summaryrefslogtreecommitdiffstats
path: root/devtools/client/inspector/changes/test/browser_changes_declaration_disable.js
blob: 4c7141cdc6c098ea132b7e58d8f6b4c9e5d52d9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* Any copyright is dedicated to the Public Domain.
 http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

// Test that toggling a CSS declaration in the Rule view is tracked.

const TEST_URI = `
  <style type='text/css'>
    div {
      color: red;
    }
  </style>
  <div></div>
`;

add_task(async function () {
  await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
  const { inspector, view: ruleView } = await openRuleView();
  const { document: doc, store } = selectChangesView(inspector);

  await selectNode("div", inspector);
  const prop = getTextProperty(ruleView, 1, { color: "red" });

  let onTrackChange = waitForDispatch(store, "TRACK_CHANGE");
  info("Disable the first declaration");
  await togglePropStatus(ruleView, prop);
  info("Wait for change to be tracked");
  await onTrackChange;

  let removedDeclarations = getRemovedDeclarations(doc);
  is(
    removedDeclarations.length,
    1,
    "Only one declaration was tracked as removed"
  );

  onTrackChange = waitForDispatch(store, "TRACK_CHANGE");
  info("Re-enable the first declaration");
  await togglePropStatus(ruleView, prop);
  info("Wait for change to be tracked");
  await onTrackChange;

  const addedDeclarations = getAddedDeclarations(doc);
  removedDeclarations = getRemovedDeclarations(doc);
  is(addedDeclarations.length, 0, "No declarations were tracked as added");
  is(removedDeclarations.length, 0, "No declarations were tracked as removed");
});