1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/styleinspector/test/browser_ruleview_keybindings.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,49 @@ 1.4 +/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ 1.5 +/* Any copyright is dedicated to the Public Domain. 1.6 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.7 + 1.8 +"use strict"; 1.9 + 1.10 +// Test that focus doesn't leave the style editor when adding a property 1.11 +// (bug 719916) 1.12 + 1.13 +let test = asyncTest(function*() { 1.14 + yield addTab("data:text/html,<h1>Some header text</h1>"); 1.15 + let {toolbox, inspector, view} = yield openRuleView(); 1.16 + 1.17 + info("Selecting the test node"); 1.18 + yield selectNode("h1", inspector); 1.19 + 1.20 + info("Getting the ruleclose brace element"); 1.21 + let brace = view.doc.querySelector(".ruleview-ruleclose"); 1.22 + 1.23 + info("Clicking on the brace element to focus the new property field"); 1.24 + let onFocus = once(brace.parentNode, "focus", true); 1.25 + brace.click(); 1.26 + yield onFocus; 1.27 + 1.28 + info("Entering a property name"); 1.29 + let editor = getCurrentInplaceEditor(view); 1.30 + editor.input.value = "color"; 1.31 + 1.32 + info("Typing ENTER to focus the next field: property value"); 1.33 + let onFocus = once(brace.parentNode, "focus", true); 1.34 + EventUtils.sendKey("return"); 1.35 + yield onFocus; 1.36 + ok(true, "The value field was focused"); 1.37 + 1.38 + info("Entering a property value"); 1.39 + let editor = getCurrentInplaceEditor(view); 1.40 + editor.input.value = "green"; 1.41 + 1.42 + info("Typing ENTER again should focus a new property name"); 1.43 + let onFocus = once(brace.parentNode, "focus", true); 1.44 + EventUtils.sendKey("return"); 1.45 + yield onFocus; 1.46 + ok(true, "The new property name field was focused"); 1.47 + getCurrentInplaceEditor(view).input.blur(); 1.48 +}); 1.49 + 1.50 +function getCurrentInplaceEditor(view) { 1.51 + return inplaceEditor(view.doc.activeElement); 1.52 +}