tor-browser

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

browser_changes_declaration_disable.js (1483B)


      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 toggling a CSS declaration in the Rule view is tracked.
      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  await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
     19  const { inspector, view: ruleView } = await openRuleView();
     20  const { document: doc, store } = selectChangesView(inspector);
     21 
     22  await selectNode("div", inspector);
     23  const prop = getTextProperty(ruleView, 1, { color: "red" });
     24 
     25  let onTrackChange = waitForDispatch(store, "TRACK_CHANGE");
     26  info("Disable the first declaration");
     27  await togglePropStatus(ruleView, prop);
     28  info("Wait for change to be tracked");
     29  await onTrackChange;
     30 
     31  let removedDeclarations = getRemovedDeclarations(doc);
     32  is(
     33    removedDeclarations.length,
     34    1,
     35    "Only one declaration was tracked as removed"
     36  );
     37 
     38  onTrackChange = waitForDispatch(store, "TRACK_CHANGE");
     39  info("Re-enable the first declaration");
     40  await togglePropStatus(ruleView, prop);
     41  info("Wait for change to be tracked");
     42  await onTrackChange;
     43 
     44  const addedDeclarations = getAddedDeclarations(doc);
     45  removedDeclarations = getRemovedDeclarations(doc);
     46  is(addedDeclarations.length, 0, "No declarations were tracked as added");
     47  is(removedDeclarations.length, 0, "No declarations were tracked as removed");
     48 });