browser_jsterm_history_command.js (1251B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 // Tests if the command history shows a table with the content we expected. 5 6 "use strict"; 7 8 const TEST_URI = "data:text/html;charset=UTF-8,<!DOCTYPE html>test"; 9 const COMMANDS = ["document", "window", "window.location"]; 10 11 add_task(async function () { 12 const hud = await openNewTabAndConsole(TEST_URI); 13 const { jsterm } = hud; 14 jsterm.focus(); 15 16 for (const command of COMMANDS) { 17 info(`Executing command ${command}`); 18 await executeAndWaitForResultMessage(hud, command, ""); 19 } 20 21 info(`Executing command :history`); 22 await executeAndWaitForMessageByType(hud, ":history", "", ".simpleTable"); 23 const historyTableRows = hud.ui.outputNode.querySelectorAll( 24 ".message.simpleTable tbody tr" 25 ); 26 27 const expectedCommands = [...COMMANDS, ":history"]; 28 29 for (let i = 0; i < historyTableRows.length; i++) { 30 const cells = historyTableRows[i].querySelectorAll("td"); 31 32 is( 33 cells[0].textContent, 34 String(i), 35 "Check the value of the column (index)" 36 ); 37 is( 38 cells[1].textContent, 39 expectedCommands[i], 40 "Check if the value of the column Expressions is the value expected" 41 ); 42 } 43 });