browser_webconsole_highlighter_console_helper.js (1881B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 // Tests that the $0 console helper works as intended. See Bug 653531. 5 6 "use strict"; 7 8 const TEST_URI = `data:text/html;charset=utf-8,<!DOCTYPE html> 9 <head> 10 <title>Inspector Tree Selection Test</title> 11 </head> 12 <body> 13 <div> 14 <h1>Inspector Tree Selection Test</h1> 15 <p>This is some example text</p> 16 <p>${loremIpsum()}</p> 17 </div> 18 <div> 19 <p>${loremIpsum()}</p> 20 </div> 21 </body>`.replace("\n", ""); 22 23 add_task(async function () { 24 const toolbox = await openNewTabAndToolbox(TEST_URI, "inspector"); 25 await selectNodeWithPicker(toolbox, "h1"); 26 27 info("Picker mode stopped, <h1> selected, now switching to the console"); 28 const hud = await openConsole(); 29 30 await clearOutput(hud); 31 32 await executeAndWaitForResultMessage(hud, "$0", "<h1>"); 33 ok(true, "correct output for $0"); 34 35 await clearOutput(hud); 36 37 const newH1Content = "newH1Content"; 38 await executeAndWaitForResultMessage( 39 hud, 40 `$0.textContent = "${newH1Content}";$0`, 41 "<h1>" 42 ); 43 44 ok(true, "correct output for $0 after setting $0.textContent"); 45 const textContent = await SpecialPowers.spawn( 46 gBrowser.selectedBrowser, 47 [], 48 () => content.document.querySelector("h1").textContent 49 ); 50 is(textContent, newH1Content, "node successfully updated"); 51 }); 52 53 function loremIpsum() { 54 return `Lorem ipsum dolor sit amet, consectetur adipisicing 55 elit, sed do eiusmod tempor incididunt ut labore et dolore magna 56 aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco 57 laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure 58 dolor in reprehenderit in voluptate velit esse cillum dolore eu 59 fugiat nulla pariatur. Excepteur sint occaecat cupidatat non 60 proident, sunt in culpa qui officia deserunt mollit anim id est laborum.`.replace( 61 "\n", 62 "" 63 ); 64 }