tor-browser

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

browser_toolbox_remoteness_change.js (1514B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 const URL_1 = "about:robots";
      5 const URL_2 =
      6  "data:text/html;charset=UTF-8," +
      7  encodeURIComponent('<div id="remote-page">foo</div>');
      8 
      9 // Testing navigation between processes
     10 add_task(async function () {
     11  info(`Testing navigation between processes`);
     12 
     13  info("Open a tab on a URL supporting only running in parent process");
     14  const tab = await addTab(URL_1);
     15  is(
     16    tab.linkedBrowser.currentURI.spec,
     17    URL_1,
     18    "We really are on the expected document"
     19  );
     20  is(
     21    tab.linkedBrowser.getAttribute("remote"),
     22    null,
     23    "And running in parent process"
     24  );
     25 
     26  const toolbox = await openToolboxForTab(tab);
     27 
     28  info("Navigate to a URL supporting remote process");
     29  await navigateTo(URL_2);
     30 
     31  is(
     32    tab.linkedBrowser.getAttribute("remote"),
     33    "true",
     34    "Navigated to a data: URI and switching to remote"
     35  );
     36 
     37  info("Veryify we are inspecting the new document");
     38  const console = await toolbox.selectTool("webconsole");
     39  const { ui } = console.hud;
     40  ui.wrapper.dispatchEvaluateExpression("document.location.href");
     41  await waitUntil(() => ui.outputNode.querySelector(".result"));
     42  const url = ui.outputNode.querySelector(".result");
     43 
     44  ok(
     45    url.textContent.includes(URL_2),
     46    "The console inspects the second document"
     47  );
     48 
     49  const { client } = toolbox.target;
     50  await toolbox.destroy();
     51  ok(client._transportClosed, "The client is closed after closing the toolbox");
     52 });