tor-browser

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

browser_source_map-reload.js (1942B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 // Test that reloading re-reads the source maps.
      5 
      6 "use strict";
      7 const INITIAL_URL =
      8  "data:text/html,<!doctype html>html><head><meta charset='utf-8'/><title>Empty test page 1</title></head><body></body></html>";
      9 const ORIGINAL_URL_1 = "webpack://code-reload/v1/code_reload_1.js";
     10 const ORIGINAL_URL_2 = "webpack://code-reload/v2/code_reload_2.js";
     11 
     12 const GENERATED_LINE = 13;
     13 const ORIGINAL_LINE = 7;
     14 
     15 const testServer = createVersionizedHttpTestServer("reload");
     16 
     17 const PAGE_URL = testServer.urlFor("doc_reload.html");
     18 const JS_URL = testServer.urlFor("code_bundle_reload.js");
     19 
     20 add_task(async function () {
     21  // Start with the empty page, then navigate, so that we can properly
     22  // listen for new sources arriving.
     23  const toolbox = await openNewTabAndToolbox(INITIAL_URL, "webconsole");
     24  const service = toolbox.sourceMapURLService;
     25 
     26  let sourceSeen = waitForSourceLoad(toolbox, JS_URL);
     27  await navigateTo(PAGE_URL);
     28  await sourceSeen;
     29 
     30  info(`checking original location for ${JS_URL}:${GENERATED_LINE}`);
     31  let newLoc = await new Promise(r =>
     32    service.subscribeByURL(JS_URL, GENERATED_LINE, undefined, r)
     33  );
     34 
     35  is(newLoc.url, ORIGINAL_URL_1, "check mapped URL");
     36  is(newLoc.line, ORIGINAL_LINE, "check mapped line number");
     37 
     38  testServer.switchToNextVersion();
     39 
     40  // Reload the page. A different source file will be loaded.
     41  sourceSeen = waitForSourceLoad(toolbox, JS_URL);
     42  await reloadBrowser();
     43  await sourceSeen;
     44 
     45  info(
     46    `checking post-reload original location for ${JS_URL}:${GENERATED_LINE}`
     47  );
     48  newLoc = await new Promise(r =>
     49    service.subscribeByURL(JS_URL, GENERATED_LINE, undefined, r)
     50  );
     51  is(newLoc.url, ORIGINAL_URL_2, "check post-reload mapped URL");
     52  is(newLoc.line, ORIGINAL_LINE, "check post-reload mapped line number");
     53 
     54  await toolbox.destroy();
     55  gBrowser.removeCurrentTab();
     56 });