tor-browser

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

browser_tab_descriptor_fission.js (2217B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 /**
      7 * Check that tab descriptor survives after the page navigates and changes
      8 * process.
      9 */
     10 
     11 const EXAMPLE_COM_URI =
     12  "https://example.com/document-builder.sjs?html=<div id=com>com";
     13 const EXAMPLE_ORG_URI =
     14  "https://example.org/document-builder.sjs?html=<div id=org>org";
     15 
     16 add_task(async function () {
     17  const tab = await addTab(EXAMPLE_COM_URI);
     18  const toolbox = await gDevTools.showToolboxForTab(tab);
     19  const target = toolbox.target;
     20  const client = toolbox.commands.client;
     21 
     22  info("Retrieve the initial list of tab descriptors");
     23  const tabDescriptors = await client.mainRoot.listTabs();
     24  const tabDescriptor = tabDescriptors.find(
     25    d => decodeURIComponent(d.url) === EXAMPLE_COM_URI
     26  );
     27  ok(tabDescriptor, "Should have a descriptor actor for the tab");
     28 
     29  info("Retrieve the target corresponding to the TabDescriptor");
     30  const comTabTarget = await tabDescriptor.getTarget();
     31  is(
     32    target,
     33    comTabTarget,
     34    "The toolbox target is also the target associated with the tab descriptor"
     35  );
     36 
     37  const waitForDevToolsReload = await watchForDevToolsReload(
     38    gBrowser.selectedBrowser,
     39    {
     40      isErrorPage: false,
     41      waitForLoad: true,
     42    }
     43  );
     44  await tabDescriptor.navigateTo(EXAMPLE_ORG_URI, true);
     45  await waitForDevToolsReload();
     46 
     47  info("Call list tabs again to update the tab descriptor forms");
     48  await client.mainRoot.listTabs();
     49 
     50  is(
     51    decodeURIComponent(tabDescriptor.url),
     52    EXAMPLE_ORG_URI,
     53    "The existing descriptor now points to the new URI"
     54  );
     55 
     56  const newTarget = toolbox.target;
     57 
     58  is(
     59    comTabTarget.actorID,
     60    null,
     61    "With Fission or server side target switching, example.com target front is destroyed"
     62  );
     63  Assert.notEqual(
     64    comTabTarget,
     65    newTarget,
     66    "With Fission or server side target switching, a new target was created for example.org"
     67  );
     68 
     69  const onDescriptorDestroyed = tabDescriptor.once("descriptor-destroyed");
     70 
     71  await removeTab(tab);
     72 
     73  info("Wait for descriptor destroyed event");
     74  await onDescriptorDestroyed;
     75  ok(tabDescriptor.isDestroyed(), "the descriptor front is really destroyed");
     76 });