browser_changes_declaration_identical_rules.js (2058B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 // Test tracking changes to CSS declarations in different stylesheets but in rules 7 // with identical selectors. 8 9 const TEST_URI = ` 10 <style type='text/css'> 11 div { 12 color: red; 13 } 14 </style> 15 <style type='text/css'> 16 div { 17 font-size: 1em; 18 } 19 </style> 20 <div></div> 21 `; 22 23 add_task(async function () { 24 await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); 25 const { inspector, view: ruleView } = await openRuleView(); 26 const { document: doc, store } = selectChangesView(inspector); 27 28 await selectNode("div", inspector); 29 const prop1 = getTextProperty(ruleView, 1, { "font-size": "1em" }); 30 const prop2 = getTextProperty(ruleView, 2, { color: "red" }); 31 32 let onTrackChange; 33 34 onTrackChange = waitForDispatch(store, "TRACK_CHANGE"); 35 info("Disable the declaration in the first rule"); 36 await togglePropStatus(ruleView, prop1); 37 info("Wait for change to be tracked"); 38 await onTrackChange; 39 40 onTrackChange = waitForDispatch(store, "TRACK_CHANGE"); 41 info("Disable the declaration in the second rule"); 42 await togglePropStatus(ruleView, prop2); 43 info("Wait for change to be tracked"); 44 await onTrackChange; 45 46 const removeDecl = getRemovedDeclarations(doc); 47 is(removeDecl.length, 2, "Two declarations tracked as removed"); 48 // The last of the two matching rules shows up first in Rule view given that the 49 // specificity is the same. This is correct. If the properties were the same, the latest 50 // declaration would overwrite the first and thus show up on top. 51 is( 52 removeDecl[0].property, 53 "font-size", 54 "Correct property name for second declaration" 55 ); 56 is( 57 removeDecl[0].value, 58 "1em", 59 "Correct property value for second declaration" 60 ); 61 is( 62 removeDecl[1].property, 63 "color", 64 "Correct property name for first declaration" 65 ); 66 is( 67 removeDecl[1].value, 68 "red", 69 "Correct property value for first declaration" 70 ); 71 });