tor-browser

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

browser_dbg-settings-disable-javascript.js (1525B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
      4 
      5 "use strict";
      6 
      7 requestLongerTimeout(2);
      8 
      9 // Tests that using the Settings menu to enable and disable JavaScript
     10 // updates the pref properly
     11 add_task(async function () {
     12  const dbg = await initDebugger("doc-scripts.html", "simple1.js");
     13  const menuItemClassName = ".debugger-settings-menu-item-disable-javascript";
     14 
     15  info("Waiting for source to load");
     16  await waitForSource(dbg, "simple1.js");
     17 
     18  const waitForDevToolsReload = await watchForDevToolsReload(
     19    gBrowser.selectedBrowser
     20  );
     21  info("Clicking the disable javascript button in the settings menu");
     22  await toggleDebuggerSettingsMenuItem(dbg, {
     23    className: menuItemClassName,
     24    isChecked: false,
     25  });
     26 
     27  info("Waiting for reload triggered by disabling javascript");
     28  await waitForSourcesInSourceTree(dbg, [], { noExpand: true });
     29 
     30  info("Wait for DevTools to be reloaded");
     31  await waitForDevToolsReload();
     32 
     33  info(
     34    "Clicking the disable javascript button in the settings menu to reenable JavaScript"
     35  );
     36  await toggleDebuggerSettingsMenuItem(dbg, {
     37    className: menuItemClassName,
     38    isChecked: true,
     39  });
     40  is(
     41    Services.prefs.getBoolPref("javascript.enabled"),
     42    true,
     43    "JavaScript is enabled"
     44  );
     45 
     46  info("Reloading page to ensure there are sources");
     47  await reload(dbg);
     48  await waitForSource(dbg, "simple1.js");
     49 });