browser_console_content_longstring.js (1578B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 // Test that very long content strings can be expanded and collapsed in the 5 // Browser Console, and do not hang the browser. 6 7 "use strict"; 8 9 const TEST_URI = 10 "data:text/html,<!DOCTYPE html><meta charset=utf8>Test LongString hang"; 11 12 const LONGSTRING = `foobar${"a".repeat( 13 9000 14 )}foobaz${"abbababazomglolztest".repeat(100)}boom!`; 15 16 add_task(async function () { 17 // Show the content messages 18 await pushPref("devtools.browsertoolbox.scope", "everything"); 19 20 await addTab(TEST_URI); 21 22 info("Open the Browser Console"); 23 const hud = await BrowserConsoleManager.toggleBrowserConsole(); 24 25 info("Log a longString"); 26 const onMessage = waitForMessageByType( 27 hud, 28 LONGSTRING.slice(0, 50), 29 ".console-api" 30 ); 31 SpecialPowers.spawn(gBrowser.selectedBrowser, [LONGSTRING], str => { 32 content.console.log(str); 33 }); 34 35 const { node } = await onMessage; 36 const arrow = node.querySelector(".theme-twisty"); 37 ok(arrow, "longString expand arrow is shown"); 38 39 info("wait for long string expansion"); 40 const onLongStringFullTextDisplayed = waitFor(() => 41 findConsoleAPIMessage(hud, LONGSTRING) 42 ); 43 arrow.click(); 44 await onLongStringFullTextDisplayed; 45 46 ok(true, "The full text of the longString is displayed"); 47 48 info("wait for long string collapse"); 49 const onLongStringCollapsed = waitFor( 50 () => !findConsoleAPIMessage(hud, LONGSTRING) 51 ); 52 arrow.click(); 53 await onLongStringCollapsed; 54 55 ok(true, "The longString can be collapsed"); 56 });