michael@0: /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
michael@0: /* Any copyright is dedicated to the Public Domain.
michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0:
michael@0: "use strict";
michael@0:
michael@0: // Test that focus doesn't leave the style editor when adding a property
michael@0: // (bug 719916)
michael@0:
michael@0: let test = asyncTest(function*() {
michael@0: yield addTab("data:text/html,
Some header text
");
michael@0: let {toolbox, inspector, view} = yield openRuleView();
michael@0:
michael@0: info("Selecting the test node");
michael@0: yield selectNode("h1", inspector);
michael@0:
michael@0: info("Getting the ruleclose brace element");
michael@0: let brace = view.doc.querySelector(".ruleview-ruleclose");
michael@0:
michael@0: info("Clicking on the brace element to focus the new property field");
michael@0: let onFocus = once(brace.parentNode, "focus", true);
michael@0: brace.click();
michael@0: yield onFocus;
michael@0:
michael@0: info("Entering a property name");
michael@0: let editor = getCurrentInplaceEditor(view);
michael@0: editor.input.value = "color";
michael@0:
michael@0: info("Typing ENTER to focus the next field: property value");
michael@0: let onFocus = once(brace.parentNode, "focus", true);
michael@0: EventUtils.sendKey("return");
michael@0: yield onFocus;
michael@0: ok(true, "The value field was focused");
michael@0:
michael@0: info("Entering a property value");
michael@0: let editor = getCurrentInplaceEditor(view);
michael@0: editor.input.value = "green";
michael@0:
michael@0: info("Typing ENTER again should focus a new property name");
michael@0: let onFocus = once(brace.parentNode, "focus", true);
michael@0: EventUtils.sendKey("return");
michael@0: yield onFocus;
michael@0: ok(true, "The new property name field was focused");
michael@0: getCurrentInplaceEditor(view).input.blur();
michael@0: });
michael@0:
michael@0: function getCurrentInplaceEditor(view) {
michael@0: return inplaceEditor(view.doc.activeElement);
michael@0: }