tor-browser

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

browser_zbug569342.js (2467B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/
      3 */
      4 
      5 add_task(async function findBarDisabledOnSomePages() {
      6  ok(!gFindBar || gFindBar.hidden, "Find bar should not be visible by default");
      7 
      8  let findbarOpenedPromise = BrowserTestUtils.waitForEvent(
      9    gBrowser.selectedTab,
     10    "TabFindInitialized"
     11  );
     12  document.documentElement.focus();
     13  // Open the Find bar before we navigate to pages that shouldn't have it.
     14  EventUtils.synthesizeKey("f", { accelKey: true });
     15  await findbarOpenedPromise;
     16  ok(!gFindBar.hidden, "Find bar should be visible");
     17 
     18  let urls = ["about:preferences", "about:addons"];
     19 
     20  for (let url of urls) {
     21    await testFindDisabled(url);
     22  }
     23 
     24  // Make sure the find bar is re-enabled after disabled page is closed.
     25  await testFindEnabled("about:about");
     26  gFindBar.close();
     27  ok(gFindBar.hidden, "Find bar should now be hidden");
     28 });
     29 
     30 function testFindDisabled(url) {
     31  return BrowserTestUtils.withNewTab(url, async function (browser) {
     32    let waitForFindBar = async () => {
     33      await new Promise(r => requestAnimationFrame(r));
     34      await new Promise(r => Services.tm.dispatchToMainThread(r));
     35    };
     36    ok(
     37      !gFindBar || gFindBar.hidden,
     38      "Find bar should not be visible at the start"
     39    );
     40    await BrowserTestUtils.synthesizeKey("/", {}, browser);
     41    await waitForFindBar();
     42    ok(
     43      !gFindBar || gFindBar.hidden,
     44      "Find bar should not be visible after fast find"
     45    );
     46    EventUtils.synthesizeKey("f", { accelKey: true });
     47    await waitForFindBar();
     48    ok(
     49      !gFindBar || gFindBar.hidden,
     50      "Find bar should not be visible after find command"
     51    );
     52    ok(
     53      document.getElementById("cmd_find").getAttribute("disabled"),
     54      "Find command should be disabled"
     55    );
     56  });
     57 }
     58 
     59 async function testFindEnabled(url) {
     60  return BrowserTestUtils.withNewTab(url, async function () {
     61    ok(
     62      !document.getElementById("cmd_find").getAttribute("disabled"),
     63      "Find command should not be disabled"
     64    );
     65 
     66    // Open Find bar and then close it.
     67    let findbarOpenedPromise = BrowserTestUtils.waitForEvent(
     68      gBrowser.selectedTab,
     69      "TabFindInitialized"
     70    );
     71    EventUtils.synthesizeKey("f", { accelKey: true });
     72    await findbarOpenedPromise;
     73    ok(!gFindBar.hidden, "Find bar should be visible again");
     74    EventUtils.synthesizeKey("KEY_Escape");
     75    ok(gFindBar.hidden, "Find bar should now be hidden");
     76  });
     77 }