browser/devtools/styleinspector/test/browser_ruleview_add-property-cancel_01.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:b2bd9ea34706
1 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
2 /* Any copyright is dedicated to the Public Domain.
3 http://creativecommons.org/publicdomain/zero/1.0/ */
4
5 "use strict";
6
7 // Testing various inplace-editor behaviors in the rule-view
8
9 let TEST_URL = 'url("' + TEST_URL_ROOT + 'doc_test_image.png")';
10 let PAGE_CONTENT = [
11 '<style type="text/css">',
12 ' #testid {',
13 ' background-color: blue;',
14 ' }',
15 ' .testclass {',
16 ' background-color: green;',
17 ' }',
18 '</style>',
19 '<div id="testid" class="testclass">Styled Node</div>'
20 ].join("\n");
21
22 let test = asyncTest(function*() {
23 yield addTab("data:text/html,test rule view user changes");
24
25 info("Creating the test document");
26 content.document.body.innerHTML = PAGE_CONTENT;
27
28 info("Opening the rule-view");
29 let {toolbox, inspector, view} = yield openRuleView();
30
31 info("Selecting the test element");
32 yield selectNode("#testid", inspector);
33
34 yield testCancelNew(view);
35 });
36
37 function* testCancelNew(view) {
38 info("Test adding a new rule to the element's style declaration and leaving it empty.");
39
40 let elementRuleEditor = view.element.children[0]._ruleEditor;
41
42 info("Focusing a new property name in the rule-view");
43 let editor = yield focusEditableField(elementRuleEditor.closeBrace);
44 is(inplaceEditor(elementRuleEditor.newPropSpan), editor, "The new property editor got focused");
45
46 info("Bluring the editor input");
47 let onBlur = once(editor.input, "blur");
48 editor.input.blur();
49 yield onBlur;
50
51 info("Checking the state of canceling a new property name editor");
52 ok(!elementRuleEditor.rule._applyingModifications, "Shouldn't have an outstanding request after a cancel.");
53 is(elementRuleEditor.rule.textProps.length, 0, "Should have canceled creating a new text property.");
54 ok(!elementRuleEditor.propertyList.hasChildNodes(), "Should not have any properties.");
55 }

mercurial