summaryrefslogtreecommitdiff
path: root/toolkit/devtools/styleinspector/test/browser_ruleview_add-property-cancel_03.js
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2016-10-16 19:34:53 -0400
committerMatt A. Tobin <email@mattatobin.com>2016-10-16 19:34:53 -0400
commit81805ce3f63e2e4a799bd54f174083c58a9b5640 (patch)
tree6e13374b213ac9b2ae74c25d8aac875faf71fdd0 /toolkit/devtools/styleinspector/test/browser_ruleview_add-property-cancel_03.js
parent28c8da71bf521bb3ee76f27b8a241919e24b7cd5 (diff)
downloadpalemoon-gre-81805ce3f63e2e4a799bd54f174083c58a9b5640.tar.gz
Move Mozilla DevTools to Platform - Part 3: Merge the browser/devtools and toolkit/devtools adjusting for directory collisions
Diffstat (limited to 'toolkit/devtools/styleinspector/test/browser_ruleview_add-property-cancel_03.js')
-rw-r--r--toolkit/devtools/styleinspector/test/browser_ruleview_add-property-cancel_03.js68
1 files changed, 68 insertions, 0 deletions
diff --git a/toolkit/devtools/styleinspector/test/browser_ruleview_add-property-cancel_03.js b/toolkit/devtools/styleinspector/test/browser_ruleview_add-property-cancel_03.js
new file mode 100644
index 000000000..aafd54b46
--- /dev/null
+++ b/toolkit/devtools/styleinspector/test/browser_ruleview_add-property-cancel_03.js
@@ -0,0 +1,68 @@
+/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// Test cancelling the addition of a new property in the rule-view
+
+add_task(function*() {
+ yield addTab("data:text/html;charset=utf-8,browser_ruleview_ui.js");
+ let {toolbox, inspector, view} = yield openRuleView();
+
+ info("Creating the test document");
+ let style = "" +
+ "#testid {" +
+ " background-color: blue;" +
+ "}" +
+ ".testclass, .unmatched {" +
+ " background-color: green;" +
+ "}";
+ let styleNode = addStyle(content.document, style);
+ content.document.body.innerHTML = "<div id='testid' class='testclass'>Styled Node</div>" +
+ "<div id='testid2'>Styled Node</div>";
+
+ yield testCancelNew(inspector, view);
+ yield testCancelNewOnEscape(inspector, view);
+ yield inspector.once("inspector-updated");
+});
+
+function* testCancelNew(inspector, ruleView) {
+ // Start at the beginning: start to add a rule to the element's style
+ // declaration, but leave it empty.
+
+ let elementRuleEditor = getRuleViewRuleEditor(ruleView, 0);
+ let editor = yield focusEditableField(elementRuleEditor.closeBrace);
+
+ is(inplaceEditor(elementRuleEditor.newPropSpan), editor,
+ "Property editor is focused");
+
+ let onBlur = once(editor.input, "blur");
+ editor.input.blur();
+ yield onBlur;
+
+ ok(!elementRuleEditor.rule._applyingModifications, "Shouldn't have an outstanding modification request after a cancel.");
+ is(elementRuleEditor.rule.textProps.length, 0, "Should have canceled creating a new text property.");
+ ok(!elementRuleEditor.propertyList.hasChildNodes(), "Should not have any properties.");
+}
+
+function* testCancelNewOnEscape(inspector, ruleView) {
+ // Start at the beginning: start to add a rule to the element's style
+ // declaration, add some text, then press escape.
+
+ let elementRuleEditor = getRuleViewRuleEditor(ruleView, 0);
+ let editor = yield focusEditableField(elementRuleEditor.closeBrace);
+
+ is(inplaceEditor(elementRuleEditor.newPropSpan), editor, "Next focused editor should be the new property editor.");
+ for (let ch of "background") {
+ EventUtils.sendChar(ch, ruleView.doc.defaultView);
+ }
+
+ let onBlur = once(editor.input, "blur");
+ EventUtils.synthesizeKey("VK_ESCAPE", {});
+ yield onBlur;
+
+ ok(!elementRuleEditor.rule._applyingModifications, "Shouldn't have an outstanding modification request after a cancel.");
+ is(elementRuleEditor.rule.textProps.length, 0, "Should have canceled creating a new text property.");
+ ok(!elementRuleEditor.propertyList.hasChildNodes(), "Should not have any properties.");
+}