add javascript on-off menuitem in tools

This commit is contained in:
Raphael Guay 2020-09-25 20:39:43 -04:00 committed by Cameron Kaiser
parent f8a60dfea9
commit 191db31e60
6 changed files with 49 additions and 1 deletions

View File

@ -482,7 +482,8 @@
<menu id="tools-menu"
label="&toolsMenu.label;"
accesskey="&toolsMenu.accesskey;"
onpopupshowing="mirrorShow(this)">
onpopupshowing="mirrorShow(this);
jsToggle.updateMenu();">
<menupopup id="menu_ToolsPopup"
# We have to use setTimeout() here to avoid a flickering menu bar when opening
# the Tools menu, see bug 970769. This can be removed once we got rid of the
@ -516,6 +517,12 @@
accesskey="&syncReAuthItem.accesskey;"
observes="sync-reauth-state"
oncommand="gSyncUI.openSignInAgainPage('menubar');"/>
<menuseparator/>
<menuitem id="toggle_javascript"
label="&JavascriptToggleCmd.label;"
type="checkbox"
command="cmd_toggleJavascript"
checked="true"/>
<menuseparator id="devToolsSeparator"/>
<menu id="webDeveloperMenu"
label="&webDeveloperMenu.label;"

View File

@ -86,6 +86,7 @@
<command id="cmd_fullZoomEnlarge" oncommand="FullZoom.enlarge()"/>
<command id="cmd_fullZoomReset" oncommand="FullZoom.reset()"/>
<command id="cmd_fullZoomToggle" oncommand="ZoomManager.toggleZoom();"/>
<command id="cmd_toggleJavascript" oncommand="jsToggle.toggle();"/>
<command id="cmd_gestureRotateLeft" oncommand="gGestureSupport.rotate(event.sourceEvent)"/>
<command id="cmd_gestureRotateRight" oncommand="gGestureSupport.rotate(event.sourceEvent)"/>
<command id="cmd_gestureRotateEnd" oncommand="gGestureSupport.rotateEnd()"/>

View File

@ -5,6 +5,7 @@
<script type="application/javascript" src="chrome://global/content/printUtils.js"/>
<script type="application/javascript" src="chrome://global/content/viewZoomOverlay.js"/>
<script type="application/javascript" src="chrome://global/content/jsToggle.js"/>
<script type="application/javascript" src="chrome://browser/content/places/browserPlacesViews.js"/>
<script type="application/javascript" src="chrome://browser/content/browser.js"/>
<script type="application/javascript" src="chrome://browser/content/downloads/downloads.js"/>

View File

@ -255,6 +255,8 @@ These should match what Safari and other Apple applications use on OS X Lion. --
<!ENTITY loopMenuItem.label "Start a conversation…">
<!ENTITY loopMenuItem.accesskey "t">
<!ENTITY JavascriptToggleCmd.label "Enable JavaScript">
<!ENTITY webDeveloperMenu.label "Web Developer">
<!ENTITY webDeveloperMenu.accesskey "W">

View File

@ -61,6 +61,7 @@ toolkit.jar:
content/global/select-child.js
content/global/TopLevelVideoDocument.js
content/global/treeUtils.js
content/global/jsToggle.js
content/global/viewZoomOverlay.js
content/global/sluggo.xhtml
content/global/sluggo.jpg

View File

@ -0,0 +1,36 @@
// -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var jsToggle = {
get _prefBranch() {
delete this._prefBranch;
return this._prefBranch = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
},
get executeJs() {
return this._prefBranch.getBoolPref("javascript.enabled");
},
set executeJs(aVal) {
this._prefBranch.setBoolPref("javascript.enabled", aVal);
return aVal;
},
updateMenu: function jsToggle_updateMenu() {
var menuItem = document.getElementById("toggle_javascript");
menuItem.setAttribute("checked", this.executeJs);
},
toggle: function jsToggle_toggle() {
this.executeJs = !this.executeJs;
}
};