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 that focus doesn't leave the style editor when adding a property |
michael@0 | 8 | // (bug 719916) |
michael@0 | 9 | |
michael@0 | 10 | let test = asyncTest(function*() { |
michael@0 | 11 | yield addTab("data:text/html,<h1>Some header text</h1>"); |
michael@0 | 12 | let {toolbox, inspector, view} = yield openRuleView(); |
michael@0 | 13 | |
michael@0 | 14 | info("Selecting the test node"); |
michael@0 | 15 | yield selectNode("h1", inspector); |
michael@0 | 16 | |
michael@0 | 17 | info("Getting the ruleclose brace element"); |
michael@0 | 18 | let brace = view.doc.querySelector(".ruleview-ruleclose"); |
michael@0 | 19 | |
michael@0 | 20 | info("Clicking on the brace element to focus the new property field"); |
michael@0 | 21 | let onFocus = once(brace.parentNode, "focus", true); |
michael@0 | 22 | brace.click(); |
michael@0 | 23 | yield onFocus; |
michael@0 | 24 | |
michael@0 | 25 | info("Entering a property name"); |
michael@0 | 26 | let editor = getCurrentInplaceEditor(view); |
michael@0 | 27 | editor.input.value = "color"; |
michael@0 | 28 | |
michael@0 | 29 | info("Typing ENTER to focus the next field: property value"); |
michael@0 | 30 | let onFocus = once(brace.parentNode, "focus", true); |
michael@0 | 31 | EventUtils.sendKey("return"); |
michael@0 | 32 | yield onFocus; |
michael@0 | 33 | ok(true, "The value field was focused"); |
michael@0 | 34 | |
michael@0 | 35 | info("Entering a property value"); |
michael@0 | 36 | let editor = getCurrentInplaceEditor(view); |
michael@0 | 37 | editor.input.value = "green"; |
michael@0 | 38 | |
michael@0 | 39 | info("Typing ENTER again should focus a new property name"); |
michael@0 | 40 | let onFocus = once(brace.parentNode, "focus", true); |
michael@0 | 41 | EventUtils.sendKey("return"); |
michael@0 | 42 | yield onFocus; |
michael@0 | 43 | ok(true, "The new property name field was focused"); |
michael@0 | 44 | getCurrentInplaceEditor(view).input.blur(); |
michael@0 | 45 | }); |
michael@0 | 46 | |
michael@0 | 47 | function getCurrentInplaceEditor(view) { |
michael@0 | 48 | return inplaceEditor(view.doc.activeElement); |
michael@0 | 49 | } |