browser_rules_completion-new-property_03.js (1513B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 // Regression test for a case where completing gave the wrong answer. 7 // See bug 1179318. 8 9 const TEST_URI = "<h1 style='color: red'>Header</h1>"; 10 11 add_task(async function () { 12 await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); 13 const { toolbox, inspector, view } = await openRuleView(); 14 15 info("Test autocompletion for background-color"); 16 await runAutocompletionTest(toolbox, inspector, view); 17 }); 18 19 async function runAutocompletionTest(toolbox, inspector, view) { 20 info("Selecting the test node"); 21 await selectNode("h1", inspector); 22 23 info("Focusing the new property editable field"); 24 const ruleEditor = getRuleViewRuleEditor(view, 0); 25 const editor = await focusNewRuleViewProperty(ruleEditor); 26 27 info('Sending "background" to the editable field'); 28 for (const key of "background") { 29 const onSuggest = editor.once("after-suggest"); 30 EventUtils.synthesizeKey(key, {}, view.styleWindow); 31 await onSuggest; 32 } 33 34 const itemIndex = 4; 35 36 const bgcItem = editor.popup.getItemAtIndex(itemIndex); 37 is( 38 bgcItem.label, 39 "background-color", 40 "check the expected completion element" 41 ); 42 43 editor.popup.selectedIndex = itemIndex; 44 45 const node = editor.popup.list.childNodes[itemIndex]; 46 EventUtils.synthesizeMouseAtCenter(node, {}, node.ownerGlobal); 47 48 is(editor.input.value, "background-color", "Correct value is autocompleted"); 49 }