tor-browser

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

browser_bug495058.js (1569B)


      1 /**
      2 * Tests that the right elements of a tab are focused when it is
      3 * torn out into its own window.
      4 */
      5 
      6 const URIS = [
      7  "about:blank",
      8  "about:home",
      9  "about:sessionrestore",
     10  "about:privatebrowsing",
     11 ];
     12 
     13 add_task(async function () {
     14  for (let uri of URIS) {
     15    let tab = BrowserTestUtils.addTab(gBrowser);
     16    BrowserTestUtils.startLoadingURIString(tab.linkedBrowser, uri);
     17    await BrowserTestUtils.browserLoaded(tab.linkedBrowser, { wantLoad: uri });
     18    let isRemote = tab.linkedBrowser.isRemoteBrowser;
     19 
     20    let win = gBrowser.replaceTabWithWindow(tab);
     21 
     22    await TestUtils.topicObserved(
     23      "browser-delayed-startup-finished",
     24      subject => subject == win
     25    );
     26    // In the e10s case, we wait for the content to first paint before we focus
     27    // the URL in the new window, to optimize for content paint time.
     28    if (isRemote) {
     29      await win.gBrowserInit.firstContentWindowPaintPromise;
     30    }
     31 
     32    tab = win.gBrowser.selectedTab;
     33 
     34    Assert.equal(
     35      win.gBrowser.currentURI.spec,
     36      uri,
     37      uri + ": uri loaded in detached tab"
     38    );
     39 
     40    const expectedActiveElement = tab.isEmpty
     41      ? win.gURLBar.inputField
     42      : win.gBrowser.selectedBrowser;
     43    Assert.equal(
     44      win.document.activeElement,
     45      expectedActiveElement,
     46      `${uri}: the active element is expected: ${win.document.activeElement?.nodeName}`
     47    );
     48    Assert.equal(win.gURLBar.value, "", uri + ": urlbar is empty");
     49    Assert.ok(win.gURLBar.placeholder, uri + ": placeholder text is present");
     50 
     51    await BrowserTestUtils.closeWindow(win);
     52  }
     53 });