tor-browser

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

browser_compatibility_event_document-reload.js (2690B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // Test the issues after reloading the browsing document.
      7 
      8 const TEST_URI = `
      9  <style>
     10  body {
     11    color: blue;
     12    overflow-anchor: auto;
     13    user-modify: read-only;
     14  }
     15  div {
     16    user-select: auto;
     17  }
     18  </style>
     19  <body>
     20    <div>test</div>
     21  </body>
     22 `;
     23 
     24 const TEST_DATA_SELECTED = [
     25  {
     26    property: "overflow-anchor",
     27    url: "https://developer.mozilla.org/docs/Web/CSS/Reference/Properties/overflow-anchor",
     28  },
     29  {
     30    property: "user-modify",
     31    url: "https://developer.mozilla.org/docs/Web/CSS/Reference/Properties/user-modify",
     32  },
     33 ];
     34 
     35 const TEST_DATA_ALL = [
     36  ...TEST_DATA_SELECTED,
     37  {
     38    property: "user-select",
     39    url: "https://developer.mozilla.org/docs/Web/CSS/Reference/Properties/user-select",
     40  },
     41 ];
     42 
     43 const {
     44  COMPATIBILITY_UPDATE_SELECTED_NODE_FAILURE,
     45  COMPATIBILITY_UPDATE_TOP_LEVEL_TARGET_FAILURE,
     46 } = require("resource://devtools/client/inspector/compatibility/actions/index.js");
     47 
     48 add_task(async function () {
     49  const tab = await addTab(
     50    "data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)
     51  );
     52 
     53  const { allElementsPane, inspector, selectedElementPane } =
     54    await openCompatibilityView();
     55 
     56  info("Check the issues on the selected element");
     57  await assertIssueList(selectedElementPane, TEST_DATA_SELECTED);
     58  info("Check the issues on all elements");
     59  await assertIssueList(allElementsPane, TEST_DATA_ALL);
     60 
     61  let isUpdateSelectedNodeFailure = false;
     62  let isUpdateTopLevelTargetFailure = false;
     63  waitForDispatch(
     64    inspector.store,
     65    COMPATIBILITY_UPDATE_SELECTED_NODE_FAILURE
     66  ).then(() => {
     67    isUpdateSelectedNodeFailure = true;
     68  });
     69  waitForDispatch(
     70    inspector.store,
     71    COMPATIBILITY_UPDATE_TOP_LEVEL_TARGET_FAILURE
     72  ).then(() => {
     73    isUpdateTopLevelTargetFailure = true;
     74  });
     75 
     76  info("Reload the browsing page");
     77  const onReloaded = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
     78  const onUpdateSelectedNode = waitForUpdateSelectedNodeAction(inspector.store);
     79  const onUpdateTopLevelTarget = waitForUpdateTopLevelTargetAction(
     80    inspector.store
     81  );
     82  gBrowser.reloadTab(tab);
     83  await Promise.all([onReloaded, onUpdateSelectedNode, onUpdateTopLevelTarget]);
     84 
     85  info("Check whether the failure action will be fired or not");
     86  ok(
     87    !isUpdateSelectedNodeFailure && !isUpdateTopLevelTargetFailure,
     88    "No error occurred"
     89  );
     90 
     91  info("Check the issues on the selected element again");
     92  await assertIssueList(selectedElementPane, TEST_DATA_SELECTED);
     93  info("Check the issues on all elements again");
     94  await assertIssueList(allElementsPane, TEST_DATA_ALL);
     95 });