browser_target_cached-resource.js (1596B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 // The target front holds resources that happend before ResourceCommand addeed listeners. 7 // Test whether that feature works correctly or not. 8 const TEST_URI = 9 "https://example.com/browser/devtools/client/framework/test/doc_cached-resource.html"; 10 const PARENT_MESSAGE = "Hello from parent"; 11 const CHILD_MESSAGE = "Hello from child"; 12 13 Services.scriptloader.loadSubScript( 14 "chrome://mochitests/content/browser/devtools/client/webconsole/test/browser/shared-head.js", 15 this 16 ); 17 18 add_task(async function () { 19 info("Open console"); 20 const tab = await addTab(TEST_URI); 21 const toolbox = await openToolboxForTab(tab, "webconsole"); 22 const hud = toolbox.getCurrentPanel().hud; 23 24 info("Check the initial messages"); 25 ok( 26 findMessageByType(hud, PARENT_MESSAGE, ".console-api"), 27 "Message from parent document is in console" 28 ); 29 ok( 30 findMessageByType(hud, CHILD_MESSAGE, ".console-api"), 31 "Message from child document is in console" 32 ); 33 34 info("Clear the messages"); 35 hud.ui.window.document.querySelector(".devtools-clear-icon").click(); 36 await waitUntil( 37 () => !findMessageByType(hud, PARENT_MESSAGE, ".console-api") 38 ); 39 40 info("Reload the browsing page"); 41 await navigateTo(TEST_URI); 42 43 info("Check the messages after reloading"); 44 await waitUntil( 45 () => 46 findMessageByType(hud, PARENT_MESSAGE, ".console-api") && 47 findMessageByType(hud, CHILD_MESSAGE, ".console-api") 48 ); 49 ok(true, "All messages are shown correctly"); 50 });