browser_changes_copy_all_changes.js (1547B)
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 Changes panel Copy All Changes button will populate the 7 // clipboard with a summary of just the changed declarations. 8 9 const TEST_URI = ` 10 <style type='text/css'> 11 div { 12 color: red; 13 margin: 0; 14 } 15 </style> 16 <div></div> 17 `; 18 19 // Indentation is important. A strict check will be done against the clipboard content. 20 const EXPECTED_CLIPBOARD = ` 21 /* Inline | data:text/html;charset=utf-8,${TEST_URI} */ 22 23 div { 24 /* color: red; */ 25 color: green; 26 } 27 `; 28 29 add_task(async function () { 30 await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); 31 const { inspector, view: ruleView } = await openRuleView(); 32 const changesView = selectChangesView(inspector); 33 const { document: panelDoc, store } = changesView; 34 35 await selectNode("div", inspector); 36 const onTrackChange = waitForDispatch(store, "TRACK_CHANGE"); 37 await updateDeclaration(ruleView, 1, { color: "red" }, { color: "green" }); 38 await onTrackChange; 39 40 info( 41 "Check that clicking the Copy All Changes button copies all changes to the clipboard." 42 ); 43 const button = panelDoc.querySelector(".changes__copy-all-changes-button"); 44 await waitForClipboardPromise( 45 () => button.click(), 46 () => checkClipboardData(EXPECTED_CLIPBOARD) 47 ); 48 }); 49 50 function checkClipboardData(expected) { 51 const actual = SpecialPowers.getClipboardData("text/plain"); 52 return decodeURIComponent(actual).trim() === expected.trim(); 53 }