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.
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/ */
5 "use strict";
7 // Test all sorts of additions and updates of properties in the rule-view
8 // FIXME: TO BE SPLIT IN *MANY* SMALLER TESTS
10 let test = asyncTest(function*() {
11 yield addTab("data:text/html;charset=utf-8,browser_ruleview_ui.js");
12 let {toolbox, inspector, view} = yield openRuleView();
14 info("Creating the test document");
15 let style = "" +
16 "#testid {" +
17 " background-color: blue;" +
18 "}" +
19 ".testclass, .unmatched {" +
20 " background-color: green;" +
21 "}";
22 let styleNode = addStyle(content.document, style);
23 content.document.body.innerHTML = "<div id='testid' class='testclass'>Styled Node</div>" +
24 "<div id='testid2'>Styled Node</div>";
26 yield testCreateNew(inspector, view);
27 yield inspector.once("inspector-updated");
28 });
30 function* testCreateNew(inspector, ruleView) {
31 // Create a new property.
32 let elementRuleEditor = ruleView.element.children[0]._ruleEditor;
33 let editor = yield focusEditableField(elementRuleEditor.closeBrace);
35 is(inplaceEditor(elementRuleEditor.newPropSpan), editor,
36 "Next focused editor should be the new property editor.");
38 let input = editor.input;
40 ok(input.selectionStart === 0 && input.selectionEnd === input.value.length,
41 "Editor contents are selected.");
43 // Try clicking on the editor's input again, shouldn't cause trouble (see bug 761665).
44 EventUtils.synthesizeMouse(input, 1, 1, {}, ruleView.doc.defaultView);
45 input.select();
47 info("Entering the property name");
48 input.value = "background-color";
50 info("Pressing RETURN and waiting for the value field focus");
51 let onFocus = once(elementRuleEditor.element, "focus", true);
52 EventUtils.sendKey("return", ruleView.doc.defaultView);
53 yield onFocus;
54 yield elementRuleEditor.rule._applyingModifications;
56 editor = inplaceEditor(ruleView.doc.activeElement);
58 is(elementRuleEditor.rule.textProps.length, 1, "Should have created a new text property.");
59 is(elementRuleEditor.propertyList.children.length, 1, "Should have created a property editor.");
60 let textProp = elementRuleEditor.rule.textProps[0];
61 is(editor, inplaceEditor(textProp.editor.valueSpan), "Should be editing the value span now.");
63 editor.input.value = "purple";
64 let onBlur = once(editor.input, "blur");
65 editor.input.blur();
66 yield onBlur;
67 yield elementRuleEditor.rule._applyingModifications;
69 is(textProp.value, "purple", "Text prop should have been changed.");
70 }