tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

browser_styleeditor_sourcemap_chrome.js (1374B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 http://creativecommons.org/publicdomain/zero/1.0/ */
      3 "use strict";
      4 
      5 const TEST_URI = URL_ROOT_SSL + "doc_sourcemap_chrome.html";
      6 const CHROME_TEST_URI = CHROME_URL_ROOT + "doc_sourcemap_chrome.html";
      7 const GENERATED_NAME = "sourcemaps_chrome.css";
      8 const ORIGINAL_NAME = "sourcemaps.scss";
      9 
     10 /**
     11 * Test that a sourcemap served by a chrome URL for a http document will not be resolved.
     12 */
     13 add_task(async function () {
     14  const { ui } = await openStyleEditorForURL(TEST_URI);
     15  ok(
     16    findStylesheetByName(ui, GENERATED_NAME),
     17    "Sourcemap not resolved: generated source is listed"
     18  );
     19  ok(
     20    !findStylesheetByName(ui, ORIGINAL_NAME),
     21    "Sourcemap not resolved: original source is not listed"
     22  );
     23 });
     24 
     25 /**
     26 * Test that a sourcemap served by a chrome URL for a chrome document is resolved.
     27 */
     28 add_task(async function () {
     29  const { ui } = await openStyleEditorForURL(CHROME_TEST_URI);
     30  ok(
     31    findStylesheetByName(ui, ORIGINAL_NAME),
     32    "Sourcemap resolved: original source is listed"
     33  );
     34  ok(
     35    !findStylesheetByName(ui, GENERATED_NAME),
     36    "Sourcemap resolved: generated source is not listed"
     37  );
     38 });
     39 
     40 function findStylesheetByName(ui, name) {
     41  return ui.editors.some(
     42    editor =>
     43      editor.summary
     44        .querySelector(".stylesheet-name > label")
     45        .getAttribute("value") === name
     46  );
     47 }