tor-browser

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

browser_grids_grid-list-on-iframe-reloaded.js (2016B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // Tests that the list of grids does refresh when an iframe containing a grid is removed
      7 // and re-created.
      8 // See bug 1378306 where this happened with jsfiddle.
      9 
     10 const TEST_URI = URL_ROOT + "doc_iframe_reloaded.html";
     11 
     12 add_task(async function () {
     13  await addTab(TEST_URI);
     14  const { gridInspector, inspector } = await openLayoutView();
     15  const { document: doc } = gridInspector;
     16  const { highlighters, store } = inspector;
     17  const gridList = doc.getElementById("grid-list");
     18  const checkbox = gridList.children[0].querySelector("input");
     19 
     20  info("Clicking on the first checkbox to highlight the grid");
     21  const onHighlighterShown = highlighters.once("grid-highlighter-shown");
     22  const onCheckboxChange = waitUntilState(
     23    store,
     24    state => state.grids.length == 1 && state.grids[0].highlighted
     25  );
     26  checkbox.click();
     27  await onHighlighterShown;
     28  await onCheckboxChange;
     29 
     30  ok(checkbox.checked, "The checkbox is checked");
     31  is(gridList.childNodes.length, 1, "There's one grid in the list");
     32  is(highlighters.gridHighlighters.size, 1, "There's a highlighter shown");
     33  is(
     34    highlighters.state.grids.size,
     35    1,
     36    "There's a saved grid state to be restored."
     37  );
     38 
     39  info("Reload the iframe in content and expect the grid list to update");
     40  const oldGrid = store.getState().grids[0];
     41  const onNewListUnchecked = waitUntilState(
     42    store,
     43    state =>
     44      state.grids.length == 1 &&
     45      state.grids[0].actorID !== oldGrid.actorID &&
     46      !state.grids[0].highlighted
     47  );
     48  const onHighlighterHidden = highlighters.once("grid-highlighter-hidden");
     49  SpecialPowers.spawn(gBrowser.selectedBrowser, [], () =>
     50    content.wrappedJSObject.reloadIFrame()
     51  );
     52  await onNewListUnchecked;
     53  await onHighlighterHidden;
     54 
     55  is(gridList.childNodes.length, 1, "There's still one grid in the list");
     56  ok(!highlighters.state.grids.size, "No grids to be restored on page reload.");
     57 });