tor-browser

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

browser_webconsole_sourcemap_nosource.js (1715B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // Test that a missing original source is reported.
      7 
      8 const JS_URL = URL_ROOT_COM_SSL + "code_bundle_nosource.js";
      9 
     10 const PAGE_URL = `data:text/html,
     11 <!doctype html>
     12 
     13 <html>
     14  <head>
     15    <meta charset="utf-8"/>
     16    <title>Empty test page to test source map with missing original source</title>
     17  </head>
     18 
     19  <body>
     20    <script src="${JS_URL}"></script>
     21  </body>
     22 
     23 </html>`;
     24 
     25 add_task(async function () {
     26  await pushPref("devtools.source-map.client-service.enabled", true);
     27 
     28  const hud = await openNewTabAndConsole(PAGE_URL);
     29  const toolbox = hud.ui.wrapper.toolbox;
     30 
     31  info('Finding "here" message and waiting for source map to be applied');
     32  await waitFor(() => {
     33    const node = findConsoleAPIMessage(hud, "here");
     34    if (!node) {
     35      return false;
     36    }
     37    const messageLocationNode = node.querySelector(".message-location");
     38    const url = messageLocationNode.getAttribute("data-url");
     39    return url.includes("nosuchfile");
     40  });
     41 
     42  await testOpenInDebugger(hud, {
     43    text: "here",
     44    typeSelector: ".console-api",
     45    // Even if the source map doesn't exists, this original location is opened at the expected location
     46    url: "https://example.com/browser/devtools/client/webconsole/test/browser/nosuchfile.js",
     47    line: 12,
     48    column: 1,
     49  });
     50 
     51  info("Selecting the console again");
     52  await toolbox.selectTool("webconsole");
     53 
     54  const node = await waitFor(() => findWarningMessage(hud, "original source"));
     55  ok(node, "source map error is displayed in web console");
     56 
     57  ok(
     58    !!node.querySelector(".learn-more-link"),
     59    "source map error has learn more link"
     60  );
     61 });