tor-browser

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

browser_changes_background_tracking.js (1655B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // Test that CSS changes are collected in the background without the Changes panel visible
      7 
      8 const TEST_URI = `
      9  <style type='text/css'>
     10    div {
     11      color: red;
     12    }
     13  </style>
     14  <div></div>
     15 `;
     16 
     17 add_task(async function () {
     18  info("Ensure Changes panel is NOT the default panel; use Computed panel");
     19  await pushPref("devtools.inspector.activeSidebar", "computedview");
     20 
     21  await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
     22  const { inspector, view: ruleView } = await openRuleView();
     23 
     24  await selectNode("div", inspector);
     25  const prop = getTextProperty(ruleView, 1, { color: "red" });
     26 
     27  info("Disable the first CSS declaration");
     28  await togglePropStatus(ruleView, prop);
     29 
     30  info("Select the Changes panel");
     31  const { document: doc, store } = selectChangesView(inspector);
     32  const onTrackChange = waitForDispatch(store, "TRACK_CHANGE");
     33  const onResetChanges = waitForDispatch(store, "RESET_CHANGES");
     34 
     35  info("Wait for change to be tracked");
     36  await onTrackChange;
     37  const removedDeclarations = getRemovedDeclarations(doc);
     38  is(removedDeclarations.length, 1, "One declaration was tracked as removed");
     39 
     40  // Test for Bug 1656477. Check that changes are not cleared immediately afterwards.
     41  info("Wait to see if the RESET_CHANGES action is dispatched unexpecteldy");
     42  const sym = Symbol();
     43  const onTimeout = wait(500).then(() => sym);
     44  const raceResult = await Promise.any([onResetChanges, onTimeout]);
     45  Assert.strictEqual(raceResult, sym, "RESET_CHANGES has not been dispatched");
     46 });