tor-browser

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

browser_aboutdebugging_devtoolstoolbox_navigate_to_url.js (1895B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 const NEW_TAB_TITLE = "PAGE 2";
      7 const TAB_URL = "data:text/html,<title>PAGE</title>";
      8 const NEW_TAB_URL = `data:text/html,<title>${NEW_TAB_TITLE}</title>`;
      9 
     10 /**
     11 * This test file ensures that the URL input for DebugTargetInfo navigates the target to
     12 * the specified URL.
     13 */
     14 add_task(async function () {
     15  const { document, tab, window } = await openAboutDebugging();
     16 
     17  info("Open a new background tab.");
     18  const debug_tab = await addTab(TAB_URL, { background: true });
     19 
     20  await selectThisFirefoxPage(document, window.AboutDebugging.store);
     21  const devToolsToolbox = await openAboutDevtoolsToolbox(
     22    document,
     23    tab,
     24    window,
     25    "PAGE"
     26  );
     27  const { devtoolsDocument, devtoolsTab, devtoolsWindow } = devToolsToolbox;
     28  const toolbox = getToolbox(devtoolsWindow);
     29 
     30  const urlInput = devtoolsDocument.querySelector(".devtools-textinput");
     31  const waitForLoadedPanelsReload = await watchForLoadedPanelsReload(toolbox);
     32 
     33  await synthesizeUrlKeyInput(devToolsToolbox, urlInput, NEW_TAB_URL);
     34 
     35  await waitForLoadedPanelsReload();
     36 
     37  info("Test that the debug target navigated to the specified URL.");
     38  await waitUntil(
     39    () =>
     40      toolbox.target.url === NEW_TAB_URL &&
     41      debug_tab.linkedBrowser.currentURI.spec === NEW_TAB_URL
     42  );
     43  ok(true, "Target navigated.");
     44  ok(toolbox.target.title.includes(NEW_TAB_TITLE), "Target's title updated.");
     45  is(urlInput.value, NEW_TAB_URL, "Input url updated.");
     46 
     47  await closeAboutDevtoolsToolbox(document, devtoolsTab, window);
     48 
     49  info("Remove the background tab");
     50  await removeTab(debug_tab);
     51  await waitUntil(() => !findDebugTargetByText("NEW_TAB_TITLE", document));
     52  await waitForAboutDebuggingRequests(window.AboutDebugging.store);
     53 
     54  info("Remove the about:debugging tab.");
     55  await removeTab(tab);
     56 });