tor-browser

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

browser_jsterm_editor_onboarding.js (1775B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 // Test that the onboarding UI is displayed when first displaying the editor mode, and
      5 // that it can be permanentely dismissed.
      6 // See https://bugzilla.mozilla.org/show_bug.cgi?id=1558417
      7 
      8 "use strict";
      9 
     10 const TEST_URI =
     11  "data:text/html;charset=utf-8,<!DOCTYPE html>Test onboarding UI";
     12 const EDITOR_UI_PREF = "devtools.webconsole.input.editor";
     13 const EDITOR_ONBOARDING_PREF = "devtools.webconsole.input.editorOnboarding";
     14 
     15 add_task(async function () {
     16  // Enable editor mode and force the onboarding pref to true so it's displayed.
     17  await pushPref(EDITOR_UI_PREF, true);
     18  await pushPref(EDITOR_ONBOARDING_PREF, true);
     19 
     20  let hud = await openNewTabAndConsole(TEST_URI);
     21 
     22  info("Check that the onboarding UI is displayed");
     23  const onboardingElement = getOnboardingEl(hud);
     24  ok(onboardingElement, "The onboarding UI exists");
     25 
     26  info("Check that the onboarding UI can be dismissed");
     27  const dismissButton = onboardingElement.querySelector(
     28    ".editor-onboarding-dismiss-button"
     29  );
     30  ok(dismissButton, "There's a dismiss button");
     31  dismissButton.click();
     32 
     33  await waitFor(() => !getOnboardingEl(hud));
     34  ok(true, "The onboarding UI is hidden after clicking the dismiss button");
     35 
     36  info("Check that the onboarding UI isn't displayed after a toolbox restart");
     37  await closeConsole();
     38  hud = await openConsole();
     39  is(
     40    getOnboardingEl(hud),
     41    null,
     42    "The onboarding UI isn't displayed after a toolbox restart after being dismissed"
     43  );
     44 
     45  Services.prefs.clearUserPref(EDITOR_UI_PREF);
     46  Services.prefs.clearUserPref(EDITOR_ONBOARDING_PREF);
     47 });
     48 
     49 function getOnboardingEl(hud) {
     50  return hud.ui.outputNode.querySelector(".editor-onboarding");
     51 }