Bug 1447903: Part 21 - Update test_bug455906.js to use only bootstrapped extensions. r?aswan
MozReview-Commit-ID: 33f7WNFP5bT
--- a/toolkit/mozapps/extensions/test/xpcshell/head_addons.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/head_addons.js
@@ -63,25 +63,16 @@ ChromeUtils.defineModuleGetter(this, "Mo
"resource://testing-common/MockRegistrar.jsm");
ChromeUtils.defineModuleGetter(this, "MockRegistry",
"resource://testing-common/MockRegistry.jsm");
XPCOMUtils.defineLazyServiceGetter(this, "aomStartup",
"@mozilla.org/addons/addon-manager-startup;1",
"amIAddonManagerStartup");
-// Whitelist existing tests that still use non-restartless extensions.
-const LEGACY_NON_RESTARTLESS_TESTS = new Set([
- "test_bug455906.js",
-]);
-
-if (LEGACY_NON_RESTARTLESS_TESTS.has(_TEST_FILE[0].replace(/.*\//, ""))) {
- Services.prefs.setBoolPref("extensions.legacy.non-restartless.enabled", true);
-}
-
const {
awaitPromise,
createAppInfo,
createInstallRDF,
createTempWebExtensionFile,
createUpdateRDF,
getFileForAddon,
manuallyUninstall,
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug455906.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug455906.js
@@ -1,21 +1,24 @@
/* 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/.
*/
const URI_EXTENSION_BLOCKLIST_DIALOG = "chrome://mozapps/content/extensions/blocklist.xul";
+ChromeUtils.import("resource://gre/modules/ExtensionUtils.jsm");
ChromeUtils.import("resource://testing-common/httpd.js");
ChromeUtils.import("resource://testing-common/MockRegistrar.jsm");
var gTestserver = new HttpServer();
gTestserver.start(-1);
gPort = gTestserver.identity.primaryPort;
+const {promiseObserved} = ExtensionUtils;
+
// register static files with server and interpolate port numbers in them
mapFile("/data/bug455906_warn.xml", gTestserver);
mapFile("/data/bug455906_start.xml", gTestserver);
mapFile("/data/bug455906_block.xml", gTestserver);
mapFile("/data/bug455906_empty.xml", gTestserver);
// Workaround for Bug 658720 - URL formatter can leak during xpcshell tests
const PREF_BLOCKLIST_ITEM_URL = "extensions.blocklist.itemURL";
@@ -161,16 +164,17 @@ MockRegistrar.register("@mozilla.org/emb
function create_addon(addon) {
var installrdf = "<?xml version=\"1.0\"?>\n" +
"\n" +
"<RDF xmlns=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n" +
" xmlns:em=\"http://www.mozilla.org/2004/em-rdf#\">\n" +
" <Description about=\"urn:mozilla:install-manifest\">\n" +
" <em:id>" + addon.id + "</em:id>\n" +
" <em:version>" + addon.version + "</em:version>\n" +
+ " <em:bootstrap>true</em:bootstrap>\n" +
" <em:targetApplication>\n" +
" <Description>\n" +
" <em:id>xpcshell@tests.mozilla.org</em:id>\n" +
" <em:minVersion>" + addon.appVersion + "</em:minVersion>\n" +
" <em:maxVersion>" + addon.appVersion + "</em:maxVersion>\n" +
" </Description>\n" +
" </em:targetApplication>\n" +
" <em:name>" + addon.name + "</em:name>\n" +
@@ -366,17 +370,17 @@ function run_test_pt3() {
gNotificationCheck = check_notification_pt3;
gTestCheck = check_test_pt3;
load_blocklist("bug455906_block.xml");
});
}
function check_notification_pt3(args) {
dump("Checking notification pt 3\n");
- Assert.equal(args.list.length, 6);
+ Assert.equal(args.list.length, 3);
for (let addon of args.list) {
if (addon.item instanceof Ci.nsIPluginTag) {
switch (addon.item.name) {
case "test_bug455906_2":
Assert.ok(addon.blocked);
break;
case "test_bug455906_3":
@@ -441,29 +445,31 @@ function check_test_pt3() {
// Shouldn't be changed
Assert.equal(check_addon_state(addons[5]), "false,false,true");
Assert.equal(check_addon_state(addons[6]), "false,false,true");
Assert.equal(check_plugin_state(PLUGINS[5]), "false,true");
// Back to starting state
gNotificationCheck = null;
- gTestCheck = run_test_pt4;
+ gTestCheck = null;
+ promiseObserved("blocklist-updated").then(run_test_pt4);
load_blocklist("bug455906_start.xml");
});
}
function run_test_pt4() {
AddonManager.getAddonByID(ADDONS[4].id, callback_soon(function(addon) {
addon.userDisabled = false;
PLUGINS[4].enabledState = Ci.nsIPluginTag.STATE_ENABLED;
restartManager();
check_initial_state(function() {
gNotificationCheck = check_notification_pt4;
gTestCheck = check_test_pt4;
+ promiseObserved("blocklist-updated").then(check_test_pt4);
load_blocklist("bug455906_empty.xml");
});
}));
}
function check_notification_pt4(args) {
dump("Checking notification pt 4\n");