Merge mozilla-central to autoland. a=merge CLOSED TREE

This commit is contained in:
Csoregi Natalia 2018-03-26 12:21:54 +03:00
Родитель bac452f9ad 57ac1bed31
Коммит 3ca75efbb5
63 изменённых файлов: 154 добавлений и 1569 удалений

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

@ -78,15 +78,7 @@ support-files =
!/image/test/mochitest/blue.png
!/toolkit/content/tests/browser/common/mockTransfer.js
!/toolkit/modules/tests/browser/metadata_*.html
!/toolkit/mozapps/extensions/test/xpinstall/amosigned.xpi
!/toolkit/mozapps/extensions/test/xpinstall/corrupt.xpi
!/toolkit/mozapps/extensions/test/xpinstall/incompatible.xpi
!/toolkit/mozapps/extensions/test/xpinstall/installtrigger.html
!/toolkit/mozapps/extensions/test/xpinstall/redirect.sjs
!/toolkit/mozapps/extensions/test/xpinstall/restartless-unsigned.xpi
!/toolkit/mozapps/extensions/test/xpinstall/restartless.xpi
!/toolkit/mozapps/extensions/test/xpinstall/theme.xpi
!/toolkit/mozapps/extensions/test/xpinstall/slowinstall.sjs
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_addKeywordSearch.js]
@ -181,8 +173,6 @@ skip-if = true # bug 1393813
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug550565.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug553455.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug555224.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug555767.js]

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

@ -31,6 +31,7 @@ async function createXULExtension(details) {
id: details.id,
name: details.name,
version: "0.1",
bootstrap: true,
targetApplications: [{
id: "toolkit@mozilla.org",
minVersion: "0",

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

@ -52,6 +52,8 @@ config = {
'vcs_share_base': '/builds/hg-shared',
'objdir': 'obj-firefox',
'multi_locale': True,
'find_links': ['http://pypi.pub.build.mozilla.org/pub'],
'pip_index': False,
#########################################################################

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

@ -1,4 +1,6 @@
config = {
'objdir': 'obj-firefox',
'app_name': 'browser',
'find_links': ['http://pypi.pub.build.mozilla.org/pub'],
'pip_index': False,
}

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

@ -1,2 +0,0 @@
1
test2

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

@ -1,24 +0,0 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>ab-CD@dictionaries.addons.mozilla.org</em:id>
<em:version>2.0</em:version>
<em:unpack>true</em:unpack>
<!-- Front End MetaData -->
<em:name>Test Dictionary</em:name>
<em:description>Test Description</em:description>
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>1</em:maxVersion>
</Description>
</em:targetApplication>
</Description>
</RDF>

Двоичный файл не отображается.

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

@ -1,32 +0,0 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>install1@tests.mozilla.org</em:id>
<em:version>1.0</em:version>
<em:bootstrap>true</em:bootstrap>
<em:updateURL>http://example.com/browser/toolkit/mozapps/extensions/test/browser/browser_install.rdf</em:updateURL>
<em:targetApplication>
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>0.3</em:minVersion>
<em:maxVersion>*</em:maxVersion>
</Description>
</em:targetApplication>
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>*</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Front End MetaData -->
<em:name>Install Tests</em:name>
</Description>
</RDF>

Двоичный файл не отображается.

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

@ -1,30 +0,0 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>install1@tests.mozilla.org</em:id>
<em:version>2.0</em:version>
<em:targetApplication>
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>0.3</em:minVersion>
<em:maxVersion>*</em:maxVersion>
</Description>
</em:targetApplication>
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>*</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Front End MetaData -->
<em:name>Install Tests</em:name>
</Description>
</RDF>

Двоичный файл не отображается.

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

@ -1,30 +0,0 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>sslinstall@tests.mozilla.org</em:id>
<em:version>1.0</em:version>
<em:targetApplication>
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>0.3</em:minVersion>
<em:maxVersion>*</em:maxVersion>
</Description>
</em:targetApplication>
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>*</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Front End MetaData -->
<em:name>SSL Install Tests</em:name>
</Description>
</RDF>

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

@ -0,0 +1,12 @@
{
"manifest_version": 2,
"applications": {
"gecko": {
"id": "sslinstall-1@tests.mozilla.org"
}
},
"name": "SSL Install Tests",
"version": "1.0"
}

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

@ -17,9 +17,6 @@ support-files =
blockPluginHard.xml
browser_updatessl.json
browser_updatessl.json^headers^
browser_install.rdf
browser_install.rdf^headers^
browser_install1_3.xpi
webapi_addon_listener.html
webapi_checkavailable.html
webapi_checkchromeframe.xul
@ -32,6 +29,7 @@ support-files =
!/toolkit/mozapps/extensions/test/xpinstall/theme.xpi
!/toolkit/mozapps/extensions/test/xpinstall/unsigned.xpi
!/toolkit/mozapps/extensions/test/xpinstall/amosigned.xpi
!/toolkit/mozapps/extensions/test/xpinstall/amosigned-restart-required.xpi
[browser_CTP_plugins.js]
tags = blocklist
@ -78,7 +76,6 @@ skip-if = buildapp == 'mulet'
[browser_gmpProvider.js]
skip-if = os == 'linux' && !debug # Bug 1398766
[browser_inlinesettings_browser.js]
[browser_install.js]
[browser_installssl.js]
[browser_langpack_signing.js]
[browser_legacy.js]

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

@ -1,247 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// Tests tha installs and undoing installs show up correctly
var gManagerWindow;
var gCategoryUtilities;
var gApp = document.getElementById("bundle_brand").getString("brandShortName");
function test() {
requestLongerTimeout(2);
waitForExplicitFinish();
// Allow http update checks
Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false);
open_manager(null, function(aWindow) {
gManagerWindow = aWindow;
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
run_next_test();
});
}
function end_test() {
close_manager(gManagerWindow, function() {
Services.prefs.clearUserPref("extensions.checkUpdateSecurity");
AddonManager.getAddonByID("install1@tests.mozilla.org", function(aAddon) {
aAddon.uninstall();
finish();
});
});
}
function get_node(parent, anonid) {
return parent.ownerDocument.getAnonymousElementByAttribute(parent, "anonid", anonid);
}
function installAddon(aCallback) {
AddonManager.getInstallForURL(TESTROOT + "addons/browser_install1_2.xpi",
function(aInstall) {
aInstall.addListener({
onInstallEnded() {
executeSoon(aCallback);
}
});
aInstall.install();
}, "application/x-xpinstall");
}
function installUpgrade(aCallback) {
AddonManager.getAddonByID("install1@tests.mozilla.org", function(aAddon) {
aAddon.findUpdates({
onUpdateAvailable(aAddon, aInstall) {
is(get_list_item_count(), 1, "Should be only one item in the list");
aInstall.addListener({
onDownloadEnded() {
is(get_list_item_count(), 1, "Should be only one item in the list once the update has started");
},
onInstallEnded() {
executeSoon(aCallback);
}
});
aInstall.install();
}
}, AddonManager.UPDATE_WHEN_USER_REQUESTED);
});
}
function cancelInstall(aCallback) {
AddonManager.getInstallForURL(TESTROOT + "addons/browser_install1_2.xpi",
function(aInstall) {
aInstall.addListener({
onDownloadEnded(aInstall) {
executeSoon(function() {
aInstall.cancel();
aCallback();
});
return false;
}
});
aInstall.install();
}, "application/x-xpinstall");
}
function get_list_item_count() {
return get_test_items_in_list(gManagerWindow).length;
}
function check_undo_install() {
is(get_list_item_count(), 1, "Should be only one item in the list");
let item = get_addon_element(gManagerWindow, "install1@tests.mozilla.org");
ok(!!item, "Should see the pending install in the list");
// Force XBL to apply
item.clientTop;
is_element_visible(get_node(item, "pending"), "Pending message should be visible");
is(get_node(item, "pending").textContent, "Install Tests will be installed after you restart " + gApp + ".", "Pending message should be correct");
EventUtils.synthesizeMouseAtCenter(get_node(item, "undo-btn"), {}, gManagerWindow);
is(get_list_item_count(), 0, "Should be no items in the list");
item = get_addon_element(gManagerWindow, "install1@tests.mozilla.org");
ok(!item, "Should no longer see the pending install");
}
function check_undo_upgrade() {
is(get_list_item_count(), 1, "Should be only one item in the list");
let item = get_addon_element(gManagerWindow, "install1@tests.mozilla.org");
ok(!!item, "Should see the pending upgrade in the list");
// Force XBL to apply
item.clientTop;
is_element_visible(get_node(item, "pending"), "Pending message should be visible");
is(get_node(item, "pending").textContent, "Install Tests will be updated after you restart " + gApp + ".", "Pending message should be correct");
EventUtils.synthesizeMouseAtCenter(get_node(item, "undo-btn"), {}, gManagerWindow);
is(get_list_item_count(), 1, "Should be only one item in the list");
item = get_addon_element(gManagerWindow, "install1@tests.mozilla.org");
ok(!!item, "Should still see installed item in the list");
is_element_hidden(get_node(item, "pending"), "Pending message should be hidden");
}
// Install an add-on through the API with the manager open
add_test(function() {
gCategoryUtilities.openType("extension", function() {
installAddon(function() {
check_undo_install();
run_next_test();
});
});
});
// Install an add-on with the manager closed then open it
add_test(function() {
close_manager(gManagerWindow, function() {
installAddon(function() {
open_manager(null, function(aWindow) {
gManagerWindow = aWindow;
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
check_undo_install();
run_next_test();
});
});
});
});
// Cancel an install after download with the manager open
add_test(function() {
cancelInstall(function() {
is(get_list_item_count(), 0, "Should be no items in the list");
run_next_test();
});
});
// Cancel an install after download with the manager closed
add_test(function() {
close_manager(gManagerWindow, function() {
cancelInstall(function() {
open_manager(null, function(aWindow) {
gManagerWindow = aWindow;
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
is(get_list_item_count(), 0, "Should be no items in the list");
run_next_test();
});
});
});
});
// Install an existing add-on for the subsequent tests
add_test(function() {
AddonManager.getInstallForURL(TESTROOT + "addons/browser_install1_1.xpi",
function(aInstall) {
aInstall.addListener({
onInstallEnded: run_next_test
});
aInstall.install();
}, "application/x-xpinstall");
});
// Install an upgrade through the API with the manager open
add_test(function() {
installAddon(function() {
check_undo_upgrade();
run_next_test();
});
});
// Install an upgrade through the API with the manager open
add_test(function() {
installUpgrade(function() {
check_undo_upgrade();
run_next_test();
});
});
// Install an upgrade through the API with the manager closed
add_test(function() {
close_manager(gManagerWindow, function() {
installAddon(function() {
open_manager(null, function(aWindow) {
gManagerWindow = aWindow;
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
check_undo_upgrade();
run_next_test();
});
});
});
});
// Cancel an upgrade after download with the manager open
add_test(function() {
cancelInstall(function() {
is(get_list_item_count(), 1, "Should be no items in the list");
let item = get_addon_element(gManagerWindow, "install1@tests.mozilla.org");
ok(!!item, "Should still see installed item in the list");
is_element_hidden(get_node(item, "pending"), "Pending message should be hidden");
run_next_test();
});
});
// Cancel an upgrade after download with the manager closed
add_test(function() {
close_manager(gManagerWindow, function() {
cancelInstall(function() {
open_manager(null, function(aWindow) {
gManagerWindow = aWindow;
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
is(get_list_item_count(), 1, "Should be no items in the list");
let item = get_addon_element(gManagerWindow, "install1@tests.mozilla.org");
ok(!!item, "Should still see installed item in the list");
is_element_hidden(get_node(item, "pending"), "Pending message should be hidden");
run_next_test();
});
});
});
});

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

@ -1,19 +0,0 @@
{
"addons": {
"install1@tests.mozilla.org": {
"updates": [
{
"applications": {
"gecko": {
"strict_min_version": "0",
"advisory_max_version": "*"
}
},
"version": "2.0",
"update_link": "https://example.com/browser/toolkit/mozapps/extensions/test/browser/browser_install1_3.xpi",
"update_hash": "sha1:4f0f4391914e3e036beca50cbac33958e5269643"
}
]
}
}
}

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

@ -1 +0,0 @@
Connection: close

Двоичный файл не отображается.

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

@ -6,7 +6,7 @@
function install() {
InstallTrigger.install({
"Test Add-on": {
URL: "https://example.com/browser/toolkit/mozapps/extensions/test/xpinstall/amosigned.xpi"
URL: "https://example.com/browser/toolkit/mozapps/extensions/test/xpinstall/amosigned-restart-required.xpi"
}
});
}
@ -14,7 +14,7 @@ function install() {
</head>
<body>
<h1>Test page for the discovery pane</h1>
<p><a id="install-direct" href="https://example.com/browser/toolkit/mozapps/extensions/test/xpinstall/amosigned.xpi">Direct install</a></p>
<p><a id="install-direct" href="https://example.com/browser/toolkit/mozapps/extensions/test/xpinstall/amosigned-restart-required.xpi">Direct install</a></p>
<p><a id="install-js" href="javascript:install()">JS install</a></p>
</body>
</html>

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

@ -584,175 +584,13 @@ function check_test_23() {
restartManager();
AddonManager.getAddonByID("ab-CD@dictionaries.addons.mozilla.org", function(b1_2) {
b1_2.uninstall();
executeSoon(run_test_25);
executeSoon(run_test_29);
});
}));
});
});
}
// Tests that updating from a bootstrappable add-on to a normal add-on calls
// the uninstall method
function run_test_25() {
restartManager();
HunspellEngine.listener = function(aEvent) {
HunspellEngine.listener = null;
Assert.equal(aEvent, "addDirectory");
Assert.ok(HunspellEngine.isDictionaryEnabled("ab-CD.dic"));
installAllFiles([do_get_addon("test_dictionary_2")], function test_25_installed2() {
// Needs a restart to complete this so the old version stays running
Assert.ok(HunspellEngine.isDictionaryEnabled("ab-CD.dic"));
AddonManager.getAddonByID("ab-CD@dictionaries.addons.mozilla.org",
callback_soon(function(b1) {
Assert.notEqual(b1, null);
Assert.equal(b1.version, "1.0");
Assert.ok(b1.isActive);
Assert.ok(hasFlag(b1.pendingOperations, AddonManager.PENDING_UPGRADE));
restartManager();
Assert.ok(!HunspellEngine.isDictionaryEnabled("ab-CD.dic"));
AddonManager.getAddonByID("ab-CD@dictionaries.addons.mozilla.org", function(b1_2) {
Assert.notEqual(b1_2, null);
Assert.equal(b1_2.version, "2.0");
Assert.ok(b1_2.isActive);
Assert.equal(b1_2.pendingOperations, AddonManager.PENDING_NONE);
executeSoon(run_test_26);
});
}));
});
};
installAllFiles([do_get_addon("test_dictionary")], function test_25_installed() { });
}
// Tests that updating from a normal add-on to a bootstrappable add-on calls
// the install method
function run_test_26() {
installAllFiles([do_get_addon("test_dictionary")], function test_26_install() {
// Needs a restart to complete this
Assert.ok(!HunspellEngine.isDictionaryEnabled("ab-CD.dic"));
AddonManager.getAddonByID("ab-CD@dictionaries.addons.mozilla.org",
callback_soon(function(b1) {
Assert.notEqual(b1, null);
Assert.equal(b1.version, "2.0");
Assert.ok(b1.isActive);
Assert.ok(hasFlag(b1.pendingOperations, AddonManager.PENDING_UPGRADE));
restartManager();
Assert.ok(HunspellEngine.isDictionaryEnabled("ab-CD.dic"));
AddonManager.getAddonByID("ab-CD@dictionaries.addons.mozilla.org", function(b1_2) {
Assert.notEqual(b1_2, null);
Assert.equal(b1_2.version, "1.0");
Assert.ok(b1_2.isActive);
Assert.equal(b1_2.pendingOperations, AddonManager.PENDING_NONE);
HunspellEngine.deactivate();
b1_2.uninstall();
executeSoon(run_test_27);
});
}));
});
}
// Tests that an update check from a normal add-on to a bootstrappable add-on works
function run_test_27() {
restartManager();
writeInstallRDFForExtension({
id: "ab-CD@dictionaries.addons.mozilla.org",
version: "1.0",
updateURL: "http://localhost:" + gPort + "/data/test_dictionary.json",
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "1",
maxVersion: "1"
}],
name: "Test Dictionary",
}, profileDir);
restartManager();
prepare_test({
"ab-CD@dictionaries.addons.mozilla.org": [
"onInstalling"
]
}, [
"onNewInstall",
"onDownloadStarted",
"onDownloadEnded",
"onInstallStarted",
"onInstallEnded"
], callback_soon(check_test_27));
AddonManagerPrivate.backgroundUpdateCheck();
}
function check_test_27(install) {
Assert.equal(install.existingAddon.pendingUpgrade.install, install);
restartManager();
AddonManager.getAddonByID("ab-CD@dictionaries.addons.mozilla.org", function(b1) {
Assert.notEqual(b1, null);
Assert.equal(b1.version, "2.0");
Assert.equal(b1.type, "dictionary");
b1.uninstall();
executeSoon(run_test_28);
});
}
// Tests that an update check from a bootstrappable add-on to a normal add-on works
function run_test_28() {
restartManager();
writeInstallRDFForExtension({
id: "ef@dictionaries.addons.mozilla.org",
version: "1.0",
type: "64",
updateURL: "http://localhost:" + gPort + "/data/test_dictionary.json",
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "1",
maxVersion: "1"
}],
name: "Test Dictionary ef",
}, profileDir);
restartManager();
prepare_test({
"ef@dictionaries.addons.mozilla.org": [
"onInstalling"
]
}, [
"onNewInstall",
"onDownloadStarted",
"onDownloadEnded",
"onInstallStarted",
"onInstallEnded"
], callback_soon(check_test_28));
AddonManagerPrivate.backgroundUpdateCheck();
}
function check_test_28(install) {
Assert.equal(install.existingAddon.pendingUpgrade.install, install);
restartManager();
AddonManager.getAddonByID("ef@dictionaries.addons.mozilla.org", function(b2) {
Assert.notEqual(b2, null);
Assert.equal(b2.version, "2.0");
Assert.equal(b2.type, "extension");
b2.uninstall();
executeSoon(run_test_29);
});
}
// Tests that an update check from a bootstrappable add-on to a bootstrappable add-on works
function run_test_29() {
restartManager();

Двоичный файл не отображается.

Двоичный файл не отображается.

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

@ -1,11 +1,11 @@
[DEFAULT]
support-files =
amosigned.xpi
amosigned-restart-required.xpi
authRedirect.sjs
bug540558.html
bug638292.html
bug645699.html
concurrent_installs.html
cookieRedirect.sjs
corrupt.xpi
empty.xpi
@ -22,8 +22,6 @@ support-files =
restartless-unsigned.xpi
signed-no-cn.xpi
signed-no-o.xpi
signed-tampered.xpi
signed-untrusted.xpi
signed.xpi
slowinstall.sjs
startsoftwareupdate.html
@ -48,7 +46,6 @@ support-files =
[browser_bug645699.js]
[browser_bug672485.js]
skip-if = true # disabled due to a leak. See bug 682410.
[browser_concurrent_installs.js]
[browser_cookies.js]
[browser_cookies2.js]
[browser_cookies3.js]
@ -56,6 +53,7 @@ skip-if = true # disabled due to a leak. See bug 682410.
skip-if = true # Bug 1084646
[browser_corrupt.js]
[browser_datauri.js]
[browser_doorhanger_installs.js]
[browser_empty.js]
[browser_enabled.js]
[browser_enabled2.js]
@ -68,28 +66,15 @@ skip-if = true # Bug 1084646
[browser_httphash4.js]
[browser_httphash5.js]
[browser_httphash6.js]
skip-if = (os == 'win' || os == 'mac') && (verify || !debug)
[browser_installchrome.js]
[browser_localfile.js]
[browser_localfile2.js]
[browser_localfile3.js]
[browser_localfile4.js]
[browser_navigateaway.js]
[browser_navigateaway2.js]
[browser_navigateaway3.js]
skip-if = (os == "mac" || os == "win") # Bug 1198261
[browser_navigateaway4.js]
[browser_offline.js]
[browser_relative.js]
[browser_signed_tampered.js]
skip-if = require_signing
[browser_signed_trigger.js]
skip-if = require_signing
[browser_signed_untrusted.js]
skip-if = require_signing
[browser_signed_url.js]
skip-if = require_signing
[browser_softwareupdate.js]
[browser_switchtab.js]
[browser_trigger_redirect.js]
[browser_unsigned_trigger.js]
skip-if = require_signing
@ -98,10 +83,3 @@ skip-if = require_signing
[browser_unsigned_trigger_xorigin.js]
[browser_unsigned_url.js]
skip-if = require_signing
[browser_whitelist.js]
[browser_whitelist2.js]
[browser_whitelist3.js]
[browser_whitelist4.js]
[browser_whitelist5.js]
[browser_whitelist6.js]
[browser_whitelist7.js]

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

@ -22,12 +22,8 @@ function test() {
gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
}
function confirm_install(window) {
var items = window.document.getElementById("itemList").childNodes;
is(items.length, 1, "Should only be 1 item listed in the confirmation dialog");
is(items[0].name, "XPI Test", "Should have seen the name");
is(items[0].url, TESTROOT + "amosigned.xpi", "Should have listed the correct url for the item");
is(items[0].icon, TESTROOT + "icon.png", "Should have listed the correct icon for the item");
function confirm_install(panel) {
is(panel.getAttribute("name"), "XPI Test", "Should have seen the name");
return true;
}

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

@ -23,12 +23,8 @@ function test() {
gBrowser.loadURI(TESTROOT + "installtrigger_frame.html?" + inner_url);
}
function confirm_install(window) {
var items = window.document.getElementById("itemList").childNodes;
is(items.length, 1, "Should only be 1 item listed in the confirmation dialog");
is(items[0].name, "XPI Test", "Should have seen the name");
is(items[0].url, TESTROOT + "amosigned.xpi", "Should have listed the correct url for the item");
is(items[0].icon, TESTROOT + "icon.png", "Should have listed the correct icon for the item");
function confirm_install(panel) {
is(panel.getAttribute("name"), "XPI Test", "Should have seen the name");
return true;
}

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

@ -12,12 +12,8 @@ function test() {
});
}
function confirm_install(window) {
let items = window.document.getElementById("itemList").childNodes;
is(items.length, 1, "Should only be 1 item listed in the confirmation dialog");
is(items[0].name, "XPI Test", "Should have had the filename for the item name");
is(items[0].url, TESTROOT + "amosigned.xpi", "Should have listed the correct url for the item");
is(items[0].icon, "", "Should have listed no icon for the item");
function confirm_install(panel) {
is(panel.getAttribute("name"), "XPI Test", "Should have seen the name");
return true;
}

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

@ -21,7 +21,7 @@ function allow_blocked(installInfo) {
return false;
}
function confirm_install(window) {
function confirm_install(panel) {
ok(false, "Should not see the install dialog");
return false;
}

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

@ -25,7 +25,7 @@ function test() {
gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
}
function confirm_install(window) {
function confirm_install(panel) {
ok(false, "Should not see the install dialog");
return false;
}

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

@ -1,123 +0,0 @@
// Test that having two frames that request installs at the same time doesn't
// cause callback ID conflicts (discussed in bug 926712)
var gConcurrentTabs = [];
var gQueuedForInstall = [];
var gResults = [];
function frame_script() {
/* globals addMessageListener, sendAsyncMessage*/
addMessageListener("Test:StartInstall", () => {
content.document.getElementById("installnow").click();
});
addEventListener("load", () => {
sendAsyncMessage("Test:Loaded");
content.addEventListener("InstallComplete", (e) => {
sendAsyncMessage("Test:InstallComplete", e.detail);
}, true);
}, true);
}
var gAddonAndWindowListener = {
onOpenWindow(win) {
var window = win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindow);
info("Window opened");
waitForFocus(function() {
info("Focused!");
// Initially the accept button is disabled on a countdown timer
let button = window.document.documentElement.getButton("accept");
button.disabled = false;
if (gQueuedForInstall.length > 0) {
// Start downloading the next add-on while we accept this dialog:
installNext();
}
window.document.documentElement.acceptDialog();
}, window);
},
onCloseWindow(win) { },
onInstallEnded(install) {
install.cancel();
},
QueryInterface: XPCOMUtils.generateQI([Ci.nsIWindowMediatorListener])
};
function installNext() {
let tab = gQueuedForInstall.shift();
tab.linkedBrowser.messageManager.sendAsyncMessage("Test:StartInstall");
}
function createTab(url) {
let tab = BrowserTestUtils.addTab(gBrowser, url);
tab.linkedBrowser.messageManager.loadFrameScript("data:,(" + frame_script.toString() + ")();", true);
tab.linkedBrowser.messageManager.addMessageListener("Test:InstallComplete", ({data}) => {
gResults.push(data);
if (gResults.length == 2) {
executeSoon(endThisTest);
}
});
return tab;
}
function test() {
waitForExplicitFinish();
Services.prefs.setBoolPref(PREF_LOGGING_ENABLED, true);
Services.prefs.setBoolPref(PREF_INSTALL_REQUIRESECUREORIGIN, false);
Services.wm.addListener(gAddonAndWindowListener);
AddonManager.addInstallListener(gAddonAndWindowListener);
registerCleanupFunction(function() {
Services.wm.removeListener(gAddonAndWindowListener);
AddonManager.removeInstallListener(gAddonAndWindowListener);
Services.prefs.clearUserPref(PREF_LOGGING_ENABLED);
Services.prefs.clearUserPref(PREF_INSTALL_REQUIRESECUREORIGIN);
Services.perms.remove(makeURI("http://example.com"), "install");
Services.perms.remove(makeURI("http://example.org"), "install");
while (gConcurrentTabs.length) {
gBrowser.removeTab(gConcurrentTabs.shift());
}
});
let pm = Services.perms;
pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
pm.add(makeURI("http://example.org/"), "install", pm.ALLOW_ACTION);
gConcurrentTabs.push(createTab(TESTROOT + "concurrent_installs.html"));
gConcurrentTabs.push(createTab(TESTROOT2 + "concurrent_installs.html"));
let promises = gConcurrentTabs.map((t) => {
return new Promise(resolve => {
t.linkedBrowser.messageManager.addMessageListener("Test:Loaded", resolve);
});
});
Promise.all(promises).then(() => {
gQueuedForInstall = [...gConcurrentTabs];
installNext();
});
}
function endThisTest() {
is(gResults.length, 2, "Should have two urls");
isnot(gResults[0].loc, gResults[1].loc, "Should not have results from the same page.");
isnot(gResults[0].xpi, gResults[1].xpi, "Should not have the same XPIs.");
for (let i = 0; i < 2; i++) {
let {loc, xpi} = gResults[i];
if (loc.includes("example.org")) {
ok(xpi.includes("example.org"), "Should get .org XPI for .org loc");
} else if (loc.includes("example.com")) {
ok(xpi.includes("example.com"), "Should get .com XPI for .com loc");
} else {
ok(false, "Should never get anything that isn't from example.org or example.com");
}
}
finish();
}

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

@ -2,28 +2,20 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
const TESTROOT = "http://example.com/browser/toolkit/mozapps/extensions/test/xpinstall/";
const TESTROOT2 = "http://example.org/browser/toolkit/mozapps/extensions/test/xpinstall/";
const SECUREROOT = "https://example.com/browser/toolkit/mozapps/extensions/test/xpinstall/";
const XPINSTALL_URL = "chrome://mozapps/content/xpinstall/xpinstallConfirm.xul";
const PREF_INSTALL_REQUIREBUILTINCERTS = "extensions.install.requireBuiltInCerts";
const PROGRESS_NOTIFICATION = "addon-progress";
ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
var rootDir = getRootDirectory(gTestPath);
var rootPath = rootDir.split("/");
var chromeName = rootPath[0] + "//" + rootPath[2];
var croot = chromeName + "/content/browser/toolkit/mozapps/extensions/test/xpinstall/";
var jar = getJar(croot);
if (jar) {
var tmpdir = extractJarToTmp(jar);
croot = "file://" + tmpdir.path + "/";
}
const CHROMEROOT = croot;
const CHROMEROOT = extractChromeRoot(gTestPath);
var gApp = document.getElementById("bundle_brand").getString("brandShortName");
var gVersion = Services.appinfo.version;
add_task(async function setup() {
await SpecialPowers.pushPrefEnv({
set: [[PREF_CUSTOM_CONFIRMATION_UI, true]],
});
});
function waitForTick() {
return new Promise(resolve => executeSoon(resolve));
@ -42,7 +34,7 @@ function getObserverTopic(aNotificationId) {
return topic;
}
async function waitForProgressNotification(aPanelOpen = false, aExpectedCount = 1) {
async function waitForProgressNotification(aPanelOpen = false, aExpectedCount = 1, wantDisabled = true) {
let notificationId = PROGRESS_NOTIFICATION;
info("Waiting for " + notificationId + " notification");
@ -82,8 +74,8 @@ async function waitForProgressNotification(aPanelOpen = false, aExpectedCount =
let nodes = Array.from(PopupNotifications.panel.childNodes);
let notification = nodes.find(n => n.id == notificationId + "-notification");
ok(notification, `Should have seen the right notification`);
ok(notification.button.hasAttribute("disabled"),
"The install button should be disabled");
is(notification.button.hasAttribute("disabled"), wantDisabled,
"The install button should be disabled?");
}
return PopupNotifications.panel;
@ -94,17 +86,20 @@ async function waitForNotification(aId, aExpectedCount = 1) {
let topic = getObserverTopic(aId);
let observerPromise = new Promise(resolve => {
Services.obs.addObserver(function observer(aSubject, aTopic, aData) {
// Ignore the progress notification unless that is the notification we want
if (aId != PROGRESS_NOTIFICATION &&
aTopic == getObserverTopic(PROGRESS_NOTIFICATION)) {
return;
}
Services.obs.removeObserver(observer, topic);
resolve();
}, topic);
});
let observerPromise;
if (aId !== "addon-webext-permissions") {
observerPromise = new Promise(resolve => {
Services.obs.addObserver(function observer(aSubject, aTopic, aData) {
// Ignore the progress notification unless that is the notification we want
if (aId != PROGRESS_NOTIFICATION &&
aTopic == getObserverTopic(PROGRESS_NOTIFICATION)) {
return;
}
Services.obs.removeObserver(observer, topic);
resolve();
}, topic);
});
}
let panelEventPromise = new Promise(resolve => {
PopupNotifications.panel.addEventListener("PanelUpdated", function eventListener(e) {
@ -142,41 +137,9 @@ function waitForNotificationClose() {
});
}
async function waitForInstallDialog() {
if (Services.prefs.getBoolPref("xpinstall.customConfirmationUI", false)) {
let panel = await waitForNotification("addon-install-confirmation");
return panel.childNodes[0];
}
info("Waiting for install dialog");
let window = await new Promise(resolve => {
Services.wm.addListener({
onOpenWindow(aXULWindow) {
Services.wm.removeListener(this);
resolve(aXULWindow);
},
onCloseWindow(aXULWindow) {
},
});
});
info("Install dialog opened, waiting for focus");
let domwindow = window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindow);
await new Promise(resolve => {
waitForFocus(function() {
resolve();
}, domwindow);
});
info("Saw install dialog");
is(domwindow.document.location.href, XPINSTALL_URL, "Should have seen the right window open");
// Override the countdown timer on the accept button
let button = domwindow.document.documentElement.getButton("accept");
button.disabled = false;
return null;
async function waitForInstallDialog(id = "addon-webext-permissions") {
let panel = await waitForNotification(id);
return panel.childNodes[0];
}
function removeTabAndWaitForNotificationClose() {
@ -186,21 +149,11 @@ function removeTabAndWaitForNotificationClose() {
}
function acceptInstallDialog(installDialog) {
if (Services.prefs.getBoolPref("xpinstall.customConfirmationUI", false)) {
installDialog.button.click();
} else {
let win = Services.wm.getMostRecentWindow("Addons:Install");
win.document.documentElement.acceptDialog();
}
installDialog.button.click();
}
function cancelInstallDialog(installDialog) {
if (Services.prefs.getBoolPref("xpinstall.customConfirmationUI", false)) {
installDialog.secondaryButton.click();
} else {
let win = Services.wm.getMostRecentWindow("Addons:Install");
win.document.documentElement.cancelDialog();
}
installDialog.secondaryButton.click();
}
async function waitForSingleNotification(aCallback) {
@ -285,22 +238,20 @@ async function test_blockedInstall() {
ok(PopupNotifications.isPanelOpen, "Notification should still be open");
notification = panel.childNodes[0];
is(notification.id, "addon-progress-notification", "Should have seen the progress notification");
let installDialog = await dialogPromise;
notificationPromise = waitForNotification("addon-install-restart");
acceptInstallDialog(installDialog);
notificationPromise = waitForNotification("addon-installed");
installDialog.button.click();
panel = await notificationPromise;
notification = panel.childNodes[0];
is(notification.button.label, "Restart Now", "Should have seen the right button");
is(notification.getAttribute("label"),
"XPI Test will be installed after you restart " + gApp + ".",
"Should have seen the right message");
let installs = await getInstalls();
is(installs.length, 1, "Should be one pending install");
installs[0].cancel();
await removeTabAndWaitForNotificationClose();
is(installs.length, 0, "Should be no pending installs");
let addon = await AddonManager.getAddonByID("amosigned-xpi@tests.mozilla.org");
addon.uninstall();
await BrowserTestUtils.removeTab(gBrowser.selectedTab);
},
async function test_whitelistedInstall() {
@ -324,19 +275,15 @@ async function test_whitelistedInstall() {
is(gBrowser.selectedTab, tab,
"tab selected in response to the addon-install-confirmation notification");
let notificationPromise = waitForNotification("addon-install-restart");
let notificationPromise = waitForNotification("addon-installed");
acceptInstallDialog(installDialog);
let panel = await notificationPromise;
let notification = panel.childNodes[0];
is(notification.button.label, "Restart Now", "Should have seen the right button");
is(notification.getAttribute("label"),
"XPI Test will be installed after you restart " + gApp + ".",
"Should have seen the right message");
await notificationPromise;
let installs = await getInstalls();
is(installs.length, 1, "Should be one pending install");
installs[0].cancel();
is(installs.length, 0, "Should be no pending installs");
let addon = await AddonManager.getAddonByID("amosigned-xpi@tests.mozilla.org");
addon.uninstall();
Services.perms.remove(makeURI("http://example.com/"), "install");
await removeTabAndWaitForNotificationClose();
@ -403,7 +350,7 @@ async function test_incompatible() {
let notification = panel.childNodes[0];
is(notification.getAttribute("label"),
"XPI Test could not be installed because it is not compatible with " +
gApp + " " + gVersion + ".",
gApp + " " + Services.appinfo.version + ".",
"Should have seen the right message");
Services.perms.remove(makeURI("http://example.com/"), "install");
@ -415,7 +362,7 @@ async function test_restartless() {
pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
let progressPromise = waitForProgressNotification();
let dialogPromise = waitForInstallDialog();
let dialogPromise = waitForInstallDialog("addon-install-confirmation");
let triggers = encodeURIComponent(JSON.stringify({
"XPI": "restartless.xpi"
}));
@ -446,7 +393,7 @@ async function test_sequential() {
// This test is only relevant if using the new doorhanger UI
// TODO: this subtest is disabled until multiple notification prompts are
// reworked in bug 1188152
if (true || !Services.prefs.getBoolPref("xpinstall.customConfirmationUI", false)) {
if (true) {
return;
}
let pm = Services.perms;
@ -520,8 +467,7 @@ async function test_sequential() {
async function test_allUnverified() {
// This test is only relevant if using the new doorhanger UI and allowing
// unsigned add-ons
if (!Services.prefs.getBoolPref("xpinstall.customConfirmationUI", false) ||
Services.prefs.getBoolPref("xpinstall.signatures.required", true) ||
if (Services.prefs.getBoolPref("xpinstall.signatures.required", true) ||
AppConstants.MOZ_REQUIRE_SIGNING) {
return;
}
@ -529,7 +475,7 @@ async function test_allUnverified() {
pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
let progressPromise = waitForProgressNotification();
let dialogPromise = waitForInstallDialog();
let dialogPromise = waitForInstallDialog("addon-install-confirmation");
let triggers = encodeURIComponent(JSON.stringify({
"Extension XPI": "restartless-unsigned.xpi"
}));
@ -561,32 +507,6 @@ async function test_allUnverified() {
await removeTabAndWaitForNotificationClose();
},
async function test_url() {
let progressPromise = waitForProgressNotification();
let dialogPromise = waitForInstallDialog();
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:blank");
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
gBrowser.loadURI(TESTROOT + "amosigned.xpi");
await progressPromise;
let installDialog = await dialogPromise;
let notificationPromise = waitForNotification("addon-install-restart");
acceptInstallDialog(installDialog);
let panel = await notificationPromise;
let notification = panel.childNodes[0];
is(notification.button.label, "Restart Now", "Should have seen the right button");
is(notification.getAttribute("label"),
"XPI Test will be installed after you restart " + gApp + ".",
"Should have seen the right message");
let installs = await getInstalls();
is(installs.length, 1, "Should be one pending install");
installs[0].cancel();
await removeTabAndWaitForNotificationClose();
},
async function test_localFile() {
let cr = Cc["@mozilla.org/chrome/chrome-registry;1"]
.getService(Ci.nsIChromeRegistry);
@ -621,16 +541,11 @@ async function test_localFile() {
},
async function test_tabClose() {
if (!Services.prefs.getBoolPref("xpinstall.customConfirmationUI", false)) {
info("Test skipped due to xpinstall.customConfirmationUI being false.");
return;
}
let progressPromise = waitForProgressNotification();
let dialogPromise = waitForInstallDialog();
let dialogPromise = waitForInstallDialog("addon-install-confirmation");
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:blank");
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
gBrowser.loadURI(TESTROOT + "amosigned.xpi");
gBrowser.loadURI(TESTROOT + "restartless.xpi");
await progressPromise;
await dialogPromise;
@ -646,16 +561,13 @@ async function test_tabClose() {
// Add-ons should be cancelled and the install notification destroyed when
// navigating to a new origin
async function test_tabNavigate() {
if (!Services.prefs.getBoolPref("xpinstall.customConfirmationUI", false)) {
return;
}
let pm = Services.perms;
pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
let progressPromise = waitForProgressNotification();
let dialogPromise = waitForInstallDialog();
let dialogPromise = waitForInstallDialog("addon-install-confirmation");
let triggers = encodeURIComponent(JSON.stringify({
"Extension XPI": "amosigned.xpi"
"Extension XPI": "restartless.xpi"
}));
BrowserTestUtils.openNewForegroundTab(gBrowser, TESTROOT + "installtrigger.html?" + triggers);
await progressPromise;
@ -695,19 +607,15 @@ async function test_urlBar() {
await progressPromise;
let installDialog = await dialogPromise;
let notificationPromise = waitForNotification("addon-install-restart");
acceptInstallDialog(installDialog);
let panel = await notificationPromise;
let notification = panel.childNodes[0];
is(notification.button.label, "Restart Now", "Should have seen the right button");
is(notification.getAttribute("label"),
"XPI Test will be installed after you restart " + gApp + ".",
"Should have seen the right message");
let notificationPromise = waitForNotification("addon-installed");
installDialog.button.click();
await notificationPromise;
let installs = await getInstalls();
is(installs.length, 1, "Should be one pending install");
installs[0].cancel();
is(installs.length, 0, "Should be no pending installs");
let addon = await AddonManager.getAddonByID("amosigned-xpi@tests.mozilla.org");
addon.uninstall();
await removeTabAndWaitForNotificationClose();
},
@ -735,91 +643,6 @@ async function test_wrongHost() {
await removeTabAndWaitForNotificationClose();
},
async function test_reload() {
let pm = Services.perms;
pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
let progressPromise = waitForProgressNotification();
let dialogPromise = waitForInstallDialog();
let triggers = encodeURIComponent(JSON.stringify({
"Unsigned XPI": "amosigned.xpi"
}));
BrowserTestUtils.openNewForegroundTab(gBrowser, TESTROOT + "installtrigger.html?" + triggers);
await progressPromise;
let installDialog = await dialogPromise;
let notificationPromise = waitForNotification("addon-install-restart");
acceptInstallDialog(installDialog);
let panel = await notificationPromise;
let notification = panel.childNodes[0];
is(notification.button.label, "Restart Now", "Should have seen the right button");
is(notification.getAttribute("label"),
"XPI Test will be installed after you restart " + gApp + ".",
"Should have seen the right message");
function testFail() {
ok(false, "Reloading should not have hidden the notification");
}
PopupNotifications.panel.addEventListener("popuphiding", testFail);
let requestedUrl = TESTROOT2 + "enabled.html";
let loadedPromise = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser, false, requestedUrl);
gBrowser.loadURI(TESTROOT2 + "enabled.html");
await loadedPromise;
PopupNotifications.panel.removeEventListener("popuphiding", testFail);
let installs = await getInstalls();
is(installs.length, 1, "Should be one pending install");
installs[0].cancel();
Services.perms.remove(makeURI("http://example.com/"), "install");
await removeTabAndWaitForNotificationClose();
},
async function test_theme() {
let pm = Services.perms;
pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
let progressPromise = waitForProgressNotification();
let dialogPromise = waitForInstallDialog();
let triggers = encodeURIComponent(JSON.stringify({
"Theme XPI": "theme.xpi"
}));
BrowserTestUtils.openNewForegroundTab(gBrowser, TESTROOT + "installtrigger.html?" + triggers);
await progressPromise;
let installDialog = await dialogPromise;
let notificationPromise = waitForNotification("addon-install-restart");
acceptInstallDialog(installDialog);
let panel = await notificationPromise;
let notification = panel.childNodes[0];
is(notification.button.label, "Restart Now", "Should have seen the right button");
is(notification.getAttribute("label"),
"Theme Test will be installed after you restart " + gApp + ".",
"Should have seen the right message");
let addon = await new Promise(resolve => {
AddonManager.getAddonByID("{972ce4c6-7e08-4474-a285-3208198ce6fd}", function(result) {
resolve(result);
});
});
ok(addon.userDisabled, "Should be switching away from the default theme.");
// Undo the pending theme switch
addon.userDisabled = false;
addon = await new Promise(resolve => {
AddonManager.getAddonByID("theme-xpi@tests.mozilla.org", function(result) {
resolve(result);
});
});
isnot(addon, null, "Test theme will have been installed");
addon.uninstall();
Services.perms.remove(makeURI("http://example.com/"), "install");
await removeTabAndWaitForNotificationClose();
},
async function test_renotifyBlocked() {
let notificationPromise = waitForNotification("addon-install-blocked");
let triggers = encodeURIComponent(JSON.stringify({
@ -850,53 +673,6 @@ async function test_renotifyBlocked() {
is(installs.length, 0, "Should have cancelled the installs");
},
async function test_renotifyInstalled() {
let pm = Services.perms;
pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
let progressPromise = waitForProgressNotification();
let dialogPromise = waitForInstallDialog();
let triggers = encodeURIComponent(JSON.stringify({
"XPI": "amosigned.xpi"
}));
BrowserTestUtils.openNewForegroundTab(gBrowser, TESTROOT + "installtrigger.html?" + triggers);
await progressPromise;
let installDialog = await dialogPromise;
// Wait for the complete notification
let notificationPromise = waitForNotification("addon-install-restart");
acceptInstallDialog(installDialog);
let panel = await notificationPromise;
let closePromise = waitForNotificationClose();
// hide the panel (this simulates the user dismissing it)
panel.hidePopup();
await closePromise;
// Install another
await new Promise(resolve => executeSoon(resolve));
progressPromise = waitForProgressNotification();
dialogPromise = waitForInstallDialog();
gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
await progressPromise;
installDialog = await dialogPromise;
info("Timeouts after this probably mean bug 589954 regressed");
// Wait for the complete notification
notificationPromise = waitForNotification("addon-install-restart");
acceptInstallDialog(installDialog);
await notificationPromise;
let installs = await getInstalls();
is(installs.length, 1, "Should be one pending installs");
installs[0].cancel();
Services.perms.remove(makeURI("http://example.com/"), "install");
await removeTabAndWaitForNotificationClose();
},
async function test_cancel() {
let pm = Services.perms;
pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);

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

@ -46,7 +46,7 @@ function allow_blocked(installInfo) {
return false;
}
function confirm_install(window) {
function confirm_install(panel) {
ok(false, "Should never see an install confirmation dialog");
return false;
}

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

@ -12,7 +12,7 @@ function test() {
var triggers = encodeURIComponent(JSON.stringify({
"Unsigned XPI": {
URL: TESTROOT + "amosigned.xpi",
Hash: "sha1:36ffb0acfd9c6e9682473aaebaab394d38b473c9",
Hash: "sha1:ee95834ad862245a9ef99ccecc2a857cadc16404",
toString() { return this.URL; }
}
}));

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

@ -12,7 +12,7 @@ function test() {
var triggers = encodeURIComponent(JSON.stringify({
"Unsigned XPI": {
URL: TESTROOT + "amosigned.xpi",
Hash: "sha1:36FFB0ACFD9C6E9682473AAEBAAB394D38B473C9",
Hash: "sha1:EE95834AD862245A9EF99CCECC2A857CADC16404",
toString() { return this.URL; }
}
}));

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

@ -12,7 +12,7 @@ function test() {
Services.prefs.setBoolPref(PREF_INSTALL_REQUIREBUILTINCERTS, false);
var url = "https://example.com/browser/" + RELATIVE_DIR + "hashRedirect.sjs";
url += "?sha1:36ffb0acfd9c6e9682473aaebaab394d38b473c9|" + TESTROOT + "amosigned.xpi";
url += "?sha1:ee95834ad862245a9ef99ccecc2a857cadc16404|" + TESTROOT + "amosigned.xpi";
var triggers = encodeURIComponent(JSON.stringify({
"Unsigned XPI": {

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

@ -16,7 +16,7 @@ function test() {
var triggers = encodeURIComponent(JSON.stringify({
"Unsigned XPI": {
URL: url,
Hash: "sha1:36ffb0acfd9c6e9682473aaebaab394d38b473c9",
Hash: "sha1:ee95834ad862245a9ef99ccecc2a857cadc16404",
toString() { return this.URL; }
}
}));

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

@ -11,7 +11,7 @@ function test() {
Services.prefs.setBoolPref(PREF_INSTALL_REQUIREBUILTINCERTS, false);
var url = "https://example.com/browser/" + RELATIVE_DIR + "hashRedirect.sjs";
url += "?sha1:36ffb0acfd9c6e9682473aaebaab394d38b473c9|";
url += "?sha1:ee95834ad862245a9ef99ccecc2a857cadc16404|";
url += "https://example.com/browser/" + RELATIVE_DIR + "hashRedirect.sjs";
url += "?sha1:foobar|" + TESTROOT + "amosigned.xpi";

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

@ -55,7 +55,7 @@ function finish_failed_download() {
// Give it the right hash this time
setup_redirect({
"X-Target-Digest": "sha1:36ffb0acfd9c6e9682473aaebaab394d38b473c9",
"X-Target-Digest": "sha1:ee95834ad862245a9ef99ccecc2a857cadc16404",
"Location": "http://example.com/browser/" + RELATIVE_DIR + "amosigned.xpi"
});

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

@ -1,36 +0,0 @@
// ----------------------------------------------------------------------------
// Tests that navigating away from the initiating page during the install
// doesn't break the install.
// This verifies bug 473060
function test() {
Harness.downloadProgressCallback = download_progress;
Harness.installEndedCallback = install_ended;
Harness.installsCompletedCallback = finish_test;
Harness.setup();
var pm = Services.perms;
pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
var triggers = encodeURIComponent(JSON.stringify({
"Unsigned XPI": TESTROOT + "amosigned.xpi"
}));
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
}
function download_progress(addon, value, maxValue) {
gBrowser.loadURI(TESTROOT + "enabled.html");
}
function install_ended(install, addon) {
install.cancel();
}
function finish_test(count) {
is(count, 1, "1 Add-on should have been successfully installed");
Services.perms.remove(makeURI("http://example.com"), "install");
gBrowser.removeCurrentTab();
Harness.finish();
}

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

@ -1,34 +0,0 @@
// ----------------------------------------------------------------------------
// Tests that closing the initiating page during the install cancels the install
// to avoid spoofing the user.
function test() {
Harness.downloadProgressCallback = download_progress;
Harness.installEndedCallback = install_ended;
Harness.installsCompletedCallback = finish_test;
Harness.setup();
var pm = Services.perms;
pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
var triggers = encodeURIComponent(JSON.stringify({
"Unsigned XPI": TESTROOT + "amosigned.xpi"
}));
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
}
function download_progress(addon, value, maxValue) {
gBrowser.removeCurrentTab();
}
function install_ended(install, addon) {
ok(false, "Should not have seen installs complete");
}
function finish_test(count) {
is(count, 0, "No add-ons should have been successfully installed");
Services.perms.remove(makeURI("http://example.com"), "install");
Harness.finish();
}

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

@ -1,38 +0,0 @@
// ----------------------------------------------------------------------------
// Tests that navigating to a new origin cancels ongoing installs.
// Block the modal install UI from showing.
Services.prefs.setBoolPref(PREF_CUSTOM_CONFIRMATION_UI, true);
function test() {
Harness.downloadProgressCallback = download_progress;
Harness.installEndedCallback = install_ended;
Harness.installsCompletedCallback = finish_test;
Harness.setup();
var pm = Services.perms;
pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
var triggers = encodeURIComponent(JSON.stringify({
"Unsigned XPI": TESTROOT + "amosigned.xpi"
}));
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
}
function download_progress(addon, value, maxValue) {
gBrowser.loadURI(TESTROOT2 + "enabled.html");
}
function install_ended(install, addon) {
ok(false, "Should not have seen installs complete");
}
function finish_test(count) {
is(count, 0, "No add-ons should have been successfully installed");
Services.perms.remove(makeURI("http://example.com"), "install");
gBrowser.removeCurrentTab();
Harness.finish();
}

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

@ -1,44 +0,0 @@
// ----------------------------------------------------------------------------
// Tests that navigating to a new origin cancels ongoing installs and closes
// the install UI.
var sawUnload = null;
function test() {
Harness.installConfirmCallback = confirm_install;
Harness.installEndedCallback = install_ended;
Harness.installsCompletedCallback = finish_test;
Harness.setup();
var pm = Services.perms;
pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
var triggers = encodeURIComponent(JSON.stringify({
"Unsigned XPI": TESTROOT + "amosigned.xpi"
}));
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
}
function confirm_install(window) {
sawUnload = BrowserTestUtils.waitForEvent(window, "unload");
gBrowser.loadURI(TESTROOT2 + "enabled.html");
return Harness.leaveOpen;
}
function install_ended(install, addon) {
ok(false, "Should not have seen installs complete");
}
function finish_test(count) {
is(count, 0, "No add-ons should have been successfully installed");
Services.perms.remove(makeURI("http://example.com"), "install");
sawUnload.then(() => {
ok(true, "The install UI should have closed itself.");
gBrowser.removeCurrentTab();
Harness.finish();
});
}

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

@ -21,12 +21,8 @@ function test() {
gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
}
function confirm_install(window) {
var items = window.document.getElementById("itemList").childNodes;
is(items.length, 1, "Should only be 1 item listed in the confirmation dialog");
is(items[0].name, "XPI Test", "Should have seen the name");
is(items[0].url, TESTROOT + "amosigned.xpi", "Should have listed the correct url for the item");
is(items[0].icon, TESTROOT + "icon.png", "Should have listed the correct icon for the item");
function confirm_install(panel) {
is(panel.getAttribute("name"), "XPI Test", "Should have seen the name");
return true;
}

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

@ -1,49 +0,0 @@
// ----------------------------------------------------------------------------
// Tests installing a signed add-on that has been tampered with after signing.
// In "no signature required" mode, a tampered add-on is equivalent to an
// unsigned add-on.
function test() {
Harness.installConfirmCallback = confirm_install;
Harness.installEndedCallback = install_ended;
Harness.installsCompletedCallback = finish_test;
Harness.finalContentEvent = "InstallComplete";
Harness.setup();
var pm = Services.perms;
pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
var triggers = encodeURIComponent(JSON.stringify({
"Tampered Signed XPI": TESTROOT + "signed-tampered.xpi"
}));
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
}
function confirm_install(window) {
var items = window.document.getElementById("itemList").childNodes;
is(items.length, 1, "Should only be 1 item listed in the confirmation dialog");
is(items[0].name, "Signed XPI Test - Tampered", "Should have seen the name");
is(items[0].url, TESTROOT + "signed-tampered.xpi", "Should have listed the correct url for the item");
return true;
}
function install_ended(install, addon) {
install.cancel();
}
const finish_test = async function(count) {
is(count, 1, "1 Add-on should have been successfully installed");
Services.perms.remove(makeURI("http://example.com"), "install");
const results = await ContentTask.spawn(gBrowser.selectedBrowser, null, () => {
return {
return: content.document.getElementById("return").textContent,
status: content.document.getElementById("status").textContent,
};
});
is(results.return, "true", "installTrigger should have claimed success");
is(results.status, "0", "Callback should have seen a success");
gBrowser.removeCurrentTab();
Harness.finish();
};

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

@ -17,11 +17,8 @@ function test() {
gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
}
function confirm_install(window) {
var items = window.document.getElementById("itemList").childNodes;
is(items.length, 1, "Should only be 1 item listed in the confirmation dialog");
is(items[0].name, "XPI Test", "Should have seen the name from the trigger list");
is(items[0].url, TESTROOT + "amosigned.xpi", "Should have listed the correct url for the item");
function confirm_install(panel) {
is(panel.getAttribute("name"), "XPI Test", "Should have seen the name");
return true;
}

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

@ -1,40 +0,0 @@
// ----------------------------------------------------------------------------
// Tests installing an add-on signed by an untrusted certificate through an
// InstallTrigger call in web content.
function test() {
Harness.installConfirmCallback = confirm_install;
Harness.installEndedCallback = install_ended;
Harness.installsCompletedCallback = finish_test;
Harness.setup();
var pm = Services.perms;
pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
var triggers = encodeURIComponent(JSON.stringify({
"Untrusted Signed XPI": TESTROOT + "signed-untrusted.xpi"
}));
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
}
function confirm_install(window) {
var items = window.document.getElementById("itemList").childNodes;
is(items.length, 1, "Should only be 1 item listed in the confirmation dialog");
is(items[0].name, "Signed XPI Test", "Should have had the filename for the item name");
is(items[0].url, TESTROOT + "signed-untrusted.xpi", "Should have listed the correct url for the item");
is(items[0].icon, "", "Should have listed no icon for the item");
return true;
}
function install_ended(install, addon) {
install.cancel();
}
function finish_test(count) {
is(count, 1, "1 Add-on should have been successfully installed");
Services.perms.remove(makeURI("http://example.com"), "install");
gBrowser.removeCurrentTab();
Harness.finish();
}
// ----------------------------------------------------------------------------

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

@ -12,11 +12,8 @@ function test() {
});
}
function confirm_install(window) {
let items = window.document.getElementById("itemList").childNodes;
is(items.length, 1, "Should only be 1 item listed in the confirmation dialog");
is(items[0].name, "XPI Test", "Should have had the name");
is(items[0].url, TESTROOT + "amosigned.xpi", "Should have listed the correct url for the item");
function confirm_install(panel) {
is(panel.getAttribute("name"), "XPI Test", "Should have seen the name");
return true;
}

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

@ -1,48 +0,0 @@
// ----------------------------------------------------------------------------
// Tests installing an unsigned add-on through an InstallTrigger call in web
// content.
var expectedTab = null;
function test() {
Harness.installConfirmCallback = confirm_install;
Harness.installEndedCallback = install_ended;
Harness.installsCompletedCallback = finish_test;
Harness.setup();
var pm = Services.perms;
pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
var triggers = encodeURIComponent(JSON.stringify({
"Unsigned XPI": {
URL: TESTROOT + "amosigned.xpi",
IconURL: TESTROOT + "icon.png",
toString() { return this.URL; }
}
}));
expectedTab = BrowserTestUtils.addTab(gBrowser);
expectedTab.linkedBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
}
function confirm_install(window) {
var items = window.document.getElementById("itemList").childNodes;
is(items.length, 1, "Should only be 1 item listed in the confirmation dialog");
is(items[0].name, "XPI Test", "Should have seen the name");
is(items[0].url, TESTROOT + "amosigned.xpi", "Should have listed the correct url for the item");
is(items[0].icon, TESTROOT + "icon.png", "Should have listed the correct icon for the item");
is(gBrowser.selectedTab, expectedTab, "Should have switched to the installing tab.");
return true;
}
function install_ended(install, addon) {
install.cancel();
}
function finish_test(count) {
is(count, 1, "1 Add-on should have been successfully installed");
Services.perms.remove(makeURI("http://example.com"), "install");
gBrowser.removeTab(expectedTab);
Harness.finish();
}

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

@ -14,12 +14,8 @@ function test() {
gBrowser.loadURI(TESTROOT + "triggerredirect.html");
}
function confirm_install(window) {
var items = window.document.getElementById("itemList").childNodes;
is(items.length, 1, "Should only be 1 item listed in the confirmation dialog");
is(items[0].name, "XPI Test", "Should have seen the name");
is(items[0].url, TESTROOT + "amosigned.xpi", "Should have listed the correct url for the item");
is(items[0].icon, TESTROOT + "icon.png", "Should have listed the correct icon for the item");
function confirm_install(panel) {
is(panel.getAttribute("name"), "XPI Test", "Should have seen the name");
return true;
}

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

@ -22,12 +22,8 @@ function test() {
gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
}
function confirm_install(window) {
var items = window.document.getElementById("itemList").childNodes;
is(items.length, 1, "Should only be 1 item listed in the confirmation dialog");
is(items[0].name, "XPI Test", "Should have seen the name");
is(items[0].url, TESTROOT + "unsigned.xpi", "Should have listed the correct url for the item");
is(items[0].icon, TESTROOT + "icon.png", "Should have listed the correct icon for the item");
function confirm_install(panel) {
is(panel.getAttribute("name"), "XPI Test", "Should have seen the name");
return true;
}

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

@ -23,12 +23,8 @@ function test() {
gBrowser.loadURI(TESTROOT + "installtrigger_frame.html?" + inner_url);
}
function confirm_install(window) {
var items = window.document.getElementById("itemList").childNodes;
is(items.length, 1, "Should only be 1 item listed in the confirmation dialog");
is(items[0].name, "XPI Test", "Should have seen the name");
is(items[0].url, TESTROOT + "unsigned.xpi", "Should have listed the correct url for the item");
is(items[0].icon, TESTROOT + "icon.png", "Should have listed the correct icon for the item");
function confirm_install(panel) {
is(panel.getAttribute("name"), "XPI Test", "Should have seen the name");
return true;
}

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

@ -12,12 +12,8 @@ function test() {
});
}
function confirm_install(window) {
let items = window.document.getElementById("itemList").childNodes;
is(items.length, 1, "Should only be 1 item listed in the confirmation dialog");
is(items[0].name, "XPI Test", "Should have had the filename for the item name");
is(items[0].url, TESTROOT + "unsigned.xpi", "Should have listed the correct url for the item");
is(items[0].icon, "", "Should have listed no icon for the item");
function confirm_install(panel) {
is(panel.getAttribute("name"), "XPI Test", "Should have seen the name");
return true;
}

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

@ -22,11 +22,8 @@ function allow_blocked(installInfo) {
return true;
}
function confirm_install(window) {
var items = window.document.getElementById("itemList").childNodes;
is(items.length, 1, "Should only be 1 item listed in the confirmation dialog");
is(items[0].name, "XPI Test", "Should have seen the name from the trigger list");
is(items[0].url, TESTROOT + "amosigned.xpi", "Should have listed the correct url for the item");
function confirm_install(panel) {
is(panel.getAttribute("name"), "XPI Test", "Should have seen the name");
return true;
}

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

@ -1,31 +0,0 @@
// ----------------------------------------------------------------------------
// Tests installing an unsigned add-on through an InstallTrigger call in web
// content. This should be blocked by the whitelist check because the source
// is not whitelisted, even though the target is.
function test() {
Harness.installBlockedCallback = allow_blocked;
Harness.installsCompletedCallback = finish_test;
Harness.setup();
var pm = Services.perms;
pm.add(makeURI("http://example.org/"), "install", pm.ALLOW_ACTION);
var triggers = encodeURIComponent(JSON.stringify({
"Unsigned XPI": TESTROOT2 + "amosigned.xpi"
}));
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
}
function allow_blocked(installInfo) {
is(installInfo.browser, gBrowser.selectedBrowser, "Install should have been triggered by the right browser");
is(installInfo.originatingURI.spec, gBrowser.currentURI.spec, "Install should have been triggered by the right uri");
return false;
}
function finish_test() {
Services.perms.remove(makeURI("http://example.org"), "install");
gBrowser.removeCurrentTab();
Harness.finish();
}

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

@ -1,28 +0,0 @@
// ----------------------------------------------------------------------------
// Tests installing an unsigned add-on through a navigation. Should not be
// blocked since the referer is whitelisted.
var url = TESTROOT2 + "navigate.html?" + encodeURIComponent(TESTROOT + "amosigned.xpi");
function test() {
Harness.installConfirmCallback = confirm_install;
Harness.installsCompletedCallback = finish_test;
Harness.setup();
var pm = Services.perms;
pm.add(makeURI("http://example.org/"), "install", pm.ALLOW_ACTION);
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
gBrowser.loadURI(url);
}
function confirm_install(window) {
return false;
}
function finish_test(count) {
is(count, 0, "No add-ons should have been installed");
Services.perms.remove(makeURI("http://example.org"), "install");
gBrowser.removeCurrentTab();
Harness.finish();
}

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

@ -1,30 +0,0 @@
// ----------------------------------------------------------------------------
// Tests installing an unsigned add-on through a navigation. Should be
// blocked since the referer is not whitelisted even though the target is.
var url = TESTROOT2 + "navigate.html?" + encodeURIComponent(TESTROOT + "amosigned.xpi");
function test() {
Harness.installBlockedCallback = allow_blocked;
Harness.installsCompletedCallback = finish_test;
Harness.setup();
var pm = Services.perms;
pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
gBrowser.loadURI(url);
}
function allow_blocked(installInfo) {
is(installInfo.browser, gBrowser.selectedBrowser, "Install should have been triggered by the right browser");
is(installInfo.originatingURI.spec, url, "Install should have been triggered by the right uri");
return false;
}
function finish_test(count) {
is(count, 0, "No add-ons should have been installed");
Services.perms.remove(makeURI("http://example.com"), "install");
gBrowser.removeCurrentTab();
Harness.finish();
}

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

@ -1,25 +0,0 @@
// ----------------------------------------------------------------------------
// Tests installing an unsigned add-on through a startSoftwareUpdate call in web
// content. This should be blocked by the whitelist check.
// This verifies bug 252830
function test() {
Harness.installBlockedCallback = allow_blocked;
Harness.installsCompletedCallback = finish_test;
Harness.setup();
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
gBrowser.loadURI(TESTROOT + "startsoftwareupdate.html? " + encodeURIComponent(TESTROOT + "amosigned.xpi"));
}
function allow_blocked(installInfo) {
is(installInfo.browser, gBrowser.selectedBrowser, "Install should have been triggered by the right browser");
is(installInfo.originatingURI.spec, gBrowser.currentURI.spec, "Install should have been triggered by the right uri");
return false;
}
function finish_test(count) {
is(count, 0, "No add-ons should have been installed");
gBrowser.removeCurrentTab();
Harness.finish();
}
// ----------------------------------------------------------------------------

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

@ -1,25 +0,0 @@
// ----------------------------------------------------------------------------
// Tests installing an unsigned add-on through an installChrome call in web
// content. This should be blocked by the whitelist check.
// This verifies bug 252830
function test() {
Harness.installBlockedCallback = allow_blocked;
Harness.installsCompletedCallback = finish_test;
Harness.setup();
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
gBrowser.loadURI(TESTROOT + "installchrome.html? " + encodeURIComponent(TESTROOT + "amosigned.xpi"));
}
function allow_blocked(installInfo) {
is(installInfo.browser, gBrowser.selectedBrowser, "Install should have been triggered by the right browser");
is(installInfo.originatingURI.spec, gBrowser.currentURI.spec, "Install should have been triggered by the right uri");
return false;
}
function finish_test(count) {
is(count, 0, "No add-ons should have been installed");
gBrowser.removeCurrentTab();
Harness.finish();
}
// ----------------------------------------------------------------------------

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

@ -1,32 +0,0 @@
// ----------------------------------------------------------------------------
// Tests installing an unsigned add-on through a direct install request from
// web content. This should be blocked by the whitelist check because we disable
// direct request whitelisting, even though the target URI is whitelisted.
function test() {
Harness.installBlockedCallback = allow_blocked;
Harness.installsCompletedCallback = finish_test;
Harness.setup();
// Disable direct request whitelisting, installing should be blocked.
Services.prefs.setBoolPref("xpinstall.whitelist.directRequest", false);
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:blank");
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(() => {
gBrowser.loadURI(TESTROOT + "amosigned.xpi");
});
}
function allow_blocked(installInfo) {
ok(true, "Seen blocked");
return false;
}
function finish_test(count) {
is(count, 0, "No add-ons should have been installed");
Services.perms.remove(makeURI("http://example.org"), "install");
Services.prefs.clearUserPref("xpinstall.whitelist.directRequest");
gBrowser.removeCurrentTab();
Harness.finish();
}

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

@ -1,40 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta charset="utf-8">
<title>Concurrent InstallTrigger tests</title>
<script type="text/javascript">
/* globals InstallTrigger */
/* exported startInstall */
function installCallback(url, status) {
document.getElementById("status").textContent = status;
dump("Sending InstallComplete\n");
var event = new CustomEvent("InstallComplete", {detail: {loc: location.href, xpi: url}});
window.dispatchEvent(event);
}
function startInstall() {
var root = location.href.replace("concurrent_installs.html", "");
var triggers = {
"Unsigned XPI": root + "amosigned.xpi"
};
try {
document.getElementById("return").textContent = InstallTrigger.install(triggers, installCallback);
} catch (e) {
document.getElementById("return").textContent = "exception";
throw e;
}
}
</script>
</head>
<body>
<p>InstallTrigger tests</p>
<button id="installnow" onclick="startInstall()">Click to install</button>
<p id="return"></p>
<p id="status"></p>
</body>
</html>

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

@ -119,6 +119,8 @@ var Harness = {
Services.wm.addListener(this);
window.addEventListener("popupshown", this);
var self = this;
registerCleanupFunction(function() {
Services.prefs.clearUserPref(PREF_LOGGING_ENABLED);
@ -135,6 +137,8 @@ var Harness = {
Services.wm.removeListener(self);
window.removeEventListener("popupshown", self);
AddonManager.getAllInstalls(function(aInstalls) {
is(aInstalls.length, 0, "Should be no active installs at the end of the test");
aInstalls.forEach(function(aInstall) {
@ -239,6 +243,40 @@ var Harness = {
}
},
popupReady(panel) {
if (this.installBlockedCallback)
ok(false, "Should have been blocked by the whitelist");
this.pendingCount++;
// 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(panel);
if (result === this.leaveOpen)
return;
}
if (!result) {
panel.secondaryButton.click();
} else {
panel.button.click();
}
},
handleEvent(event) {
if (event.type === "popupshown") {
if (event.target.firstChild) {
let popupId = event.target.getAttribute("popupid");
if (popupId === "addon-webext-permissions") {
this.popupReady(event.target.firstChild);
} else if (popupId === "addon-installed" || popupId === "addon-install-failed") {
event.target.firstChild.button.click();
}
}
}
},
// Install blocked handling
installDisabled(installInfo) {
@ -355,9 +393,9 @@ var Harness = {
},
onInstallEnded(install, addon) {
this.installCount++;
if (this.installEndedCallback)
this.installEndedCallback(install, addon);
this.installCount++;
this.checkTestEnded();
},

Двоичный файл не отображается.

Двоичный файл не отображается.

Двоичный файл не отображается.