tor-browser

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

browser_inspector_highlighter-07.js (2231B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 "use strict";
      4 
      5 Services.scriptloader.loadSubScript(
      6  "chrome://mochitests/content/browser/devtools/client/debugger/test/mochitest/shared-head.js",
      7  this
      8 );
      9 
     10 // Test that the highlighter works when the debugger is paused.
     11 
     12 function debuggerIsPaused(dbg) {
     13  return !!dbg.selectors.getIsPaused(dbg.selectors.getCurrentThread());
     14 }
     15 
     16 function waitForPaused(dbg) {
     17  return new Promise(resolve => {
     18    if (debuggerIsPaused(dbg)) {
     19      resolve();
     20      return;
     21    }
     22 
     23    const unsubscribe = dbg.store.subscribe(() => {
     24      if (debuggerIsPaused(dbg)) {
     25        unsubscribe();
     26        resolve();
     27      }
     28    });
     29  });
     30 }
     31 
     32 const IFRAME_SRC =
     33  "<style>" +
     34  "body {" +
     35  "margin:0;" +
     36  "height:100%;" +
     37  "background-color:red" +
     38  "}" +
     39  "</style><body>hello from iframe</body>";
     40 
     41 const DOCUMENT_SRC =
     42  "<style>" +
     43  "iframe {" +
     44  "height:200px;" +
     45  "border: 11px solid black;" +
     46  "padding: 13px;" +
     47  "}" +
     48  "body,iframe {" +
     49  "margin:0" +
     50  "}" +
     51  "</style>" +
     52  "<body>" +
     53  "<script>setInterval('debugger', 100)</script>" +
     54  "<iframe src='data:text/html;charset=utf-8," +
     55  IFRAME_SRC +
     56  "'></iframe>" +
     57  "</body>";
     58 
     59 const TEST_URI = "data:text/html;charset=utf-8," + DOCUMENT_SRC;
     60 
     61 add_task(async function () {
     62  const { inspector, toolbox, highlighterTestFront, tab } =
     63    await openInspectorForURL(TEST_URI);
     64 
     65  await gDevTools.showToolboxForTab(tab, { toolId: "jsdebugger" });
     66  const dbg = await createDebuggerContext(toolbox);
     67 
     68  await waitForPaused(dbg);
     69 
     70  await gDevTools.showToolboxForTab(tab, { toolId: "inspector" });
     71 
     72  // Needed to get this test to pass consistently :(
     73  await waitForTime(1000);
     74 
     75  info("Waiting for box mode to show.");
     76  const body = await getNodeFront("body", inspector);
     77  await inspector.highlighters.showHighlighterTypeForNode(
     78    inspector.highlighters.TYPES.BOXMODEL,
     79    body
     80  );
     81 
     82  info("Waiting for element picker to become active.");
     83  await startPicker(toolbox);
     84 
     85  info("Moving mouse over iframe padding.");
     86  await hoverElement(inspector, "iframe", 1, 1);
     87 
     88  info("Performing checks");
     89  await isNodeCorrectlyHighlighted(highlighterTestFront, "iframe");
     90 });