summaryrefslogtreecommitdiffstats
path: root/devtools/client/inspector/changes/test/browser_changes_declaration_rename.js
diff options
context:
space:
mode:
Diffstat (limited to 'devtools/client/inspector/changes/test/browser_changes_declaration_rename.js')
-rw-r--r--devtools/client/inspector/changes/test/browser_changes_declaration_rename.js68
1 files changed, 68 insertions, 0 deletions
diff --git a/devtools/client/inspector/changes/test/browser_changes_declaration_rename.js b/devtools/client/inspector/changes/test/browser_changes_declaration_rename.js
new file mode 100644
index 0000000000..245ce50121
--- /dev/null
+++ b/devtools/client/inspector/changes/test/browser_changes_declaration_rename.js
@@ -0,0 +1,68 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// Test that renaming the property of 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;
+
+ const oldPropertyName = "color";
+ const newPropertyName = "background-color";
+
+ info(`Rename the CSS declaration name to ${newPropertyName}`);
+ onTrackChange = waitForDispatch(store, "TRACK_CHANGE");
+ await renameProperty(ruleView, prop, newPropertyName);
+ info("Wait for the change to be tracked");
+ await onTrackChange;
+
+ const removeDecl = getRemovedDeclarations(doc);
+ const addDecl = getAddedDeclarations(doc);
+
+ is(removeDecl.length, 1, "One declaration tracked as removed");
+ is(
+ removeDecl[0].property,
+ oldPropertyName,
+ `Removed declaration has old property name: ${oldPropertyName}`
+ );
+ is(addDecl.length, 1, "One declaration tracked as added");
+ is(
+ addDecl[0].property,
+ newPropertyName,
+ `Added declaration has new property name: ${newPropertyName}`
+ );
+
+ info(
+ `Reverting the CSS declaration name to ${oldPropertyName} should clear changes.`
+ );
+ onTrackChange = waitForDispatch(store, "TRACK_CHANGE");
+ await renameProperty(ruleView, prop, oldPropertyName);
+ info("Wait for the change to be tracked");
+ await onTrackChange;
+
+ await waitFor(
+ () => !getRemovedDeclarations(doc).length,
+ "No declaration tracked as removed"
+ );
+ await waitFor(
+ () => !getAddedDeclarations(doc).length,
+ "No declaration tracked as added"
+ );
+});