browser_styleeditor_syncAddProperty.js (1546B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 "use strict"; 4 5 // Test that adding a new rule is synced to the style editor. 6 7 const TESTCASE_URI = TEST_BASE_HTTP + "sync.html"; 8 const TESTCASE_URI_WITH_CSP = TEST_BASE_HTTP + "sync_with_csp.html"; 9 10 const expectedText = ` 11 body { 12 border-width: 15px; 13 color: red; 14 } 15 16 #testid { 17 font-size: 4em; 18 /*! background-color: yellow; */ 19 } 20 `; 21 22 add_task(async function () { 23 const URIs = [TESTCASE_URI, TESTCASE_URI_WITH_CSP]; 24 25 for (const URI of URIs) { 26 await addTab(URI); 27 const { inspector, view } = await openRuleView(); 28 await selectNode("#testid", inspector); 29 30 info("Focusing a new property name in the rule-view on " + URI); 31 const ruleEditor = getRuleViewRuleEditor(view, 1); 32 const editor = await focusEditableField(view, ruleEditor.closeBrace); 33 is( 34 inplaceEditor(ruleEditor.newPropSpan), 35 editor, 36 "The new property editor has focus" 37 ); 38 39 const input = editor.input; 40 input.value = "/* background-color: yellow; */"; 41 42 info("Pressing return to commit and focus the new value field"); 43 const onModifications = view.once("ruleview-changed"); 44 EventUtils.synthesizeKey("VK_RETURN", {}, view.styleWindow); 45 await onModifications; 46 47 const { ui } = await openStyleEditor(); 48 const sourceEditor = await ui.editors[0].getSourceEditor(); 49 const text = sourceEditor.sourceEditor.getText(); 50 is(text, expectedText, "selector edits are synced"); 51 } 52 });