browser_jsterm_syntax_highlight_output.js (1146B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 const TEST_URI = 7 "data:text/html;charset=utf-8,<!DOCTYPE html>Test syntax highlighted output"; 8 9 add_task(async function () { 10 const hud = await openNewTabAndConsole(TEST_URI); 11 12 // Syntax highlighting is implemented with a Custom Element: 13 ok( 14 hud.iframeWindow.customElements.get("syntax-highlighted"), 15 "Custom Element exists" 16 ); 17 18 // Check that we syntax highlight output to look like the inputed text. 19 // See Bug 1463669. 20 const onMessage = waitForMessageByType(hud, `var a = 'str';`, ".command"); 21 execute(hud, "var a = 'str';"); 22 const message = await onMessage; 23 const highlighted = message.node.querySelectorAll("syntax-highlighted"); 24 const expectedMarkup = `<syntax-highlighted class="cm-s-mozilla"><span class="cm-keyword">var</span> <span class="cm-def">a</span> <span class="cm-operator">=</span> <span class="cm-string">'str'</span>;</syntax-highlighted>`; 25 is(highlighted.length, 1, "1 syntax highlighted tag"); 26 is(highlighted[0].outerHTML, expectedMarkup, "got expected html"); 27 });