tor-browser

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

browser_wireframe_basic.js (1478B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 add_setup(async function () {
      5  await SpecialPowers.pushPrefEnv({
      6    set: [["test.wait300msAfterTabSwitch", true]],
      7  });
      8 });
      9 
     10 /**
     11 * Ensure that document wireframes are persisted when enabled,
     12 * and that we can generate previews for them.
     13 */
     14 add_task(async function thumbnails_wireframe_basic() {
     15  // Wireframes only works when Fission is enabled.
     16  if (!Services.appinfo.fissionAutostart) {
     17    ok(true, "Skipping test_wireframes when Fission is not enabled.");
     18    return;
     19  }
     20 
     21  await SpecialPowers.pushPrefEnv({
     22    set: [["browser.history.collectWireframes", true]],
     23  });
     24 
     25  let tab = await BrowserTestUtils.openNewForegroundTab(
     26    gBrowser,
     27    "https://www.example.com/"
     28  );
     29  await TabStateFlusher.flush(tab.linkedBrowser);
     30  info("Checking a loaded tab");
     31  checkWireframeForTab(tab);
     32 
     33  await BrowserTestUtils.switchTab(gBrowser, gBrowser.tabs[0]);
     34  gBrowser.discardBrowser(tab, true);
     35 
     36  info("Checking a discarded tab");
     37  checkWireframeForTab(tab);
     38 
     39  gBrowser.removeTab(tab);
     40 });
     41 
     42 function checkWireframeForTab(tab) {
     43  let wireframe = PageWireframes.getWireframeState(tab);
     44  ok(wireframe, "After load: Got wireframe state");
     45  Assert.greater(wireframe.rects.length, 0, "After load: Got wireframe rects");
     46  let wireframeElement = PageWireframes.getWireframeElementForTab(tab);
     47  is(wireframeElement.tagName, "svg", "Got wireframe element");
     48 }