tor-browser

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

browser_pip_ui.js (1710B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 const { UrlbarTestUtils } = ChromeUtils.importESModule(
      7  "resource://testing-common/UrlbarTestUtils.sys.mjs"
      8 );
      9 
     10 add_task(async function pip_urlbar_shows_readonly_opener_url() {
     11  const [tab, chromePiP] = await newTabWithPiP();
     12 
     13  // correct URL at the beginning
     14  const expectedURL = UrlbarTestUtils.trimURL(
     15    tab.linkedBrowser.currentURI.spec
     16  );
     17  is(chromePiP.gURLBar.value, expectedURL, "PiP urlbar shows opener url");
     18  ok(chromePiP.gURLBar.readOnly, "Location bar is read-only in PiP");
     19 
     20  // correct URL after PiP location change
     21  const onLocationChange = BrowserTestUtils.waitForLocationChange(
     22    chromePiP.gBrowser,
     23    "about:blank#0"
     24  );
     25  await SpecialPowers.spawn(chromePiP.gBrowser.selectedBrowser, [], () => {
     26    content.location.href = "about:blank#0";
     27  });
     28  await onLocationChange;
     29  is(chromePiP.gURLBar.value, expectedURL, "PiP urlbar shows opener url");
     30 
     31  // Cleanup.
     32  await BrowserTestUtils.closeWindow(chromePiP);
     33  BrowserTestUtils.removeTab(tab);
     34 });
     35 
     36 add_task(async function pip_alwaysontop_chromeFlag() {
     37  const [tab, chromePiP] = await newTabWithPiP();
     38 
     39  // Currently, we cannot check the widget is actually alwaysontop. But we can check
     40  // that the respective chromeFlag is set.
     41  const chromeFlags = chromePiP.docShell.treeOwner
     42    .QueryInterface(Ci.nsIInterfaceRequestor)
     43    .getInterface(Ci.nsIAppWindow).chromeFlags;
     44  ok(
     45    chromeFlags & Ci.nsIWebBrowserChrome.CHROME_ALWAYS_ON_TOP,
     46    "PiP has alwaysontop chrome flag"
     47  );
     48 
     49  // Cleanup.
     50  await BrowserTestUtils.closeWindow(chromePiP);
     51  BrowserTestUtils.removeTab(tab);
     52 });