browser_changes_declaration_rename.js (1983B)
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 renaming the property of a CSS declaration in the Rule view is tracked. 7 8 const TEST_URI = ` 9 <style type='text/css'> 10 div { 11 color: red; 12 } 13 </style> 14 <div></div> 15 `; 16 17 add_task(async function () { 18 await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); 19 const { inspector, view: ruleView } = await openRuleView(); 20 const { document: doc, store } = selectChangesView(inspector); 21 22 await selectNode("div", inspector); 23 const prop = getTextProperty(ruleView, 1, { color: "red" }); 24 25 let onTrackChange; 26 27 const oldPropertyName = "color"; 28 const newPropertyName = "background-color"; 29 30 info(`Rename the CSS declaration name to ${newPropertyName}`); 31 onTrackChange = waitForDispatch(store, "TRACK_CHANGE"); 32 await renameProperty(ruleView, prop, newPropertyName); 33 info("Wait for the change to be tracked"); 34 await onTrackChange; 35 36 const removeDecl = getRemovedDeclarations(doc); 37 const addDecl = getAddedDeclarations(doc); 38 39 is(removeDecl.length, 1, "One declaration tracked as removed"); 40 is( 41 removeDecl[0].property, 42 oldPropertyName, 43 `Removed declaration has old property name: ${oldPropertyName}` 44 ); 45 is(addDecl.length, 1, "One declaration tracked as added"); 46 is( 47 addDecl[0].property, 48 newPropertyName, 49 `Added declaration has new property name: ${newPropertyName}` 50 ); 51 52 info( 53 `Reverting the CSS declaration name to ${oldPropertyName} should clear changes.` 54 ); 55 onTrackChange = waitForDispatch(store, "TRACK_CHANGE"); 56 await renameProperty(ruleView, prop, oldPropertyName); 57 info("Wait for the change to be tracked"); 58 await onTrackChange; 59 60 await waitFor( 61 () => !getRemovedDeclarations(doc).length, 62 "No declaration tracked as removed" 63 ); 64 await waitFor( 65 () => !getAddedDeclarations(doc).length, 66 "No declaration tracked as added" 67 ); 68 });