tor-browser

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

browser_source_map-init.js (1659B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 // Test that the source map service initializes properly when source
      5 // actors have already been created.  Regression test for bug 1391768.
      6 
      7 "use strict";
      8 
      9 const JS_URL = URL_ROOT_SSL + "code_bundle_no_race.js";
     10 
     11 const PAGE_URL = `data:text/html,
     12 <!doctype html>
     13 
     14 <html>
     15  <head>
     16    <meta charset="utf-8"/>
     17    <title>Empty test page to test race case</title>
     18  </head>
     19 
     20  <body>
     21    <script src="${JS_URL}"></script>
     22  </body>
     23 
     24 </html>`;
     25 
     26 const ORIGINAL_URL = "webpack:///code_no_race.js";
     27 
     28 const GENERATED_LINE = 84;
     29 const ORIGINAL_LINE = 11;
     30 
     31 add_task(async function () {
     32  // Opening the debugger causes the source actors to be created.
     33  const toolbox = await openNewTabAndToolbox(PAGE_URL, "jsdebugger");
     34  // In bug 1391768, when the sourceMapURLService was created, it was
     35  // ignoring any source actors that already existed, leading to
     36  // source-mapping failures for those.
     37  const service = toolbox.sourceMapURLService;
     38 
     39  info(`checking original location for ${JS_URL}:${GENERATED_LINE}`);
     40  const newLoc = await new Promise(r =>
     41    service.subscribeByURL(JS_URL, GENERATED_LINE, undefined, r)
     42  );
     43  is(newLoc.url, ORIGINAL_URL, "check mapped URL");
     44  is(newLoc.line, ORIGINAL_LINE, "check mapped line number");
     45 
     46  // See Bug 1637793 and Bug 1621337.
     47  // Ideally the debugger should only resolve when the worker targets have been
     48  // retrieved, which should be fixed by Bug 1621337 or a followup.
     49  info("Wait for all pending requests to settle on the DevToolsClient");
     50  await toolbox.commands.client.waitForRequestsToSettle();
     51 });