tor-browser

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

browser_webconsole_logging_exceptions.js (1302B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 // Check that logging exceptions works as expected
      5 
      6 "use strict";
      7 
      8 const TEST_URI =
      9  `data:text/html;charset=utf8,` +
     10  encodeURI(`<!DOCTYPE html><script>
     11  const domExceptionOnLine2 = new DOMException("Bar");
     12  /* console.error will be on line 4 */
     13  console.error("Foo", domExceptionOnLine2);
     14 </script>`);
     15 
     16 add_task(async function () {
     17  const hud = await openNewTabAndConsole(TEST_URI);
     18 
     19  info("Wait for the error to be logged");
     20  const msgNode = await waitFor(() => findConsoleAPIMessage(hud, "Foo"));
     21  ok(!msgNode.classList.contains("open"), `Error logged not expanded`);
     22 
     23  const framesNode = await waitFor(() => msgNode.querySelector(".pane.frames"));
     24  ok(framesNode, "The DOMException stack is displayed right away");
     25 
     26  const frameNodes = framesNode.querySelectorAll(".frame");
     27  is(frameNodes.length, 1, "Expected frames are displayed");
     28  is(
     29    frameNodes[0].querySelector(".line").textContent,
     30    "2",
     31    "The stack displayed by default refers to second argument passed to console.error and refers to DOMException callsite"
     32  );
     33 
     34  info(
     35    "Check that the console.error stack is refering to console.error() callsite"
     36  );
     37  await checkMessageStack(hud, "Foo", [4]);
     38 });