tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

browser_jsterm_editor.js (1544B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 // Check that the editor is displayed as expected.
      5 
      6 "use strict";
      7 
      8 const TEST_URI = "data:text/html;charset=utf8,<!DOCTYPE html><p>Test editor";
      9 
     10 add_task(async function () {
     11  await pushPref("devtools.webconsole.input.editor", false);
     12 
     13  const tab = await addTab(TEST_URI);
     14  let hud = await openConsole(tab);
     15 
     16  info("Test that the editor mode is disabled when the pref is set to false");
     17  is(
     18    isEditorModeEnabled(hud),
     19    false,
     20    "Editor is disabled when pref is set to false"
     21  );
     22  const openEditorButton = getInlineOpenEditorButton(hud);
     23  ok(openEditorButton, "button is rendered in the inline input");
     24  const rect = openEditorButton.getBoundingClientRect();
     25  ok(rect.width > 0 && rect.height > 0, "Button is visible");
     26 
     27  await closeConsole();
     28 
     29  info(
     30    "Test that wrapper does have the jsterm-editor class when editor is enabled"
     31  );
     32  await pushPref("devtools.webconsole.input.editor", true);
     33  hud = await openConsole(tab);
     34  is(
     35    isEditorModeEnabled(hud),
     36    true,
     37    "Editor is enabled when pref is set to true"
     38  );
     39  is(getInlineOpenEditorButton(hud), null, "Button is hidden in editor mode");
     40 
     41  await toggleLayout(hud);
     42  getInlineOpenEditorButton(hud).click();
     43  await waitFor(() => isEditorModeEnabled(hud));
     44  ok(true, "Editor is open when clicking on the button");
     45 });
     46 
     47 function getInlineOpenEditorButton(hud) {
     48  return hud.ui.outputNode.querySelector(".webconsole-input-openEditorButton");
     49 }