Bug 1473933: Remove xpinstallConfirm dialog. r=aswan

Differential Revision: https://phabricator.services.mozilla.com/D6854

--HG--
extra : rebase_source : 15a43212697a02ef7aa35eccc4b3c09bd195d7ed
This commit is contained in:
Kris Maglione 2018-09-25 15:33:52 -07:00
Родитель ced19a86b0
Коммит b9ad1e41b7
17 изменённых файлов: 14 добавлений и 513 удалений

Просмотреть файл

@ -9,6 +9,7 @@ support-files =
[test_bug246699.html]
[test_bug292789.html]
skip-if = os == 'android'
[test_bug423375.html]
[test_bug470804.html]
[test_bug1367586.html]

Просмотреть файл

@ -13,7 +13,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=292789
<p id="display"></p>
<div id="content" style="display: none">
<script src="chrome://global/content/treeUtils.js"></script>
<script type="application/javascript" src="chrome://mozapps/content/xpinstall/xpinstallConfirm.js"></script>
<script type="application/javascript" src="chrome://mozapps/content/extensions/eula.js"></script>
<script id="resjs" type="application/javascript"></script>
</div>
<pre id="test">
@ -29,11 +29,15 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=292789
SimpleTest.waitForExplicitFinish();
let ChromeUtils = {
import() {},
};
/** <script src=""> test **/
function testScriptSrc(aCallback) {
is(typeof gTreeUtils.sort, "function",
"content can still load <script> from chrome://global");
is(typeof XPInstallConfirm, "undefined",
is(typeof Startup, "undefined",
"content should not be able to load <script> from chrome://mozapps");
/** make sure the last one didn't pass because someone
@ -41,12 +45,12 @@ function testScriptSrc(aCallback) {
**/
var resjs = document.getElementById("resjs");
resjs.onload = scriptOnload;
resjs.src = "resource://gre/chrome/toolkit/content/mozapps/xpinstall/xpinstallConfirm.js";
resjs.src = "resource://gre/chrome/toolkit/content/mozapps/extensions/eula.js";
document.getElementById("content").appendChild(resjs);
function scriptOnload() {
is(typeof XPInstallConfirm, "object",
"xpinstallConfirm.js has not moved unexpectedly");
is(typeof Startup, "function",
"extensions.js has not moved unexpectedly");
// trigger the callback
if (aCallback)

Просмотреть файл

@ -1,13 +0,0 @@
<!-- 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/. -->
<!-- extracted from institems.xul -->
<!ENTITY dialog.title "Software Installation">
<!ENTITY dialog.style "width: 45em">
<!ENTITY warningPrimary.label "Install add-ons only from authors whom you trust.">
<!ENTITY warningSecondary.label "Malicious software can damage your computer or violate your privacy.">
<!ENTITY from.label "from:">

Просмотреть файл

@ -1,8 +0,0 @@
# 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/.
itemWarnIntroMultiple=You have asked to install the following %S items:
itemWarnIntroSingle=You have asked to install the following item:
installButtonDisabledLabel=Install (%S)
installButtonLabel=Install Now

Просмотреть файл

@ -102,8 +102,6 @@
locale/@AB_CD@/mozapps/update/updates.properties (%chrome/mozapps/update/updates.properties)
#endif
locale/@AB_CD@/mozapps/update/history.dtd (%chrome/mozapps/update/history.dtd)
locale/@AB_CD@/mozapps/xpinstall/xpinstallConfirm.dtd (%chrome/mozapps/extensions/xpinstallConfirm.dtd)
locale/@AB_CD@/mozapps/xpinstall/xpinstallConfirm.properties (%chrome/mozapps/extensions/xpinstallConfirm.properties)
% locale pluginproblem @AB_CD@ %locale/@AB_CD@/pluginproblem/
locale/@AB_CD@/pluginproblem/pluginproblem.dtd (%chrome/pluginproblem/pluginproblem.dtd)
% locale alerts @AB_CD@ %locale/@AB_CD@/alerts/

Просмотреть файл

@ -33,6 +33,7 @@ const PREF_SYS_ADDON_UPDATE_ENABLED = "extensions.systemAddon.update.enabled";
const PREF_MIN_WEBEXT_PLATFORM_VERSION = "extensions.webExtensionsMinPlatformVersion";
const PREF_WEBAPI_TESTING = "extensions.webapi.testing";
const PREF_WEBEXT_PERM_PROMPTS = "extensions.webextPermissionPrompts";
const PREF_XPINSTALL_DIALOG = "extensions.xpinstall.confirm.dialog";
const UPDATE_REQUEST_VERSION = 2;
@ -59,8 +60,6 @@ const WEBAPI_TEST_INSTALL_HOSTS = [
"example.com",
];
const URI_XPINSTALL_DIALOG = "chrome://mozapps/content/xpinstall/xpinstallConfirm.xul";
ChromeUtils.import("resource://gre/modules/Services.jsm");
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
ChromeUtils.import("resource://gre/modules/AsyncShutdown.jsm");
@ -2604,7 +2603,8 @@ var AddonManagerInternal = {
reject = () => {
cancelled = true;
};
Services.ww.openWindow(parentWindow, URI_XPINSTALL_DIALOG,
Services.ww.openWindow(parentWindow,
Services.prefs.getStringPref(PREF_XPINSTALL_DIALOG),
null, "chrome,modal,centerscreen", args);
if (cancelled) {
reallyReject();

Просмотреть файл

@ -1,8 +0,0 @@
/* 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/. */
installitem {
-moz-binding: url("chrome://mozapps/content/xpinstall/xpinstallItem.xml#installitem");
display: -moz-box;
}

Просмотреть файл

@ -1,180 +0,0 @@
// -*- 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 XPInstallConfirm = {};
XPInstallConfirm.init = function() {
ChromeUtils.import("resource://gre/modules/AddonManager.jsm");
ChromeUtils.import("resource://gre/modules/Services.jsm");
var _installCountdown;
var _installCountdownInterval;
var _focused;
var _timeout;
// Default to cancelling the install when the window unloads
XPInstallConfirm._installOK = false;
var bundle = document.getElementById("xpinstallConfirmStrings");
let args = window.arguments[0].wrappedJSObject;
// If all installs have already been cancelled in some way then just close
// the window
if (args.installs.every(i => i.state != AddonManager.STATE_DOWNLOADED)) {
window.close();
return;
}
var _installCountdownLength = 5;
try {
var delay_in_milliseconds = Services.prefs.getIntPref("security.dialog_enable_delay");
_installCountdownLength = Math.round(delay_in_milliseconds / 500);
} catch (ex) { }
var itemList = document.getElementById("itemList");
let installMap = new WeakMap();
let installListener = {
onDownloadCancelled(install) {
itemList.removeChild(installMap.get(install));
if (--numItemsToInstall == 0)
window.close();
},
};
var numItemsToInstall = args.installs.length;
for (let install of args.installs) {
var installItem = document.createElement("installitem");
itemList.appendChild(installItem);
installItem.name = install.addon.name;
installItem.url = install.sourceURI.spec;
var icon = install.iconURL;
if (icon)
installItem.icon = icon;
var type = install.type;
if (type)
installItem.type = type;
installMap.set(install.wrapped, installItem);
install.addListener(installListener);
}
var introString = bundle.getString("itemWarnIntroSingle");
if (numItemsToInstall > 4)
introString = bundle.getFormattedString("itemWarnIntroMultiple", [numItemsToInstall]);
var textNode = document.createTextNode(introString);
var introNode = document.getElementById("itemWarningIntro");
while (introNode.hasChildNodes())
introNode.firstChild.remove();
introNode.appendChild(textNode);
var okButton = document.documentElement.getButton("accept");
okButton.focus();
function okButtonCountdown() {
_installCountdown -= 1;
if (_installCountdown < 1) {
okButton.label = bundle.getString("installButtonLabel");
okButton.disabled = false;
clearInterval(_installCountdownInterval);
} else
okButton.label = bundle.getFormattedString("installButtonDisabledLabel", [_installCountdown]);
}
function myfocus() {
// Clear the timeout if it exists so only the last one will be used.
if (_timeout)
clearTimeout(_timeout);
// Use setTimeout since the last focus or blur event to fire is the one we
// want
_timeout = setTimeout(setWidgetsAfterFocus, 0);
}
function setWidgetsAfterFocus() {
if (_focused)
return;
_installCountdown = _installCountdownLength;
_installCountdownInterval = setInterval(okButtonCountdown, 500);
okButton.label = bundle.getFormattedString("installButtonDisabledLabel", [_installCountdown]);
_focused = true;
}
function myblur() {
// Clear the timeout if it exists so only the last one will be used.
if (_timeout)
clearTimeout(_timeout);
// Use setTimeout since the last focus or blur event to fire is the one we
// want
_timeout = setTimeout(setWidgetsAfterBlur, 0);
}
function setWidgetsAfterBlur() {
if (!_focused)
return;
// Set _installCountdown to the inital value set in setWidgetsAfterFocus
// plus 1 so when the window is focused there is immediate ui feedback.
_installCountdown = _installCountdownLength + 1;
okButton.label = bundle.getFormattedString("installButtonDisabledLabel", [_installCountdown]);
okButton.disabled = true;
clearInterval(_installCountdownInterval);
_focused = false;
}
function myUnload() {
if (_installCountdownLength > 0) {
document.removeEventListener("focus", myfocus, true);
document.removeEventListener("blur", myblur, true);
}
window.removeEventListener("unload", myUnload);
for (let install of args.installs)
install.removeListener(installListener);
// Now perform the desired action - either install the
// addons or cancel the installations
if (XPInstallConfirm._installOK) {
for (let install of args.installs)
install.install();
} else {
for (let install of args.installs) {
if (install.state != AddonManager.STATE_CANCELLED)
install.cancel();
}
}
}
window.addEventListener("unload", myUnload);
if (_installCountdownLength > 0) {
document.addEventListener("focus", myfocus, true);
document.addEventListener("blur", myblur, true);
okButton.disabled = true;
setWidgetsAfterFocus();
} else
okButton.label = bundle.getString("installButtonLabel");
};
XPInstallConfirm.onOK = function() {
Services.telemetry.getHistogramById("SECURITY_UI")
.add(Ci.nsISecurityUITelemetry.WARNING_CONFIRM_ADDON_INSTALL_CLICK_THROUGH);
// Perform the install or cancel after the window has unloaded
XPInstallConfirm._installOK = true;
return true;
};
XPInstallConfirm.onCancel = function() {
// Perform the install or cancel after the window has unloaded
XPInstallConfirm._installOK = false;
return true;
};

Просмотреть файл

@ -1,37 +0,0 @@
<?xml version="1.0"?>
<!-- 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/. -->
<?xml-stylesheet href="chrome://mozapps/content/xpinstall/xpinstallConfirm.css" type="text/css"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://mozapps/skin/xpinstall/xpinstallConfirm.css" type="text/css"?>
<!DOCTYPE dialog SYSTEM "chrome://mozapps/locale/xpinstall/xpinstallConfirm.dtd">
<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
id="xpinstallConfirm" title="&dialog.title;" style="&dialog.style;"
windowtype="Addons:Install"
onload="XPInstallConfirm.init()"
ondialogaccept="return XPInstallConfirm.onOK();"
ondialogcancel="return XPInstallConfirm.onCancel();">
<script src="chrome://mozapps/content/xpinstall/xpinstallConfirm.js" type="application/javascript"/>
<stringbundle id="xpinstallConfirmStrings"
src="chrome://mozapps/locale/xpinstall/xpinstallConfirm.properties"/>
<vbox flex="1" id="dialogContentBox">
<hbox id="xpinstallheader" align="start">
<image class="alert-icon"/>
<vbox flex="1">
<description class="warning">&warningPrimary.label;</description>
<description>&warningSecondary.label;</description>
</vbox>
</hbox>
<label id="itemWarningIntro"/>
<vbox id="itemList" class="listbox" flex="1" style="overflow: auto;"/>
</vbox>
</dialog>

Просмотреть файл

@ -1,50 +0,0 @@
<?xml version="1.0"?>
<!-- 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/. -->
<!DOCTYPE bindings SYSTEM "chrome://mozapps/locale/xpinstall/xpinstallConfirm.dtd">
<bindings id="xpinstallItemBindings"
xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:xbl="http://www.mozilla.org/xbl">
<binding id="installitem">
<resources>
<stylesheet src="chrome://mozapps/skin/xpinstall/xpinstallConfirm.css"/>
</resources>
<content>
<xul:hbox flex="1">
<xul:vbox align="center" pack="center" class="xpinstallIconContainer">
<xul:image class="xpinstallItemIcon" xbl:inherits="src=icon"/>
</xul:vbox>
<xul:vbox flex="1" pack="center">
<xul:hbox class="xpinstallItemNameRow" align="center">
<xul:label class="xpinstallItemName" xbl:inherits="value=name" crop="right"/>
</xul:hbox>
<xul:hbox class="xpinstallItemDetailsRow" align="center">
<xul:textbox class="xpinstallItemURL" xbl:inherits="value=url" flex="1" readonly="true" crop="right"/>
</xul:hbox>
</xul:vbox>
</xul:hbox>
</content>
<implementation>
<property name="name" onset="this.setAttribute('name', val); return val;"
onget="return this.getAttribute('name');"/>
<property name="cert" onset="this.setAttribute('cert', val); return val;"
onget="return this.getAttribute('cert');"/>
<property name="signed" onset="this.setAttribute('signed', val); return val;"
onget="return this.getAttribute('signed');"/>
<property name="url" onset="this.setAttribute('url', val); return val;"
onget="return this.getAttribute('url');"/>
<property name="icon" onset="this.setAttribute('icon', val); return val;"
onget="return this.getAttribute('icon');"/>
<property name="type" onset="this.setAttribute('type', val); return val;"
onget="return this.getAttribute('type');"/>
</implementation>
</binding>
</bindings>

Просмотреть файл

@ -21,7 +21,3 @@ toolkit.jar:
content/mozapps/extensions/pluginPrefs.js (content/pluginPrefs.js)
content/mozapps/extensions/OpenH264-license.txt (content/OpenH264-license.txt)
#endif
content/mozapps/xpinstall/xpinstallConfirm.xul (content/xpinstallConfirm.xul)
content/mozapps/xpinstall/xpinstallConfirm.js (content/xpinstallConfirm.js)
content/mozapps/xpinstall/xpinstallConfirm.css (content/xpinstallConfirm.css)
content/mozapps/xpinstall/xpinstallItem.xml (content/xpinstallItem.xml)

Просмотреть файл

@ -34,7 +34,6 @@ const PREF_CUSTOM_XPINSTALL_CONFIRMATION_UI = "xpinstall.customConfirmationUI";
const PREF_UI_LASTCATEGORY = "extensions.ui.lastCategory";
const MANAGER_URI = "about:addons";
const INSTALL_URI = "chrome://mozapps/content/xpinstall/xpinstallConfirm.xul";
const PREF_LOGGING_ENABLED = "extensions.logging.enabled";
const PREF_STRICT_COMPAT = "extensions.strictCompatibility";

Просмотреть файл

@ -4,7 +4,6 @@ const RELATIVE_DIR = "toolkit/mozapps/extensions/test/xpinstall/";
const TESTROOT = "http://example.com/browser/" + RELATIVE_DIR;
const TESTROOT2 = "http://example.org/browser/" + RELATIVE_DIR;
const XPINSTALL_URL = "chrome://mozapps/content/xpinstall/xpinstallConfirm.xul";
const PROMPT_URL = "chrome://global/content/commonDialog.xul";
const ADDONS_URL = "chrome://mozapps/content/extensions/extensions.xul";
const PREF_LOGGING_ENABLED = "extensions.logging.enabled";
@ -187,29 +186,7 @@ var Harness = {
// Window open handling
windowReady(window) {
if (window.document.location.href == XPINSTALL_URL) {
if (this.installBlockedCallback)
ok(false, "Should have been blocked by the whitelist");
this.pendingCount = window.document.getElementById("itemList").childNodes.length;
// If there is a confirm callback then its return status determines whether
// to install the items or not. If not the test is over.
let result = true;
if (this.installConfirmCallback) {
result = this.installConfirmCallback(window);
if (result === this.leaveOpen)
return;
}
if (!result) {
window.document.documentElement.cancelDialog();
} else {
// Initially the accept button is disabled on a countdown timer
var button = window.document.documentElement.getButton("accept");
button.disabled = false;
window.document.documentElement.acceptDialog();
}
} else if (window.document.location.href == PROMPT_URL) {
if (window.document.location.href == PROMPT_URL) {
var promptType = window.args.promptType;
switch (promptType) {
case "alert":

Просмотреть файл

@ -1,85 +0,0 @@
/* 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/. */
#xpinstallheader {
margin-bottom: 2em;
}
.alert-icon {
width: 48px;
height: 48px;
list-style-image: url("chrome://global/skin/icons/warning-large.png");
margin-top: 0 !important;
margin-bottom: 6px !important;
margin-inline-start: 6px !important;
margin-inline-end: 20px !important;
}
#itemList {
-moz-appearance: listbox;
margin: 3px 4px 10px 4px;
height: 14em;
}
#itemWarningIntro {
margin-inline-start: 8px;
}
#dialogContentBox {
padding: 5px;
}
installitem {
padding: 5px 0 5px 5px;
border-bottom: 1px dotted #C0C0C0;
margin-bottom: 5px;
}
.warning {
font-weight: bold;
font-size: 1.25em;
margin-bottom: 1em;
}
.xpinstallIconContainer {
width: 32px;
height: 32px;
margin-inline-end: 5px;
}
.xpinstallItemName {
font-weight: bold;
}
.xpinstallItemURL {
-moz-appearance: none;
border: none;
background-color: Window;
margin-top: 2px;
margin-bottom: 1px;
margin-inline-start: 6px;
margin-inline-end: 5px;
}
.xpinstallItemIcon {
max-width: 32px;
max-height: 32px;
list-style-image: url("chrome://mozapps/skin/extensions/extensionGeneric.svg");
}
installitem[type="theme"] .xpinstallItemIcon {
list-style-image: url("chrome://mozapps/skin/extensions/themeGeneric.svg");
}
installitem[type="locale"] .xpinstallItemIcon {
list-style-image: url("chrome://mozapps/skin/extensions/localeGeneric.svg");
}
installitem[type="plugin"] .xpinstallItemIcon {
list-style-image: url("chrome://mozapps/skin/plugins/pluginGeneric.svg");
}
installitem[type="dictionary"] .xpinstallItemIcon {
list-style-image: url("chrome://mozapps/skin/extensions/dictionaryGeneric.svg");
}

Просмотреть файл

@ -19,5 +19,4 @@ toolkit.jar:
skin/classic/mozapps/profile/profileSelection.css (profile/profileSelection.css)
skin/classic/mozapps/update/buttons.png (update/buttons.png)
* skin/classic/mozapps/update/updates.css (update/updates.css)
skin/classic/mozapps/xpinstall/xpinstallConfirm.css (extensions/xpinstallConfirm.css)
skin/classic/mozapps/handling/handling.css (handling/handling.css)

Просмотреть файл

@ -44,6 +44,5 @@
skin/classic/mozapps/plugins/pluginHelp-16.png (../../windows/mozapps/plugins/pluginHelp-16.png)
skin/classic/mozapps/profile/profileSelection.css (../../windows/mozapps/profile/profileSelection.css)
skin/classic/mozapps/update/downloadButtons.png (../../windows/mozapps/update/downloadButtons.png)
* skin/classic/mozapps/xpinstall/xpinstallConfirm.css (../../windows/mozapps/extensions/xpinstallConfirm.css)
% override chrome://mozapps/skin/xpinstall/xpinstallItemGeneric.png chrome://mozapps/skin/extensions/extensionGeneric.svg

Просмотреть файл

@ -1,91 +0,0 @@
/* 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/. */
#xpinstallheader {
margin-bottom: 2em;
}
#itemList {
-moz-appearance: listbox;
margin: 3px 4px 10px;
height: 14em;
background-color: -moz-Field;
color: -moz-FieldText;
}
#itemWarningIntro {
margin-inline-start: 8px;
}
#dialogContentBox {
padding: 5px;
}
installitem {
padding-top: 5px;
padding-bottom: 5px;
padding-inline-start: 5px;
padding-inline-end: 0;
border-bottom: 1px dotted ThreeDShadow;
margin-bottom: 5px;
}
.alert-icon {
%ifdef XP_WIN
list-style-image: url("chrome://global/skin/icons/warning-large.png");
width: 48px;
height: 48px;
%endif
margin-inline-end: 20px;
}
.warning {
font-weight: bold;
font-size: 1.25em;
margin-bottom: 1em;
}
.xpinstallIconContainer {
width: 32px;
height: 32px;
margin-inline-end: 5px;
}
.xpinstallItemName {
font-weight: bold;
}
.xpinstallItemURL {
-moz-appearance: none;
border: none;
padding: 0;
background-color: -moz-Field;
color: -moz-FieldText;
margin-top: 1px;
margin-bottom: 1px;
margin-inline-start: 6px;
margin-inline-end: 5px;
}
.xpinstallItemIcon {
max-width: 32px;
max-height: 32px;
list-style-image: url("chrome://mozapps/skin/extensions/extensionGeneric.svg");
}
installitem[type="theme"] .xpinstallItemIcon {
list-style-image: url("chrome://mozapps/skin/extensions/themeGeneric.svg");
}
installitem[type="locale"] .xpinstallItemIcon {
list-style-image: url("chrome://mozapps/skin/extensions/localeGeneric.svg");
}
installitem[type="plugin"] .xpinstallItemIcon {
list-style-image: url("chrome://mozapps/skin/plugins/pluginGeneric.svg");
}
installitem[type="dictionary"] .xpinstallItemIcon {
list-style-image: url("chrome://mozapps/skin/extensions/dictionaryGeneric.svg");
}