tor-browser

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

browser_reload_tab.js (2525B)


      1 "use strict";
      2 
      3 /**
      4 * Check that customize mode doesn't break when its tab is reloaded.
      5 */
      6 add_task(async function reload_tab() {
      7  let initialTab = gBrowser.selectedTab;
      8  let customizeTab = BrowserTestUtils.addTab(gBrowser, "about:blank");
      9  gCustomizeMode.setTab(customizeTab);
     10  let customizationContainer = document.getElementById(
     11    "customization-container"
     12  );
     13 
     14  is(
     15    customizationContainer.clientWidth,
     16    0,
     17    "Customization container shouldn't be visible (X)"
     18  );
     19  is(
     20    customizationContainer.clientHeight,
     21    0,
     22    "Customization container shouldn't be visible (Y)"
     23  );
     24 
     25  let customizePromise = BrowserTestUtils.waitForEvent(
     26    gNavToolbox,
     27    "customizationready"
     28  );
     29  gCustomizeMode.enter();
     30  await customizePromise;
     31 
     32  let tabReloaded = new Promise(resolve => {
     33    gBrowser.addTabsProgressListener({
     34      async onLocationChange(aBrowser) {
     35        if (customizeTab.linkedBrowser == aBrowser) {
     36          gBrowser.removeTabsProgressListener(this);
     37          await Promise.resolve();
     38          resolve();
     39        }
     40      },
     41    });
     42  });
     43  gBrowser.reloadTab(customizeTab);
     44  await tabReloaded;
     45 
     46  is(
     47    gBrowser.getIcon(customizeTab),
     48    "chrome://browser/skin/customize.svg",
     49    "Tab should have customize icon"
     50  );
     51  is(
     52    customizeTab.getAttribute("customizemode"),
     53    "true",
     54    "Tab should be in customize mode"
     55  );
     56  Assert.greater(
     57    customizationContainer.clientWidth,
     58    0,
     59    "Customization container should be visible (X)"
     60  );
     61  Assert.greater(
     62    customizationContainer.clientHeight,
     63    0,
     64    "Customization container should be visible (Y)"
     65  );
     66 
     67  customizePromise = BrowserTestUtils.waitForEvent(
     68    gNavToolbox,
     69    "aftercustomization"
     70  );
     71  await BrowserTestUtils.switchTab(gBrowser, initialTab);
     72  await customizePromise;
     73 
     74  customizePromise = BrowserTestUtils.waitForEvent(
     75    gNavToolbox,
     76    "customizationready"
     77  );
     78  await BrowserTestUtils.switchTab(gBrowser, customizeTab);
     79  await customizePromise;
     80 
     81  is(
     82    gBrowser.getIcon(customizeTab),
     83    "chrome://browser/skin/customize.svg",
     84    "Tab should still have customize icon"
     85  );
     86  is(
     87    customizeTab.getAttribute("customizemode"),
     88    "true",
     89    "Tab should still be in customize mode"
     90  );
     91  Assert.greater(
     92    customizationContainer.clientWidth,
     93    0,
     94    "Customization container should still be visible (X)"
     95  );
     96  Assert.greater(
     97    customizationContainer.clientHeight,
     98    0,
     99    "Customization container should still be visible (Y)"
    100  );
    101 
    102  await endCustomizing();
    103 });