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