Bug 1140263: Test updates. r=mossop

This commit is contained in:
Stephen Pohl 2015-03-19 22:59:45 -04:00
Родитель 9fca7ec964
Коммит 90c1248342
3 изменённых файлов: 111 добавлений и 143 удалений

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

@ -4,7 +4,7 @@
const {classes: Cc, interfaces: Ci, results: Cr, utils: Cu, manager: Cm} = Components;
const URL_HOST = "http://localhost";
Cu.import("resource://gre/modules/GMPInstallManager.jsm");
let GMPScope = Cu.import("resource://gre/modules/GMPInstallManager.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/FileUtils.jsm");
@ -26,26 +26,26 @@ function run_test() {Cu.import("resource://gre/modules/Preferences.jsm")
add_task(function* test_prefs() {
let addon1 = "addon1", addon2 = "addon2";
GMPPrefs.set(GMPPrefs.KEY_URL, "http://not-really-used");
GMPPrefs.set(GMPPrefs.KEY_URL_OVERRIDE, "http://not-really-used-2");
GMPPrefs.set(GMPPrefs.KEY_ADDON_LAST_UPDATE, "1", addon1);
GMPPrefs.set(GMPPrefs.KEY_ADDON_VERSION, "2", addon1);
GMPPrefs.set(GMPPrefs.KEY_ADDON_LAST_UPDATE, "3", addon2);
GMPPrefs.set(GMPPrefs.KEY_ADDON_VERSION, "4", addon2);
GMPPrefs.set(GMPPrefs.KEY_ADDON_AUTOUPDATE, false, addon2);
GMPPrefs.set(GMPPrefs.KEY_CERT_CHECKATTRS, true);
GMPScope.GMPPrefs.set(GMPScope.GMPPrefs.KEY_URL, "http://not-really-used");
GMPScope.GMPPrefs.set(GMPScope.GMPPrefs.KEY_URL_OVERRIDE, "http://not-really-used-2");
GMPScope.GMPPrefs.set(GMPScope.GMPPrefs.KEY_PLUGIN_LAST_UPDATE, "1", addon1);
GMPScope.GMPPrefs.set(GMPScope.GMPPrefs.KEY_PLUGIN_VERSION, "2", addon1);
GMPScope.GMPPrefs.set(GMPScope.GMPPrefs.KEY_PLUGIN_LAST_UPDATE, "3", addon2);
GMPScope.GMPPrefs.set(GMPScope.GMPPrefs.KEY_PLUGIN_VERSION, "4", addon2);
GMPScope.GMPPrefs.set(GMPScope.GMPPrefs.KEY_PLUGIN_AUTOUPDATE, false, addon2);
GMPScope.GMPPrefs.set(GMPScope.GMPPrefs.KEY_CERT_CHECKATTRS, true);
do_check_eq(GMPPrefs.get(GMPPrefs.KEY_URL), "http://not-really-used");
do_check_eq(GMPPrefs.get(GMPPrefs.KEY_URL_OVERRIDE),
do_check_eq(GMPScope.GMPPrefs.get(GMPScope.GMPPrefs.KEY_URL), "http://not-really-used");
do_check_eq(GMPScope.GMPPrefs.get(GMPScope.GMPPrefs.KEY_URL_OVERRIDE),
"http://not-really-used-2");
do_check_eq(GMPPrefs.get(GMPPrefs.KEY_ADDON_LAST_UPDATE, "", addon1), "1");
do_check_eq(GMPPrefs.get(GMPPrefs.KEY_ADDON_VERSION, "", addon1), "2");
do_check_eq(GMPPrefs.get(GMPPrefs.KEY_ADDON_LAST_UPDATE, "", addon2), "3");
do_check_eq(GMPPrefs.get(GMPPrefs.KEY_ADDON_VERSION, "", addon2), "4");
do_check_eq(GMPPrefs.get(GMPPrefs.KEY_ADDON_AUTOUPDATE, undefined, addon2),
do_check_eq(GMPScope.GMPPrefs.get(GMPScope.GMPPrefs.KEY_PLUGIN_LAST_UPDATE, "", addon1), "1");
do_check_eq(GMPScope.GMPPrefs.get(GMPScope.GMPPrefs.KEY_PLUGIN_VERSION, "", addon1), "2");
do_check_eq(GMPScope.GMPPrefs.get(GMPScope.GMPPrefs.KEY_PLUGIN_LAST_UPDATE, "", addon2), "3");
do_check_eq(GMPScope.GMPPrefs.get(GMPScope.GMPPrefs.KEY_PLUGIN_VERSION, "", addon2), "4");
do_check_eq(GMPScope.GMPPrefs.get(GMPScope.GMPPrefs.KEY_PLUGIN_AUTOUPDATE, undefined, addon2),
false);
do_check_true(GMPPrefs.get(GMPPrefs.KEY_CERT_CHECKATTRS));
GMPPrefs.set(GMPPrefs.KEY_ADDON_AUTOUPDATE, true, addon2);
do_check_true(GMPScope.GMPPrefs.get(GMPScope.GMPPrefs.KEY_CERT_CHECKATTRS));
GMPScope.GMPPrefs.set(GMPScope.GMPPrefs.KEY_PLUGIN_AUTOUPDATE, true, addon2);
});
/**
@ -184,10 +184,10 @@ add_test(function test_checkForAddons_bad_ssl() {
// Add random stuff that cause CertUtil to require https.
//
let PREF_KEY_URL_OVERRIDE_BACKUP =
Preferences.get(GMPPrefs.KEY_URL_OVERRIDE, undefined);
Preferences.reset(GMPPrefs.KEY_URL_OVERRIDE);
Preferences.get(GMPScope.GMPPrefs.KEY_URL_OVERRIDE, undefined);
Preferences.reset(GMPScope.GMPPrefs.KEY_URL_OVERRIDE);
let CERTS_BRANCH_DOT_ONE = GMPPrefs.CERTS_BRANCH + ".1";
let CERTS_BRANCH_DOT_ONE = GMPScope.GMPPrefs.KEY_CERTS_BRANCH + ".1";
let PREF_CERTS_BRANCH_DOT_ONE_BACKUP =
Preferences.get(CERTS_BRANCH_DOT_ONE, undefined);
Services.prefs.setCharPref(CERTS_BRANCH_DOT_ONE, "funky value");
@ -203,7 +203,7 @@ add_test(function test_checkForAddons_bad_ssl() {
"not https."));
installManager.uninit();
if (PREF_KEY_URL_OVERRIDE_BACKUP) {
Preferences.set(GMPPrefs.KEY_URL_OVERRIDE,
Preferences.set(GMPScope.GMPPrefs.KEY_URL_OVERRIDE,
PREF_KEY_URL_OVERRIDE_BACKUP);
}
if (PREF_CERTS_BRANCH_DOT_ONE_BACKUP) {
@ -483,10 +483,11 @@ function* test_checkForAddons_installAddon(id, includeSize, wantInstallReject) {
do_check_true(compareBinaryData(downloadedBytes, sourceBytes));
// Make sure the prefs are set correctly
do_check_true(!!GMPPrefs.get(GMPPrefs.KEY_ADDON_LAST_UPDATE, "",
gmpAddon.id));
do_check_eq(GMPPrefs.get(GMPPrefs.KEY_ADDON_VERSION, "", gmpAddon.id),
"1.1");
do_check_true(!!GMPScope.GMPPrefs.get(
GMPScope.GMPPrefs.KEY_PLUGIN_LAST_UPDATE, "", gmpAddon.id));
do_check_eq(GMPScope.GMPPrefs.get(GMPScope.GMPPrefs.KEY_PLUGIN_VERSION, "",
gmpAddon.id),
"1.1");
// Make sure it reports as being installed
do_check_true(gmpAddon.isInstalled);
@ -518,7 +519,7 @@ add_task(test_checkForAddons_installAddon.bind(null, "3", true, true));
* Tests simpleCheckAndInstall when autoupdate is disabled for a GMP
*/
add_task(function* test_simpleCheckAndInstall_autoUpdateDisabled() {
GMPPrefs.set(GMPPrefs.KEY_ADDON_AUTOUPDATE, false, OPEN_H264_ID);
GMPScope.GMPPrefs.set(GMPScope.GMPPrefs.KEY_PLUGIN_AUTOUPDATE, false, GMPScope.OPEN_H264_ID);
let responseXML =
"<?xml version=\"1.0\"?>" +
"<updates>" +
@ -536,8 +537,8 @@ add_task(function* test_simpleCheckAndInstall_autoUpdateDisabled() {
let installManager = new GMPInstallManager();
let result = yield installManager.simpleCheckAndInstall();
do_check_eq(result.status, "nothing-new-to-install");
Preferences.reset(GMPPrefs.KEY_UPDATE_LAST_CHECK);
GMPPrefs.set(GMPPrefs.KEY_ADDON_AUTOUPDATE, true, OPEN_H264_ID);
Preferences.reset(GMPScope.GMPPrefs.KEY_UPDATE_LAST_CHECK);
GMPScope.GMPPrefs.set(GMPScope.GMPPrefs.KEY_PLUGIN_AUTOUPDATE, true, GMPScope.OPEN_H264_ID);
});
/**

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

@ -15,18 +15,15 @@ let gCategoryUtilities;
let gIsEnUsLocale;
let gMockAddons = [];
let gMockEmeAddons = [];
for (let plugin of GMPScope.GMP_PLUGINS) {
let mockAddon = Object.freeze({
id: plugin.id,
isValid: true,
isInstalled: false,
isEME: plugin.id.indexOf("gmp-eme-") == 0 ? true : false,
});
gMockAddons.push(mockAddon);
if (mockAddon.id.indexOf("gmp-eme-") == 0) {
gMockEmeAddons.push(mockAddon);
}
}
let gInstalledAddonId = "";
@ -47,7 +44,6 @@ MockGMPInstallManager.prototype = {
},
};
let gOptionsObserver = {
lastDisplayed: null,
observe: function(aSubject, aTopic, aData) {
@ -86,8 +82,8 @@ function openDetailsView(aId) {
}
add_task(function* initializeState() {
gPrefs.setBoolPref(GMPScope.KEY_LOGGING_DUMP, true);
gPrefs.setIntPref(GMPScope.KEY_LOGGING_LEVEL, 0);
gPrefs.setBoolPref(GMPScope.GMPPrefs.KEY_LOGGING_DUMP, true);
gPrefs.setIntPref(GMPScope.GMPPrefs.KEY_LOGGING_LEVEL, 0);
gManagerWindow = yield open_manager();
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
@ -96,16 +92,16 @@ add_task(function* initializeState() {
Services.obs.removeObserver(gOptionsObserver, AddonManager.OPTIONS_NOTIFICATION_DISPLAYED);
for (let addon of gMockAddons) {
gPrefs.clearUserPref(getKey(GMPScope.KEY_PLUGIN_ENABLED, addon.id));
gPrefs.clearUserPref(getKey(GMPScope.KEY_PLUGIN_LAST_UPDATE, addon.id));
gPrefs.clearUserPref(getKey(GMPScope.KEY_PLUGIN_AUTOUPDATE, addon.id));
gPrefs.clearUserPref(getKey(GMPScope.KEY_PLUGIN_VERSION, addon.id));
gPrefs.clearUserPref(getKey(GMPScope.KEY_PLUGIN_HIDDEN, addon.id));
gPrefs.clearUserPref(getKey(GMPScope.GMPPrefs.KEY_PLUGIN_ENABLED, addon.id));
gPrefs.clearUserPref(getKey(GMPScope.GMPPrefs.KEY_PLUGIN_LAST_UPDATE, addon.id));
gPrefs.clearUserPref(getKey(GMPScope.GMPPrefs.KEY_PLUGIN_AUTOUPDATE, addon.id));
gPrefs.clearUserPref(getKey(GMPScope.GMPPrefs.KEY_PLUGIN_VERSION, addon.id));
gPrefs.clearUserPref(getKey(GMPScope.GMPPrefs.KEY_PLUGIN_FORCEVISIBLE, addon.id));
}
gPrefs.clearUserPref(GMPScope.KEY_LOGGING_DUMP);
gPrefs.clearUserPref(GMPScope.KEY_LOGGING_LEVEL);
gPrefs.clearUserPref(GMPScope.KEY_PROVIDER_LASTCHECK);
gPrefs.clearUserPref(GMPScope.KEY_EME_ENABLED);
gPrefs.clearUserPref(GMPScope.GMPPrefs.KEY_LOGGING_DUMP);
gPrefs.clearUserPref(GMPScope.GMPPrefs.KEY_LOGGING_LEVEL);
gPrefs.clearUserPref(GMPScope.GMPPrefs.KEY_PROVIDER_LASTCHECK);
gPrefs.clearUserPref(GMPScope.GMPPrefs.KEY_EME_ENABLED);
yield GMPScope.GMPProvider.shutdown();
GMPScope.GMPProvider.startup();
}));
@ -117,13 +113,14 @@ add_task(function* initializeState() {
// Start out with plugins not being installed, disabled and automatic updates
// disabled.
gPrefs.setBoolPref(GMPScope.KEY_EME_ENABLED, true);
gPrefs.setBoolPref(GMPScope.GMPPrefs.KEY_EME_ENABLED, true);
for (let addon of gMockAddons) {
gPrefs.setBoolPref(getKey(GMPScope.KEY_PLUGIN_ENABLED, addon.id), false);
gPrefs.setIntPref(getKey(GMPScope.KEY_PLUGIN_LAST_UPDATE, addon.id), 0);
gPrefs.setBoolPref(getKey(GMPScope.KEY_PLUGIN_AUTOUPDATE, addon.id), false);
gPrefs.setCharPref(getKey(GMPScope.KEY_PLUGIN_VERSION, addon.id), "");
gPrefs.setBoolPref(getKey(GMPScope.KEY_PLUGIN_HIDDEN, addon.id), false);
gPrefs.setBoolPref(getKey(GMPScope.GMPPrefs.KEY_PLUGIN_ENABLED, addon.id), false);
gPrefs.setIntPref(getKey(GMPScope.GMPPrefs.KEY_PLUGIN_LAST_UPDATE, addon.id), 0);
gPrefs.setBoolPref(getKey(GMPScope.GMPPrefs.KEY_PLUGIN_AUTOUPDATE, addon.id), false);
gPrefs.setCharPref(getKey(GMPScope.GMPPrefs.KEY_PLUGIN_VERSION, addon.id), "");
gPrefs.setBoolPref(getKey(GMPScope.GMPPrefs.KEY_PLUGIN_FORCEVISIBLE, addon.id),
true);
}
yield GMPScope.GMPProvider.shutdown();
GMPScope.GMPProvider.startup();
@ -176,7 +173,7 @@ add_task(function* testNotInstalled() {
yield gCategoryUtilities.openType("plugin");
for (let addon of gMockAddons) {
gPrefs.setBoolPref(getKey(GMPScope.KEY_PLUGIN_ENABLED, addon.id), true);
gPrefs.setBoolPref(getKey(GMPScope.GMPPrefs.KEY_PLUGIN_ENABLED, addon.id), true);
let item = get_addon_element(gManagerWindow, addon.id);
Assert.ok(item, "Got add-on element:" + addon.id);
item.parentNode.ensureElementIsVisible(item);
@ -216,10 +213,10 @@ add_task(function* testNotInstalledDetails() {
add_task(function* testInstalled() {
for (let addon of gMockAddons) {
gPrefs.setIntPref(getKey(GMPScope.KEY_PLUGIN_LAST_UPDATE, addon.id),
gPrefs.setIntPref(getKey(GMPScope.GMPPrefs.KEY_PLUGIN_LAST_UPDATE, addon.id),
TEST_DATE.getTime());
gPrefs.setBoolPref(getKey(GMPScope.KEY_PLUGIN_AUTOUPDATE, addon.id), false);
gPrefs.setCharPref(getKey(GMPScope.KEY_PLUGIN_VERSION, addon.id), "1.2.3.4");
gPrefs.setBoolPref(getKey(GMPScope.GMPPrefs.KEY_PLUGIN_AUTOUPDATE, addon.id), false);
gPrefs.setCharPref(getKey(GMPScope.GMPPrefs.KEY_PLUGIN_VERSION, addon.id), "1.2.3.4");
yield gCategoryUtilities.openType("plugin");
@ -276,63 +273,18 @@ add_task(function* testInstalledDetails() {
});
add_task(function* testInstalledGlobalEmeDisabled() {
gPrefs.setBoolPref(GMPScope.KEY_EME_ENABLED, false);
for (let addon of gMockEmeAddons) {
gPrefs.setBoolPref(GMPScope.GMPPrefs.KEY_EME_ENABLED, false);
for (let addon of gMockAddons) {
yield gCategoryUtilities.openType("plugin");
let item = get_addon_element(gManagerWindow, addon.id);
Assert.ok(item, "Got add-on element.");
item.parentNode.ensureElementIsVisible(item);
is(item.getAttribute("active"), "false");
let el = item.ownerDocument.getAnonymousElementByAttribute(item, "anonid", "warning");
is_element_hidden(el, "Warning notification is hidden.");
el = item.ownerDocument.getAnonymousElementByAttribute(item, "class", "disabled-postfix");
is_element_visible(el, "disabled-postfix is visible.");
el = item.ownerDocument.getAnonymousElementByAttribute(item, "anonid", "disable-btn");
is_element_hidden(el, "Disable button not visible.");
el = item.ownerDocument.getAnonymousElementByAttribute(item, "anonid", "enable-btn");
is_element_hidden(el, "Enable button not visible.");
let menu = item.ownerDocument.getAnonymousElementByAttribute(item, "anonid", "state-menulist");
is_element_visible(menu, "State menu should be visible.");
let neverActivate = item.ownerDocument.getAnonymousElementByAttribute(item, "anonid", "never-activate-menuitem");
is(menu.selectedItem, neverActivate, "Plugin state should be never-activate.");
if (addon.isEME) {
Assert.ok(!item, "Couldn't get add-on element.");
} else {
Assert.ok(item, "Got add-on element.");
}
}
gPrefs.setBoolPref(GMPScope.KEY_EME_ENABLED, true);
});
add_task(function* testInstalledGlobalEmeDisabledDetails() {
gPrefs.setBoolPref(GMPScope.KEY_EME_ENABLED, false);
for (let addon of gMockEmeAddons) {
yield openDetailsView(addon.id);
let doc = gManagerWindow.document;
let el = doc.getElementsByClassName("disabled-postfix")[0];
is_element_visible(el, "disabled-postfix is visible.");
el = doc.getElementById("detail-findUpdates-btn");
is_element_hidden(el, "Find updates link is hidden.");
el = doc.getElementById("detail-warning");
is_element_hidden(el, "Warning notification is hidden.");
el = doc.getElementsByTagName("setting")[0];
let contextMenu = doc.getElementById("addonitem-popup");
let deferred = Promise.defer();
let listener = () => {
contextMenu.removeEventListener("popupshown", listener, false);
deferred.resolve();
};
contextMenu.addEventListener("popupshown", listener, false);
el = doc.getElementsByClassName("detail-view-container")[0];
EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow);
EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow);
yield deferred.promise;
let menuSep = doc.getElementById("addonitem-menuseparator");
is_element_hidden(menuSep, "Menu separator is hidden.");
contextMenu.hidePopup();
}
gPrefs.setBoolPref(GMPScope.KEY_EME_ENABLED, true);
gPrefs.setBoolPref(GMPScope.GMPPrefs.KEY_EME_ENABLED, true);
});
add_task(function* testPreferencesButton() {
@ -351,9 +303,9 @@ add_task(function* testPreferencesButton() {
yield close_manager(gManagerWindow);
gManagerWindow = yield open_manager();
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
gPrefs.setCharPref(getKey(GMPScope.KEY_PLUGIN_VERSION, addon.id),
gPrefs.setCharPref(getKey(GMPScope.GMPPrefs.KEY_PLUGIN_VERSION, addon.id),
preferences.version);
gPrefs.setBoolPref(getKey(GMPScope.KEY_PLUGIN_ENABLED, addon.id),
gPrefs.setBoolPref(getKey(GMPScope.GMPPrefs.KEY_PLUGIN_ENABLED, addon.id),
preferences.enabled);
yield gCategoryUtilities.openType("plugin");
@ -372,7 +324,7 @@ add_task(function* testPreferencesButton() {
});
add_task(function* testUpdateButton() {
gPrefs.clearUserPref(GMPScope.KEY_PROVIDER_LASTCHECK);
gPrefs.clearUserPref(GMPScope.GMPPrefs.KEY_PROVIDER_LASTCHECK);
let originalInstallManager = GMPScope.GMPInstallManager;
Object.defineProperty(GMPScope, "GMPInstallManager", {
@ -411,14 +363,10 @@ add_task(function* testUpdateButton() {
});
});
add_task(function* testHidden() {
gPrefs.clearUserPref(GMPScope.KEY_PROVIDER_LASTCHECK);
add_task(function* testEmeSupport() {
for (let addon of gMockAddons) {
gPrefs.setBoolPref(getKey(GMPScope.KEY_PLUGIN_HIDDEN, addon.id), true);
gPrefs.clearUserPref(getKey(GMPScope.GMPPrefs.KEY_PLUGIN_FORCEVISIBLE, addon.id));
}
// Hiding of plugins requires a restart of the GMP provider.
yield GMPScope.GMPProvider.shutdown();
GMPScope.GMPProvider.startup();
@ -426,8 +374,26 @@ add_task(function* testHidden() {
yield gCategoryUtilities.openType("plugin");
let doc = gManagerWindow.document;
let item = get_addon_element(gManagerWindow, addon.id);
Assert.equal(item, null);
if (addon.id == GMPScope.EME_ADOBE_ID) {
if (Services.appinfo.OS == "WINNT" &&
Services.sysinfo.getPropertyAsInt32("version") >= 6) {
Assert.ok(item, "Adobe EME supported, found add-on element.");
} else {
Assert.ok(!item,
"Adobe EME not supported, couldn't find add-on element.");
}
} else {
Assert.ok(item, "Found add-on element.");
}
}
for (let addon of gMockAddons) {
gPrefs.setBoolPref(getKey(GMPScope.GMPPrefs.KEY_PLUGIN_FORCEVISIBLE, addon.id),
true);
}
yield GMPScope.GMPProvider.shutdown();
GMPScope.GMPProvider.startup();
});
add_task(function* test_cleanup() {

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

@ -47,11 +47,12 @@ function run_test() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
startupManager();
gPrefs.setBoolPref(GMPScope.KEY_LOGGING_DUMP, true);
gPrefs.setIntPref(GMPScope.KEY_LOGGING_LEVEL, 0);
gPrefs.setBoolPref(GMPScope.KEY_EME_ENABLED, true);
gPrefs.setBoolPref(GMPScope.GMPPrefs.KEY_LOGGING_DUMP, true);
gPrefs.setIntPref(GMPScope.GMPPrefs.KEY_LOGGING_LEVEL, 0);
gPrefs.setBoolPref(GMPScope.GMPPrefs.KEY_EME_ENABLED, true);
for (let addon of gMockAddons.values()) {
gPrefs.setBoolPref(gGetKey(GMPScope.KEY_PLUGIN_HIDDEN, addon.id), false);
gPrefs.setBoolPref(gGetKey(GMPScope.GMPPrefs.KEY_PLUGIN_FORCEVISIBLE, addon.id),
true);
}
GMPScope.GMPProvider.shutdown();
GMPScope.GMPProvider.startup();
@ -61,8 +62,8 @@ function run_test() {
add_task(function* test_notInstalled() {
for (let addon of gMockAddons.values()) {
gPrefs.setCharPref(gGetKey(GMPScope.KEY_PLUGIN_VERSION, addon.id), "");
gPrefs.setBoolPref(gGetKey(GMPScope.KEY_PLUGIN_ENABLED, addon.id), false);
gPrefs.setCharPref(gGetKey(GMPScope.GMPPrefs.KEY_PLUGIN_VERSION, addon.id), "");
gPrefs.setBoolPref(gGetKey(GMPScope.GMPPrefs.KEY_PLUGIN_ENABLED, addon.id), false);
}
let addons = yield promiseAddonsByIDs([...gMockAddons.keys()]);
@ -126,10 +127,10 @@ add_task(function* test_installed() {
let file = Services.dirsvc.get("ProfD", Ci.nsIFile);
file.append(addon.id);
file.append(TEST_VERSION);
gPrefs.setBoolPref(gGetKey(GMPScope.KEY_PLUGIN_ENABLED, mockAddon.id), false);
gPrefs.setCharPref(gGetKey(GMPScope.KEY_PLUGIN_LAST_UPDATE, mockAddon.id),
gPrefs.setBoolPref(gGetKey(GMPScope.GMPPrefs.KEY_PLUGIN_ENABLED, mockAddon.id), false);
gPrefs.setCharPref(gGetKey(GMPScope.GMPPrefs.KEY_PLUGIN_LAST_UPDATE, mockAddon.id),
"" + TEST_TIME_SEC);
gPrefs.setCharPref(gGetKey(GMPScope.KEY_PLUGIN_VERSION, mockAddon.id),
gPrefs.setCharPref(gGetKey(GMPScope.GMPPrefs.KEY_PLUGIN_VERSION, mockAddon.id),
TEST_VERSION);
Assert.ok(addon.isInstalled);
@ -165,7 +166,7 @@ add_task(function* test_enable() {
Assert.equal(addons.length, gMockAddons.size);
for (let addon of addons) {
gPrefs.setBoolPref(gGetKey(GMPScope.KEY_PLUGIN_ENABLED, addon.id), true);
gPrefs.setBoolPref(gGetKey(GMPScope.GMPPrefs.KEY_PLUGIN_ENABLED, addon.id), true);
Assert.ok(addon.isActive);
Assert.ok(!addon.appDisabled);
@ -180,7 +181,7 @@ add_task(function* test_globalEmeDisabled() {
let addons = yield promiseAddonsByIDs([...gMockEmeAddons.keys()]);
Assert.equal(addons.length, gMockEmeAddons.size);
gPrefs.setBoolPref(GMPScope.KEY_EME_ENABLED, false);
gPrefs.setBoolPref(GMPScope.GMPPrefs.KEY_EME_ENABLED, false);
GMPScope.GMPProvider.shutdown();
GMPScope.GMPProvider.startup();
for (let addon of addons) {
@ -190,7 +191,7 @@ add_task(function* test_globalEmeDisabled() {
Assert.equal(addon.permissions, 0);
}
gPrefs.setBoolPref(GMPScope.KEY_EME_ENABLED, true);
gPrefs.setBoolPref(GMPScope.GMPPrefs.KEY_EME_ENABLED, true);
GMPScope.GMPProvider.shutdown();
GMPScope.GMPProvider.startup();
});
@ -200,7 +201,7 @@ add_task(function* test_autoUpdatePrefPersistance() {
Assert.equal(addons.length, gMockAddons.size);
for (let addon of addons) {
let autoupdateKey = gGetKey(GMPScope.KEY_PLUGIN_AUTOUPDATE, addon.id);
let autoupdateKey = gGetKey(GMPScope.GMPPrefs.KEY_PLUGIN_AUTOUPDATE, addon.id);
gPrefs.clearUserPref(autoupdateKey);
addon.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DISABLE;
@ -233,10 +234,10 @@ add_task(function* test_pluginRegistration() {
};
GMPScope.gmpService = MockGMPService;
gPrefs.setBoolPref(gGetKey(GMPScope.KEY_PLUGIN_ENABLED, addon.id), true);
gPrefs.setBoolPref(gGetKey(GMPScope.GMPPrefs.KEY_PLUGIN_ENABLED, addon.id), true);
// Check that the plugin gets registered after startup.
gPrefs.setCharPref(gGetKey(GMPScope.KEY_PLUGIN_VERSION, addon.id),
gPrefs.setCharPref(gGetKey(GMPScope.GMPPrefs.KEY_PLUGIN_VERSION, addon.id),
TEST_VERSION);
clearPaths();
yield promiseRestartManager();
@ -245,7 +246,7 @@ add_task(function* test_pluginRegistration() {
// Check that clearing the version doesn't trigger registration.
clearPaths();
gPrefs.clearUserPref(gGetKey(GMPScope.KEY_PLUGIN_VERSION, addon.id));
gPrefs.clearUserPref(gGetKey(GMPScope.GMPPrefs.KEY_PLUGIN_VERSION, addon.id));
Assert.deepEqual(addedPaths, []);
Assert.deepEqual(removedPaths, [file.path]);
@ -256,23 +257,23 @@ add_task(function* test_pluginRegistration() {
Assert.equal(removedPaths.indexOf(file.path), -1);
// Changing the pref mid-session should cause unregistration and registration.
gPrefs.setCharPref(gGetKey(GMPScope.KEY_PLUGIN_VERSION, addon.id),
gPrefs.setCharPref(gGetKey(GMPScope.GMPPrefs.KEY_PLUGIN_VERSION, addon.id),
TEST_VERSION);
clearPaths();
const TEST_VERSION_2 = "5.6.7.8";
let file2 = Services.dirsvc.get("ProfD", Ci.nsIFile);
file2.append(addon.id);
file2.append(TEST_VERSION_2);
gPrefs.setCharPref(gGetKey(GMPScope.KEY_PLUGIN_VERSION, addon.id),
gPrefs.setCharPref(gGetKey(GMPScope.GMPPrefs.KEY_PLUGIN_VERSION, addon.id),
TEST_VERSION_2);
Assert.deepEqual(addedPaths, [file2.path]);
Assert.deepEqual(removedPaths, [file.path]);
// Disabling the plugin should cause unregistration.
gPrefs.setCharPref(gGetKey(GMPScope.KEY_PLUGIN_VERSION, addon.id),
gPrefs.setCharPref(gGetKey(GMPScope.GMPPrefs.KEY_PLUGIN_VERSION, addon.id),
TEST_VERSION);
clearPaths();
gPrefs.setBoolPref(gGetKey(GMPScope.KEY_PLUGIN_ENABLED, addon.id), false);
gPrefs.setBoolPref(gGetKey(GMPScope.GMPPrefs.KEY_PLUGIN_ENABLED, addon.id), false);
Assert.deepEqual(addedPaths, []);
Assert.deepEqual(removedPaths, [file.path]);
@ -284,7 +285,7 @@ add_task(function* test_pluginRegistration() {
// Re-enabling the plugin should cause registration.
clearPaths();
gPrefs.setBoolPref(gGetKey(GMPScope.KEY_PLUGIN_ENABLED, addon.id), true);
gPrefs.setBoolPref(gGetKey(GMPScope.GMPPrefs.KEY_PLUGIN_ENABLED, addon.id), true);
Assert.deepEqual(addedPaths, [file.path]);
Assert.deepEqual(removedPaths, []);
GMPScope = Cu.import("resource://gre/modules/addons/GMPProvider.jsm");
@ -303,21 +304,21 @@ add_task(function* test_periodicUpdate() {
Assert.equal(addons.length, gMockAddons.size);
for (let addon of addons) {
gPrefs.clearUserPref(gGetKey(GMPScope.KEY_PLUGIN_AUTOUPDATE, addon.id));
gPrefs.clearUserPref(gGetKey(GMPScope.GMPPrefs.KEY_PLUGIN_AUTOUPDATE, addon.id));
addon.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DISABLE;
gPrefs.setIntPref(GMPScope.KEY_PROVIDER_LASTCHECK, 0);
gPrefs.setIntPref(GMPScope.GMPPrefs.KEY_PROVIDER_LASTCHECK, 0);
let result =
yield addon.findUpdates({}, AddonManager.UPDATE_WHEN_PERIODIC_UPDATE);
Assert.strictEqual(result, false);
addon.applyBackgroundUpdates = AddonManager.AUTOUPDATE_ENABLE;
gPrefs.setIntPref(GMPScope.KEY_PROVIDER_LASTCHECK, Date.now() / 1000 - 60);
gPrefs.setIntPref(GMPScope.GMPPrefs.KEY_PROVIDER_LASTCHECK, Date.now() / 1000 - 60);
result =
yield addon.findUpdates({}, AddonManager.UPDATE_WHEN_PERIODIC_UPDATE);
Assert.strictEqual(result, false);
gPrefs.setIntPref(GMPScope.KEY_PROVIDER_LASTCHECK,
gPrefs.setIntPref(GMPScope.GMPPrefs.KEY_PROVIDER_LASTCHECK,
Date.now() / 1000 - 2 * GMPScope.SEC_IN_A_DAY);
gInstalledAddonId = "";
result =