browser_changes_declaration_remove_ahead.js (1828B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 // Test that the correct declaration is identified and changed after removing a 7 // declaration positioned ahead of it in the same CSS rule. 8 9 const TEST_URI = ` 10 <style type='text/css'> 11 div { 12 color: red; 13 display: block; 14 } 15 </style> 16 <div></div> 17 `; 18 19 add_task(async function () { 20 await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); 21 const { inspector, view: ruleView } = await openRuleView(); 22 const { document: doc, store } = selectChangesView(inspector); 23 24 await selectNode("div", inspector); 25 const prop1 = getTextProperty(ruleView, 1, { color: "red" }); 26 const prop2 = getTextProperty(ruleView, 1, { display: "block" }); 27 28 let onTrackChange = waitForDispatch(store, "TRACK_CHANGE"); 29 info("Change the second declaration"); 30 await setProperty(ruleView, prop2, "grid"); 31 await onTrackChange; 32 33 onTrackChange = waitForDispatch(store, "TRACK_CHANGE"); 34 info("Remove the first declaration"); 35 await removeProperty(ruleView, prop1); 36 await onTrackChange; 37 38 onTrackChange = waitForDispatch(store, "TRACK_CHANGE"); 39 info("Change the second declaration again"); 40 await setProperty(ruleView, prop2, "flex"); 41 info("Wait for change to be tracked"); 42 await onTrackChange; 43 44 // Ensure changes to the second declaration were tracked after removing the first one. 45 await waitFor( 46 () => getRemovedDeclarations(doc).length == 2, 47 "Two declarations should have been tracked as removed" 48 ); 49 await waitFor(() => { 50 const addDecl = getAddedDeclarations(doc); 51 return addDecl.length == 1 && addDecl[0].value == "flex"; 52 }, "One declaration should have been tracked as added, and the added declaration to have updated property value"); 53 });