summaryrefslogtreecommitdiffstats
path: root/devtools/client/inspector/changes/test/browser_changes_declaration_remove.js
blob: 60b61c3196fe8c6bc979e764e43b3a0a23468372 (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
/* Any copyright is dedicated to the Public Domain.
 http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

// Test that removing a CSS declaration from a rule 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" });

  const onTrackChange = waitForDispatch(store, "TRACK_CHANGE");
  info("Remove the first declaration");
  await removeProperty(ruleView, prop);
  info("Wait for change to be tracked");
  await onTrackChange;

  const removeDecl = getRemovedDeclarations(doc);
  is(removeDecl.length, 1, "One declaration was tracked as removed");
  is(
    removeDecl[0].property,
    "color",
    "Correct declaration name was tracked as removed"
  );
  is(
    removeDecl[0].value,
    "red",
    "Correct declaration value was tracked as removed"
  );
});