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 | // Test cancelling the addition of a new property in the rule-view |
michael@0 | 8 | |
michael@0 | 9 | let test = asyncTest(function*() { |
michael@0 | 10 | yield addTab("data:text/html;charset=utf-8,browser_ruleview_ui.js"); |
michael@0 | 11 | let {toolbox, inspector, view} = yield openRuleView(); |
michael@0 | 12 | |
michael@0 | 13 | info("Creating the test document"); |
michael@0 | 14 | let style = "" + |
michael@0 | 15 | "#testid {" + |
michael@0 | 16 | " background-color: blue;" + |
michael@0 | 17 | "}" + |
michael@0 | 18 | ".testclass, .unmatched {" + |
michael@0 | 19 | " background-color: green;" + |
michael@0 | 20 | "}"; |
michael@0 | 21 | let styleNode = addStyle(content.document, style); |
michael@0 | 22 | content.document.body.innerHTML = "<div id='testid' class='testclass'>Styled Node</div>" + |
michael@0 | 23 | "<div id='testid2'>Styled Node</div>"; |
michael@0 | 24 | |
michael@0 | 25 | yield testCancelNew(inspector, view); |
michael@0 | 26 | yield testCancelNewOnEscape(inspector, view); |
michael@0 | 27 | yield inspector.once("inspector-updated"); |
michael@0 | 28 | }); |
michael@0 | 29 | |
michael@0 | 30 | function* testCancelNew(inspector, ruleView) { |
michael@0 | 31 | // Start at the beginning: start to add a rule to the element's style |
michael@0 | 32 | // declaration, but leave it empty. |
michael@0 | 33 | |
michael@0 | 34 | let elementRuleEditor = ruleView.element.children[0]._ruleEditor; |
michael@0 | 35 | let editor = yield focusEditableField(elementRuleEditor.closeBrace); |
michael@0 | 36 | |
michael@0 | 37 | is(inplaceEditor(elementRuleEditor.newPropSpan), editor, |
michael@0 | 38 | "Property editor is focused"); |
michael@0 | 39 | |
michael@0 | 40 | let onBlur = once(editor.input, "blur"); |
michael@0 | 41 | editor.input.blur(); |
michael@0 | 42 | yield onBlur; |
michael@0 | 43 | |
michael@0 | 44 | ok(!elementRuleEditor.rule._applyingModifications, "Shouldn't have an outstanding modification request after a cancel."); |
michael@0 | 45 | is(elementRuleEditor.rule.textProps.length, 0, "Should have canceled creating a new text property."); |
michael@0 | 46 | ok(!elementRuleEditor.propertyList.hasChildNodes(), "Should not have any properties."); |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | function* testCancelNewOnEscape(inspector, ruleView) { |
michael@0 | 50 | // Start at the beginning: start to add a rule to the element's style |
michael@0 | 51 | // declaration, add some text, then press escape. |
michael@0 | 52 | |
michael@0 | 53 | let elementRuleEditor = ruleView.element.children[0]._ruleEditor; |
michael@0 | 54 | let editor = yield focusEditableField(elementRuleEditor.closeBrace); |
michael@0 | 55 | |
michael@0 | 56 | is(inplaceEditor(elementRuleEditor.newPropSpan), editor, "Next focused editor should be the new property editor."); |
michael@0 | 57 | for (let ch of "background") { |
michael@0 | 58 | EventUtils.sendChar(ch, ruleView.doc.defaultView); |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | let onBlur = once(editor.input, "blur"); |
michael@0 | 62 | EventUtils.synthesizeKey("VK_ESCAPE", {}); |
michael@0 | 63 | yield onBlur; |
michael@0 | 64 | |
michael@0 | 65 | ok(!elementRuleEditor.rule._applyingModifications, "Shouldn't have an outstanding modification request after a cancel."); |
michael@0 | 66 | is(elementRuleEditor.rule.textProps.length, 0, "Should have canceled creating a new text property."); |
michael@0 | 67 | ok(!elementRuleEditor.propertyList.hasChildNodes(), "Should not have any properties."); |
michael@0 | 68 | } |