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