tor-browser

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

browser_dom_fission_target_switching.js (1797B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 "use strict";
      4 
      5 // Test top-level target switching in the DOM panel.
      6 
      7 const PARENT_PROCESS_URI = "about:robots";
      8 const CONTENT_PROCESS_URI = URL_ROOT_SSL + "page_basic.html";
      9 
     10 add_task(async function () {
     11  // We use about:robots as the starting page because it will run in the parent process.
     12  // Navigating from that page to a regular content page will always trigger a target
     13  // switch, with or without fission.
     14 
     15  info("Open a page that runs in the parent process");
     16  const { panel } = await addTestTab(PARENT_PROCESS_URI);
     17 
     18  const _aProperty = getRowByLabel(panel, "_a");
     19  let buttonProperty = getRowByLabel(panel, "button");
     20 
     21  ok(!_aProperty, "There is no _a property on the about:robots page");
     22  ok(buttonProperty, "There is, however, a button property on this page");
     23 
     24  info("Navigate to a page that runs in the content process");
     25  // Wait for the DOM panel to refresh.
     26 
     27  const store = getReduxStoreFromPanel(panel);
     28 
     29  // Set repeat=2 here because the DOM panel will be refreshed twice when
     30  // navigating to a new page:
     31  // - once from watchTargets onSelected
     32  // - once from watchResources dom-complete for a top-level target
     33  const onPropertiesFetched = waitForDispatch(store, "FETCH_PROPERTIES", 2);
     34 
     35  // Also wait for the toolbox to switch to the new target, to avoid hanging requests when
     36  // the test ends.
     37  await navigateTo(CONTENT_PROCESS_URI);
     38  await onPropertiesFetched;
     39 
     40  await waitFor(() => getRowByLabel(panel, "_a"));
     41  ok(true, "This time, the _a property exists on this content process page");
     42 
     43  buttonProperty = getRowByLabel(panel, "button");
     44  ok(
     45    !buttonProperty,
     46    "There is, however, no more button property on this page"
     47  );
     48 });