mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-19 09:30:44 +00:00
UI for prefs to control popups and other JS annoyances. Bug 75371,
patch from Doron Rosenberg <doronr@naboonline.com>, r=bzbarsky, sr=shaver, a=brendan
This commit is contained in:
parent
3e233bc9e1
commit
e153cfd6d8
@ -30,7 +30,7 @@
|
||||
<script type="application/x-javascript">
|
||||
<![CDATA[
|
||||
var panel = "chrome://communicator/content/pref/pref-advanced.xul";
|
||||
var _elementIDs = ["advancedJavaAllow", "javascriptEnabled", "advancedMailFTP", "advancedMailFTPAddress"];
|
||||
var _elementIDs = ["advancedJavaAllow", "advancedMailFTP", "advancedMailFTPAddress"];
|
||||
|
||||
function Startup() {
|
||||
ftpCheck();
|
||||
@ -134,8 +134,6 @@
|
||||
<vbox align="start" id="contentEnablingBox">
|
||||
<checkbox id="advancedJavaAllow" label="&enbJavaCheck.label;" accesskey="&enbJavaCheck.accesskey;"
|
||||
prefstring="security.enable_java"/>
|
||||
<checkbox id="javascriptEnabled" label="&enbJsCheck.label;" accesskey="&enbJsCheck.accesskey;"
|
||||
prefstring="javascript.enabled"/>
|
||||
</vbox>
|
||||
<vbox>
|
||||
<separator/>
|
||||
|
214
suite/common/pref/pref-scripts.js
Normal file
214
suite/common/pref/pref-scripts.js
Normal file
@ -0,0 +1,214 @@
|
||||
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla.org Code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Doron Rosenerg.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
const pref = Components.classes["@mozilla.org/preferences;1"].getService(Components.interfaces.nsIPref);
|
||||
|
||||
var allowWindowOpenChanged = false;
|
||||
var allowWindowMoveResizeChanged = false;
|
||||
var allowWindowFlipChanged = false;
|
||||
var allowWindowStatusChangeChanged = false;
|
||||
var allowImageSrcChangeChanged = false;
|
||||
var allowDocumentCookieSetChanged = false;
|
||||
var allowDocumentCookieGetChanged = false;
|
||||
|
||||
function setCapabilityPolicy(prefName, checkboxValue){
|
||||
|
||||
//if checked, we allow the script to do task, so we clear the pref.
|
||||
//since some options are made up of multiple capability policies and users can turn
|
||||
//individual ones on/off via prefs.js, it can happen that we clear a nonexistent pref
|
||||
if (checkboxValue){
|
||||
try {
|
||||
pref.ClearUserPref(prefName);
|
||||
} catch (e) {}
|
||||
} else {
|
||||
pref.SetCharPref(prefName, "noAccess");
|
||||
}
|
||||
}
|
||||
|
||||
function doAllowWindowOpen(){
|
||||
allowWindowOpenChanged = !allowWindowOpenChanged;
|
||||
}
|
||||
|
||||
function doWindowMoveResize(){
|
||||
allowWindowMoveResizeChanged = !allowWindowMoveResizeChanged;
|
||||
}
|
||||
|
||||
function doWindowStatusChange(){
|
||||
allowWindowStatusChangeChanged = !allowWindowStatusChangeChanged;
|
||||
}
|
||||
|
||||
function doWindowFlipChange(){
|
||||
allowWindowFlipChanged = !allowWindowFlipChanged;
|
||||
}
|
||||
|
||||
function doAllowCookieSet(){
|
||||
allowDocumentCookieSetChanged = !allowDocumentCookieSetChanged;
|
||||
}
|
||||
|
||||
function doAllowCookieGet(){
|
||||
allowDocumentCookieGetChanged = !allowDocumentCookieGetChanged;
|
||||
}
|
||||
|
||||
function doAllowImageSrcChange(){
|
||||
allowImageSrcChangeChanged = !allowImageSrcChangeChanged;
|
||||
}
|
||||
|
||||
function changeDisabledState(state){
|
||||
// set the groupbox children's state based on the "javascript enabled" checkbox value
|
||||
document.getElementById('allowScriptsDescription').disabled = state;
|
||||
document.getElementById('allowWindowMoveResize').disabled = state;
|
||||
document.getElementById('allowWindowOpen').disabled = state;
|
||||
document.getElementById('allowImageSrcChange').disabled = state;
|
||||
document.getElementById('allowDocumentCookieSet').disabled = state;
|
||||
document.getElementById('allowDocumentCookieGet').disabled = state;
|
||||
document.getElementById('allowWindowStatusChange').disabled = state;
|
||||
document.getElementById('allowWindowFlip').disabled = state;
|
||||
}
|
||||
|
||||
function javascriptEnabledChange(state){
|
||||
changeDisabledState(!state);
|
||||
}
|
||||
|
||||
function getPrefValueForCheckbox(prefName){
|
||||
|
||||
var prefValue;
|
||||
var rv = false;
|
||||
|
||||
try {
|
||||
prefValue = pref.GetCharPref(prefName);
|
||||
|
||||
if(prefValue == "allAccess" || prefValue == "sameOrigin"){
|
||||
rv = true;
|
||||
}
|
||||
}
|
||||
catch(e) { //if no pref set, check the box, as it is equivalent with "AllAccess" or "sameOrigin"
|
||||
rv = true;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
function Startup(){
|
||||
|
||||
try{
|
||||
document.getElementById('allowWindowOpen').checked = !pref.GetBoolPref("dom.disable_open_during_load");
|
||||
} catch (e){
|
||||
//if we get an error, the pref is not existent, we default to true
|
||||
document.getElementById('allowWindowOpen').checked = true;
|
||||
}
|
||||
|
||||
//if one of the security capability prefs is set, checkbox becomes unchecked
|
||||
document.getElementById("allowWindowMoveResize").checked =
|
||||
getPrefValueForCheckbox("capability.policy.default.Window.resizeTo") &&
|
||||
getPrefValueForCheckbox("capability.policy.default.Window.innerWidth.set") &&
|
||||
getPrefValueForCheckbox("capability.policy.default.Window.innerHeight.set") &&
|
||||
getPrefValueForCheckbox("capability.policy.default.Window.outerWidth.set") &&
|
||||
getPrefValueForCheckbox("capability.policy.default.Window.outerHeight.set") &&
|
||||
getPrefValueForCheckbox("capability.policy.default.Window.sizeToContent") &&
|
||||
getPrefValueForCheckbox("capability.policy.default.Window.resizeBy") &&
|
||||
getPrefValueForCheckbox("capability.policy.default.Window.screenX.set") &&
|
||||
getPrefValueForCheckbox("capability.policy.default.Window.screenY.set") &&
|
||||
getPrefValueForCheckbox("capability.policy.default.Window.moveTo") &&
|
||||
getPrefValueForCheckbox("capability.policy.default.Window.moveBy");
|
||||
|
||||
document.getElementById("allowWindowFlip").checked =
|
||||
getPrefValueForCheckbox("capability.policy.default.Window.focus");
|
||||
|
||||
document.getElementById("allowWindowStatusChange").checked =
|
||||
getPrefValueForCheckbox("capability.policy.default.Window.status");
|
||||
|
||||
document.getElementById("allowImageSrcChange").checked =
|
||||
getPrefValueForCheckbox("capability.policy.default.HTMLImageElement.src");
|
||||
|
||||
document.getElementById("allowDocumentCookieGet").checked =
|
||||
getPrefValueForCheckbox("capability.policy.default.HTMLDocument.cookie.get");
|
||||
|
||||
document.getElementById("allowDocumentCookieSet").checked =
|
||||
getPrefValueForCheckbox("capability.policy.default.HTMLDocument.cookie.set");
|
||||
|
||||
//if javascript is disabled, disable the checkboxes
|
||||
if (!document.getElementById('javascriptEnabled').checked) changeDisabledState(true);
|
||||
|
||||
parent.hPrefWindow.registerOKCallbackFunc(doOnOk);
|
||||
}
|
||||
|
||||
function doOnOk(){
|
||||
|
||||
if (allowWindowOpenChanged){
|
||||
pref.SetBoolPref("dom.disable_open_during_load", !document.getElementById("allowWindowOpen").checked);
|
||||
}
|
||||
|
||||
if (allowWindowMoveResizeChanged){
|
||||
var myValue = document.getElementById("allowWindowMoveResize").checked;
|
||||
|
||||
setCapabilityPolicy("capability.policy.default.Window.resizeTo", myValue);
|
||||
setCapabilityPolicy("capability.policy.default.Window.innerWidth.set", myValue);
|
||||
setCapabilityPolicy("capability.policy.default.Window.innerHeight.set", myValue);
|
||||
setCapabilityPolicy("capability.policy.default.Window.outerWidth.set", myValue);
|
||||
setCapabilityPolicy("capability.policy.default.Window.outerHeight.set", myValue);
|
||||
setCapabilityPolicy("capability.policy.default.Window.sizeToContent", myValue);
|
||||
setCapabilityPolicy("capability.policy.default.Window.resizeBy", myValue);
|
||||
setCapabilityPolicy("capability.policy.default.Window.screenX.set", myValue);
|
||||
setCapabilityPolicy("capability.policy.default.Window.screenY.set", myValue);
|
||||
setCapabilityPolicy("capability.policy.default.Window.moveTo", myValue);
|
||||
setCapabilityPolicy("capability.policy.default.Window.moveBy", myValue);
|
||||
}
|
||||
|
||||
if (allowWindowStatusChangeChanged){
|
||||
setCapabilityPolicy("capability.policy.default.Window.status",
|
||||
document.getElementById("allowWindowStatusChange").checked);
|
||||
}
|
||||
|
||||
if (allowWindowFlipChanged){
|
||||
setCapabilityPolicy("capability.policy.default.Window.focus",
|
||||
document.getElementById("allowWindowFlip").checked);
|
||||
}
|
||||
|
||||
if (allowDocumentCookieSetChanged){
|
||||
setCapabilityPolicy("capability.policy.default.HTMLDocument.cookie.set",
|
||||
document.getElementById("allowDocumentCookieSet").checked);
|
||||
}
|
||||
|
||||
if (allowDocumentCookieGetChanged){
|
||||
setCapabilityPolicy("capability.policy.default.HTMLDocument.cookie.get",
|
||||
document.getElementById("allowDocumentCookieGet").checked);
|
||||
}
|
||||
|
||||
if (allowImageSrcChangeChanged){
|
||||
setCapabilityPolicy("capability.policy.default.HTMLImageElement.src",
|
||||
document.getElementById("allowImageSrcChange").checked);
|
||||
}
|
||||
}
|
88
suite/common/pref/pref-scripts.xul
Normal file
88
suite/common/pref/pref-scripts.xul
Normal file
@ -0,0 +1,88 @@
|
||||
<?xml version="1.0"?><!-- -*- Mode: HTML -*- -->
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is Mozilla.org Code.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Doron Rosenberg.
|
||||
- Portions created by the Initial Developer are Copyright (C) 2001
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
- the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
- in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
- of those above. If you wish to allow use of your version of this file only
|
||||
- under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
- use your version of this file under the terms of the MPL, indicate your
|
||||
- decision by deleting the provisions above and replace them with the notice
|
||||
- and other provisions required by the LGPL or the GPL. If you do not delete
|
||||
- the provisions above, a recipient may use your version of this file under
|
||||
- the terms of any one of the MPL, the GPL or the LGPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://communicator/skin/dialogOverlay.css" type="text/css"?>
|
||||
|
||||
<!DOCTYPE window SYSTEM "chrome://communicator/locale/pref/pref-scripts.dtd" >
|
||||
<page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
onload="parent.initPanel('chrome://communicator/content/pref/pref-scripts.xul');"
|
||||
headertitle="&lHeader;">
|
||||
<script type="application/x-javascript" src="chrome://communicator/content/pref/pref-scripts.js"/>
|
||||
<script type="application/x-javascript">
|
||||
<![CDATA[
|
||||
var panel = "chrome://communicator/content/pref/pref-scripts.xul";
|
||||
var _elementIDs = ["javascriptEnabled"];
|
||||
]]>
|
||||
</script>
|
||||
|
||||
<groupbox orient="vertical" id="scriptsSettings">
|
||||
<caption>
|
||||
<checkbox id="javascriptEnabled" label="&enableJsCheck.label;" accesskey="&enableJsCheck.accesskey;"
|
||||
pref="true" preftype="bool" prefstring="javascript.enabled"
|
||||
prefattribute="checked" oncommand="javascriptEnabledChange(this.checked);"/>
|
||||
</caption>
|
||||
|
||||
<description id="allowScriptsDescription" value="&allowScriptsDescription.label;"/>
|
||||
|
||||
<tree flex="1">
|
||||
<treechildren flex="1">
|
||||
<treerow>
|
||||
<checkbox id="allowWindowOpen" label="&allowWindowOpen.label;" oncommand="doAllowWindowOpen();"/>
|
||||
</treerow>
|
||||
<treerow>
|
||||
<checkbox id="allowWindowMoveResize" label="&allowWindowMoveResize.label;" oncommand="doWindowMoveResize();"/>
|
||||
</treerow>
|
||||
<treerow>
|
||||
<checkbox id="allowWindowFlip" label="&allowWindowFlip.label;" oncommand="doWindowFlipChange();"/>
|
||||
</treerow>
|
||||
<treerow>
|
||||
<checkbox id="allowWindowStatusChange" label="&allowWindowStatusChange.label;" oncommand="doWindowStatusChange();"/>
|
||||
</treerow>
|
||||
<treerow>
|
||||
<checkbox id="allowImageSrcChange" label="&allowWindowImageSrcChange.label;" oncommand="doAllowImageSrcChange();"/>
|
||||
</treerow>
|
||||
<treerow>
|
||||
<checkbox id="allowDocumentCookieSet" label="&allowDocumentCookieSet.label;" oncommand="doAllowCookieSet();"/>
|
||||
</treerow>
|
||||
<treerow>
|
||||
<checkbox id="allowDocumentCookieGet" label="&allowDocumentCookieGet.label;" oncommand="doAllowCookieGet();"/>
|
||||
</treerow>
|
||||
</treechildren>
|
||||
</tree>
|
||||
</groupbox>
|
||||
</page>
|
@ -130,6 +130,11 @@
|
||||
<treecell class="treecell-indent" url="chrome://communicator/content/pref/pref-advanced.xul" label="&advance.label;"/>
|
||||
</treerow>
|
||||
<treechildren id="advancedChildren">
|
||||
<treeitem>
|
||||
<treerow>
|
||||
<treecell class="treecell-indent" url="chrome://communicator/content/pref/pref-scripts.xul" label="&scriptsAndWindows.label;"/>
|
||||
</treerow>
|
||||
</treeitem>
|
||||
<treeitem>
|
||||
<treerow>
|
||||
<treecell class="treecell-indent" url="chrome://communicator/content/pref/pref-cache.xul" label="&cache.label;"/>
|
||||
|
@ -10,10 +10,6 @@
|
||||
<!ENTITY enbJavaCheck.label "Enable Java">
|
||||
<!ENTITY enbJavaCheck.accesskey "j">
|
||||
|
||||
<!--LOCALIZATION NOTE (enbJsCheck.label): 'JavaScript' should never be translated -->
|
||||
<!ENTITY enbJsCheck.label "Enable JavaScript for Navigator">
|
||||
<!ENTITY enbJsCheck.accesskey "r">
|
||||
|
||||
<!ENTITY sendAddFtpCheck.label "Send this email address as anonymous FTP password:">
|
||||
<!ENTITY sendAddFtpCheck.accesskey "e">
|
||||
|
||||
|
17
suite/locales/en-US/chrome/common/pref/pref-scripts.dtd
Normal file
17
suite/locales/en-US/chrome/common/pref/pref-scripts.dtd
Normal file
@ -0,0 +1,17 @@
|
||||
<!-- extracted from content/pref-scripts.xul -->
|
||||
|
||||
<!--LOCALIZATION NOTE : FILE The 'Scripts & Windows' preferences dialog -->
|
||||
<!ENTITY lHeader "Scripts & Windows">
|
||||
|
||||
<!--LOCALIZATION NOTE (enbableJsCheck.label): 'JavaScript' should never be translated -->
|
||||
<!ENTITY enableJsCheck.label "Enable JavaScript">
|
||||
<!ENTITY enableJsCheck.accesskey "r">
|
||||
|
||||
<!ENTITY allowScriptsDescription.label "Allow scripts to do the following:">
|
||||
<!ENTITY allowWindowOpen.label "Open windows by themselves">
|
||||
<!ENTITY allowWindowMoveResize.label "Move or resize existing windows">
|
||||
<!ENTITY allowWindowFlip.label "Make windows flip over or under other windows">
|
||||
<!ENTITY allowWindowStatusChange.label "Change status bar text">
|
||||
<!ENTITY allowWindowImageSrcChange.label "Change images (image rollovers)">
|
||||
<!ENTITY allowDocumentCookieSet.label "Create or change cookies">
|
||||
<!ENTITY allowDocumentCookieGet.label "Read cookies">
|
@ -30,3 +30,4 @@
|
||||
<!ENTITY search.label "Internet Search">
|
||||
<!ENTITY policies.label "Security Policies">
|
||||
<!ENTITY mousewheel.label "Mouse Wheel">
|
||||
<!ENTITY scriptsAndWindows.label "Scripts & Windows">
|
||||
|
Loading…
x
Reference in New Issue
Block a user