mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1089867: Add tests for Adobe EME CDM download/install. r=gfritzsche
--HG-- rename : toolkit/mozapps/extensions/test/browser/browser_openH264.js => toolkit/mozapps/extensions/test/browser/browser_gmpProvider.js rename : toolkit/mozapps/extensions/test/xpcshell/test_openh264.js => toolkit/mozapps/extensions/test/xpcshell/test_gmpProvider.js
This commit is contained in:
parent
beadb8532a
commit
be6e3d806d
@ -15,17 +15,17 @@ Cu.import("resource://gre/modules/Preferences.jsm")
|
|||||||
do_get_profile();
|
do_get_profile();
|
||||||
|
|
||||||
function run_test() {Cu.import("resource://gre/modules/Preferences.jsm")
|
function run_test() {Cu.import("resource://gre/modules/Preferences.jsm")
|
||||||
Preferences.set("media.gmp-manager.log", true);
|
Preferences.set("media.gmp.log.dump", true);
|
||||||
|
Preferences.set("media.gmp.log.level", 0);
|
||||||
run_next_test();
|
run_next_test();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests that the helper used for preferences works correctly
|
* Tests that the helper used for preferences works correctly
|
||||||
*/
|
*/
|
||||||
add_test(function test_prefs() {
|
add_task(function* test_prefs() {
|
||||||
let addon1 = "addon1", addon2 = "addon2";
|
let addon1 = "addon1", addon2 = "addon2";
|
||||||
|
|
||||||
GMPPrefs.set(GMPPrefs.KEY_LOG_ENABLED, true);
|
|
||||||
GMPPrefs.set(GMPPrefs.KEY_URL, "http://not-really-used");
|
GMPPrefs.set(GMPPrefs.KEY_URL, "http://not-really-used");
|
||||||
GMPPrefs.set(GMPPrefs.KEY_URL_OVERRIDE, "http://not-really-used-2");
|
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_LAST_UPDATE, "1", addon1);
|
||||||
@ -35,41 +35,41 @@ add_test(function test_prefs() {
|
|||||||
GMPPrefs.set(GMPPrefs.KEY_ADDON_AUTOUPDATE, false, addon2);
|
GMPPrefs.set(GMPPrefs.KEY_ADDON_AUTOUPDATE, false, addon2);
|
||||||
GMPPrefs.set(GMPPrefs.KEY_CERT_CHECKATTRS, true);
|
GMPPrefs.set(GMPPrefs.KEY_CERT_CHECKATTRS, true);
|
||||||
|
|
||||||
do_check_true(GMPPrefs.get(GMPPrefs.KEY_LOG_ENABLED));
|
|
||||||
do_check_eq(GMPPrefs.get(GMPPrefs.KEY_URL), "http://not-really-used");
|
do_check_eq(GMPPrefs.get(GMPPrefs.KEY_URL), "http://not-really-used");
|
||||||
do_check_eq(GMPPrefs.get(GMPPrefs.KEY_URL_OVERRIDE), "http://not-really-used-2");
|
do_check_eq(GMPPrefs.get(GMPPrefs.KEY_URL_OVERRIDE),
|
||||||
do_check_eq(GMPPrefs.get(GMPPrefs.KEY_ADDON_LAST_UPDATE, addon1), "1");
|
"http://not-really-used-2");
|
||||||
do_check_eq(GMPPrefs.get(GMPPrefs.KEY_ADDON_VERSION, addon1), "2");
|
do_check_eq(GMPPrefs.get(GMPPrefs.KEY_ADDON_LAST_UPDATE, "", addon1), "1");
|
||||||
do_check_eq(GMPPrefs.get(GMPPrefs.KEY_ADDON_LAST_UPDATE, addon2), "3");
|
do_check_eq(GMPPrefs.get(GMPPrefs.KEY_ADDON_VERSION, "", addon1), "2");
|
||||||
do_check_eq(GMPPrefs.get(GMPPrefs.KEY_ADDON_VERSION, addon2), "4");
|
do_check_eq(GMPPrefs.get(GMPPrefs.KEY_ADDON_LAST_UPDATE, "", addon2), "3");
|
||||||
do_check_eq(GMPPrefs.get(GMPPrefs.KEY_ADDON_AUTOUPDATE, addon2), false);
|
do_check_eq(GMPPrefs.get(GMPPrefs.KEY_ADDON_VERSION, "", addon2), "4");
|
||||||
|
do_check_eq(GMPPrefs.get(GMPPrefs.KEY_ADDON_AUTOUPDATE, undefined, addon2),
|
||||||
|
false);
|
||||||
do_check_true(GMPPrefs.get(GMPPrefs.KEY_CERT_CHECKATTRS));
|
do_check_true(GMPPrefs.get(GMPPrefs.KEY_CERT_CHECKATTRS));
|
||||||
GMPPrefs.set(GMPPrefs.KEY_ADDON_AUTOUPDATE, true, addon2);
|
GMPPrefs.set(GMPPrefs.KEY_ADDON_AUTOUPDATE, true, addon2);
|
||||||
run_next_test();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests that an uninit without a check works fine
|
* Tests that an uninit without a check works fine
|
||||||
*/
|
*/
|
||||||
add_test(function test_checkForAddons_noResponse() {
|
add_task(function* test_checkForAddons_uninitWithoutCheck() {
|
||||||
let installManager = new GMPInstallManager();
|
let installManager = new GMPInstallManager();
|
||||||
installManager.uninit();
|
installManager.uninit();
|
||||||
run_next_test();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests that an uninit without an install works fine
|
* Tests that an uninit without an install works fine
|
||||||
*/
|
*/
|
||||||
add_test(function test_checkForAddons_noResponse() {
|
add_test(function test_checkForAddons_uninitWithoutInstall() {
|
||||||
overrideXHR(200, "");
|
overrideXHR(200, "");
|
||||||
let installManager = new GMPInstallManager();
|
let installManager = new GMPInstallManager();
|
||||||
let promise = installManager.checkForAddons();
|
let promise = installManager.checkForAddons();
|
||||||
promise.then(function(gmpAddons) {
|
promise.then(() => {
|
||||||
do_throw("no repsonse should reject");
|
do_throw("no response should reject");
|
||||||
}, function(err) {
|
}, err => {
|
||||||
installManager.uninit();
|
do_check_true(!!err);
|
||||||
|
installManager.uninit();
|
||||||
|
run_next_test();
|
||||||
});
|
});
|
||||||
run_next_test();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -79,9 +79,9 @@ add_test(function test_checkForAddons_noResponse() {
|
|||||||
overrideXHR(200, "");
|
overrideXHR(200, "");
|
||||||
let installManager = new GMPInstallManager();
|
let installManager = new GMPInstallManager();
|
||||||
let promise = installManager.checkForAddons();
|
let promise = installManager.checkForAddons();
|
||||||
promise.then(function(gmpAddons) {
|
promise.then(() => {
|
||||||
do_throw("no repsonse should reject");
|
do_throw("no response should reject");
|
||||||
}, function(err) {
|
}, err => {
|
||||||
do_check_true(!!err);
|
do_check_true(!!err);
|
||||||
installManager.uninit();
|
installManager.uninit();
|
||||||
run_next_test();
|
run_next_test();
|
||||||
@ -91,7 +91,7 @@ add_test(function test_checkForAddons_noResponse() {
|
|||||||
/**
|
/**
|
||||||
* Tests that no addons element returned resolves with no addons
|
* Tests that no addons element returned resolves with no addons
|
||||||
*/
|
*/
|
||||||
add_task(function test_checkForAddons_noAddonsElement() {
|
add_task(function* test_checkForAddons_noAddonsElement() {
|
||||||
overrideXHR(200, "<updates></updates>");
|
overrideXHR(200, "<updates></updates>");
|
||||||
let installManager = new GMPInstallManager();
|
let installManager = new GMPInstallManager();
|
||||||
let gmpAddons = yield installManager.checkForAddons();
|
let gmpAddons = yield installManager.checkForAddons();
|
||||||
@ -102,7 +102,7 @@ add_task(function test_checkForAddons_noAddonsElement() {
|
|||||||
/**
|
/**
|
||||||
* Tests that empty addons element returned resolves with no addons
|
* Tests that empty addons element returned resolves with no addons
|
||||||
*/
|
*/
|
||||||
add_task(function test_checkForAddons_noAddonsElement() {
|
add_task(function* test_checkForAddons_emptyAddonsElement() {
|
||||||
overrideXHR(200, "<updates><addons/></updates>");
|
overrideXHR(200, "<updates><addons/></updates>");
|
||||||
let installManager = new GMPInstallManager();
|
let installManager = new GMPInstallManager();
|
||||||
let gmpAddons = yield installManager.checkForAddons();
|
let gmpAddons = yield installManager.checkForAddons();
|
||||||
@ -117,16 +117,15 @@ add_test(function test_checkForAddons_wrongResponseXML() {
|
|||||||
overrideXHR(200, "<digits_of_pi>3.141592653589793....</digits_of_pi>");
|
overrideXHR(200, "<digits_of_pi>3.141592653589793....</digits_of_pi>");
|
||||||
let installManager = new GMPInstallManager();
|
let installManager = new GMPInstallManager();
|
||||||
let promise = installManager.checkForAddons();
|
let promise = installManager.checkForAddons();
|
||||||
promise.then(function(err, gmpAddons) {
|
promise.then(() => {
|
||||||
do_throw("response with the wrong root element should reject");
|
do_throw("response with the wrong root element should reject");
|
||||||
}, function(err) {
|
}, err => {
|
||||||
do_check_true(!!err);
|
do_check_true(!!err);
|
||||||
installManager.uninit();
|
installManager.uninit();
|
||||||
run_next_test();
|
run_next_test();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests that a 404 error works as expected
|
* Tests that a 404 error works as expected
|
||||||
*/
|
*/
|
||||||
@ -134,9 +133,9 @@ add_test(function test_checkForAddons_404Error() {
|
|||||||
overrideXHR(404, "");
|
overrideXHR(404, "");
|
||||||
let installManager = new GMPInstallManager();
|
let installManager = new GMPInstallManager();
|
||||||
let promise = installManager.checkForAddons();
|
let promise = installManager.checkForAddons();
|
||||||
promise.then(function(gmpAddons) {
|
promise.then(() => {
|
||||||
do_throw("404 response should reject");
|
do_throw("404 response should reject");
|
||||||
}, function(err) {
|
}, err => {
|
||||||
do_check_true(!!err);
|
do_check_true(!!err);
|
||||||
do_check_eq(err.status, 404);
|
do_check_eq(err.status, 404);
|
||||||
installManager.uninit();
|
installManager.uninit();
|
||||||
@ -152,9 +151,9 @@ add_test(function test_checkForAddons_abort() {
|
|||||||
let installManager = new GMPInstallManager();
|
let installManager = new GMPInstallManager();
|
||||||
let promise = installManager.checkForAddons();
|
let promise = installManager.checkForAddons();
|
||||||
xhr.abort();
|
xhr.abort();
|
||||||
promise.then(function() {
|
promise.then(() => {
|
||||||
do_throw("abort() should reject");
|
do_throw("abort() should reject");
|
||||||
}, function(err) {
|
}, err => {
|
||||||
do_check_eq(err.status, 0);
|
do_check_eq(err.status, 0);
|
||||||
installManager.uninit();
|
installManager.uninit();
|
||||||
run_next_test();
|
run_next_test();
|
||||||
@ -168,9 +167,9 @@ add_test(function test_checkForAddons_timeout() {
|
|||||||
overrideXHR(200, "", { dropRequest: true, timeout: true });
|
overrideXHR(200, "", { dropRequest: true, timeout: true });
|
||||||
let installManager = new GMPInstallManager();
|
let installManager = new GMPInstallManager();
|
||||||
let promise = installManager.checkForAddons();
|
let promise = installManager.checkForAddons();
|
||||||
promise.then(function() {
|
promise.then(() => {
|
||||||
do_throw("Defensive timeout should reject");
|
do_throw("Defensive timeout should reject");
|
||||||
}, function(err) {
|
}, err => {
|
||||||
do_check_eq(err.status, 0);
|
do_check_eq(err.status, 0);
|
||||||
installManager.uninit();
|
installManager.uninit();
|
||||||
run_next_test();
|
run_next_test();
|
||||||
@ -197,10 +196,11 @@ add_test(function test_checkForAddons_bad_ssl() {
|
|||||||
overrideXHR(200, "");
|
overrideXHR(200, "");
|
||||||
let installManager = new GMPInstallManager();
|
let installManager = new GMPInstallManager();
|
||||||
let promise = installManager.checkForAddons();
|
let promise = installManager.checkForAddons();
|
||||||
promise.then(function() {
|
promise.then(() => {
|
||||||
do_throw("Defensive timeout should reject");
|
do_throw("Defensive timeout should reject");
|
||||||
}, function(err) {
|
}, err => {
|
||||||
do_check_true(err.message.contains("SSL is required and URI scheme is not https."));
|
do_check_true(err.message.contains("SSL is required and URI scheme is " +
|
||||||
|
"not https."));
|
||||||
installManager.uninit();
|
installManager.uninit();
|
||||||
if (PREF_KEY_URL_OVERRIDE_BACKUP) {
|
if (PREF_KEY_URL_OVERRIDE_BACKUP) {
|
||||||
Preferences.set(GMPPrefs.KEY_URL_OVERRIDE,
|
Preferences.set(GMPPrefs.KEY_URL_OVERRIDE,
|
||||||
@ -221,9 +221,9 @@ add_test(function test_checkForAddons_notXML() {
|
|||||||
overrideXHR(200, "3.141592653589793....");
|
overrideXHR(200, "3.141592653589793....");
|
||||||
let installManager = new GMPInstallManager();
|
let installManager = new GMPInstallManager();
|
||||||
let promise = installManager.checkForAddons();
|
let promise = installManager.checkForAddons();
|
||||||
promise.then(function(gmpAddons) {
|
promise.then(() => {
|
||||||
do_throw("non XML response should reject");
|
do_throw("non XML response should reject");
|
||||||
}, function(err) {
|
}, err => {
|
||||||
do_check_true(!!err);
|
do_check_true(!!err);
|
||||||
installManager.uninit();
|
installManager.uninit();
|
||||||
run_next_test();
|
run_next_test();
|
||||||
@ -233,7 +233,7 @@ add_test(function test_checkForAddons_notXML() {
|
|||||||
/**
|
/**
|
||||||
* Tests that getting a response with a single addon works as expected
|
* Tests that getting a response with a single addon works as expected
|
||||||
*/
|
*/
|
||||||
add_test(function test_checkForAddons_singleAddonNoUpdates() {
|
add_task(function* test_checkForAddons_singleAddon() {
|
||||||
let responseXML =
|
let responseXML =
|
||||||
"<?xml version=\"1.0\"?>" +
|
"<?xml version=\"1.0\"?>" +
|
||||||
"<updates>" +
|
"<updates>" +
|
||||||
@ -247,31 +247,25 @@ add_test(function test_checkForAddons_singleAddonNoUpdates() {
|
|||||||
"</updates>"
|
"</updates>"
|
||||||
overrideXHR(200, responseXML);
|
overrideXHR(200, responseXML);
|
||||||
let installManager = new GMPInstallManager();
|
let installManager = new GMPInstallManager();
|
||||||
let promise = installManager.checkForAddons();
|
let gmpAddons = yield installManager.checkForAddons();
|
||||||
promise.then(function(gmpAddons) {
|
do_check_eq(gmpAddons.length, 1);
|
||||||
do_check_eq(gmpAddons.length, 1);
|
let gmpAddon= gmpAddons[0];
|
||||||
let gmpAddon= gmpAddons[0];
|
do_check_eq(gmpAddon.id, "gmp-gmpopenh264");
|
||||||
do_check_eq(gmpAddon.id, "gmp-gmpopenh264");
|
do_check_eq(gmpAddon.URL, "http://127.0.0.1:8011/gmp-gmpopenh264-1.1.zip");
|
||||||
do_check_eq(gmpAddon.URL, "http://127.0.0.1:8011/gmp-gmpopenh264-1.1.zip");
|
do_check_eq(gmpAddon.hashFunction, "sha256");
|
||||||
do_check_eq(gmpAddon.hashFunction, "sha256");
|
do_check_eq(gmpAddon.hashValue, "1118b90d6f645eefc2b99af17bae396636ace1e33d079c88de715177584e2aee");
|
||||||
do_check_eq(gmpAddon.hashValue, "1118b90d6f645eefc2b99af17bae396636ace1e33d079c88de715177584e2aee");
|
do_check_eq(gmpAddon.version, "1.1");
|
||||||
do_check_eq(gmpAddon.version, "1.1");
|
do_check_eq(gmpAddon.size, undefined);
|
||||||
do_check_eq(gmpAddon.size, undefined);
|
do_check_true(gmpAddon.isValid);
|
||||||
do_check_true(gmpAddon.isValid);
|
do_check_false(gmpAddon.isInstalled);
|
||||||
do_check_true(gmpAddon.isOpenH264);
|
installManager.uninit();
|
||||||
do_check_false(gmpAddon.isInstalled);
|
|
||||||
installManager.uninit();
|
|
||||||
run_next_test();
|
|
||||||
}, function(err) {
|
|
||||||
do_throw("1 addon found should not reject");
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests that getting a response with a single addon with the optional size
|
* Tests that getting a response with a single addon with the optional size
|
||||||
* attribute parses as expected.
|
* attribute parses as expected.
|
||||||
*/
|
*/
|
||||||
add_test(function test_checkForAddons_singleAddonNoUpdates() {
|
add_task(function* test_checkForAddons_singleAddonWithSize() {
|
||||||
let responseXML =
|
let responseXML =
|
||||||
"<?xml version=\"1.0\"?>" +
|
"<?xml version=\"1.0\"?>" +
|
||||||
"<updates>" +
|
"<updates>" +
|
||||||
@ -286,31 +280,25 @@ add_test(function test_checkForAddons_singleAddonNoUpdates() {
|
|||||||
"</updates>"
|
"</updates>"
|
||||||
overrideXHR(200, responseXML);
|
overrideXHR(200, responseXML);
|
||||||
let installManager = new GMPInstallManager();
|
let installManager = new GMPInstallManager();
|
||||||
let promise = installManager.checkForAddons();
|
let gmpAddons = yield installManager.checkForAddons();
|
||||||
promise.then(function(gmpAddons) {
|
do_check_eq(gmpAddons.length, 1);
|
||||||
do_check_eq(gmpAddons.length, 1);
|
let gmpAddon = gmpAddons[0];
|
||||||
let gmpAddon= gmpAddons[0];
|
do_check_eq(gmpAddon.id, "openh264-plugin-no-at-symbol");
|
||||||
do_check_eq(gmpAddon.id, "openh264-plugin-no-at-symbol");
|
do_check_eq(gmpAddon.URL, "http://127.0.0.1:8011/gmp-gmpopenh264-1.1.zip");
|
||||||
do_check_eq(gmpAddon.URL, "http://127.0.0.1:8011/gmp-gmpopenh264-1.1.zip");
|
do_check_eq(gmpAddon.hashFunction, "sha256");
|
||||||
do_check_eq(gmpAddon.hashFunction, "sha256");
|
do_check_eq(gmpAddon.hashValue, "1118b90d6f645eefc2b99af17bae396636ace1e33d079c88de715177584e2aee");
|
||||||
do_check_eq(gmpAddon.hashValue, "1118b90d6f645eefc2b99af17bae396636ace1e33d079c88de715177584e2aee");
|
do_check_eq(gmpAddon.size, 42);
|
||||||
do_check_eq(gmpAddon.size, 42);
|
do_check_eq(gmpAddon.version, "1.1");
|
||||||
do_check_eq(gmpAddon.version, "1.1");
|
do_check_true(gmpAddon.isValid);
|
||||||
do_check_true(gmpAddon.isValid);
|
do_check_false(gmpAddon.isInstalled);
|
||||||
do_check_false(gmpAddon.isOpenH264);
|
installManager.uninit();
|
||||||
do_check_false(gmpAddon.isInstalled);
|
|
||||||
installManager.uninit();
|
|
||||||
run_next_test();
|
|
||||||
}, function(err) {
|
|
||||||
do_throw("1 addon found should not reject");
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests that checking for multiple addons work correctly.
|
* Tests that checking for multiple addons work correctly.
|
||||||
* Also tests that invalid addons work correctly.
|
* Also tests that invalid addons work correctly.
|
||||||
*/
|
*/
|
||||||
add_test(function test_checkForAddons_multipleAddonNoUpdatesSomeInvalid() {
|
add_task(function* test_checkForAddons_multipleAddonNoUpdatesSomeInvalid() {
|
||||||
let responseXML =
|
let responseXML =
|
||||||
"<?xml version=\"1.0\"?>" +
|
"<?xml version=\"1.0\"?>" +
|
||||||
"<updates>" +
|
"<updates>" +
|
||||||
@ -361,45 +349,38 @@ add_test(function test_checkForAddons_multipleAddonNoUpdatesSomeInvalid() {
|
|||||||
"</updates>"
|
"</updates>"
|
||||||
overrideXHR(200, responseXML);
|
overrideXHR(200, responseXML);
|
||||||
let installManager = new GMPInstallManager();
|
let installManager = new GMPInstallManager();
|
||||||
let promise = installManager.checkForAddons();
|
let gmpAddons = yield installManager.checkForAddons();
|
||||||
promise.then(function(gmpAddons) {
|
do_check_eq(gmpAddons.length, 7);
|
||||||
do_check_eq(gmpAddons.length, 7);
|
let gmpAddon= gmpAddons[0];
|
||||||
let gmpAddon= gmpAddons[0];
|
do_check_eq(gmpAddon.id, "gmp-gmpopenh264");
|
||||||
do_check_eq(gmpAddon.id, "gmp-gmpopenh264");
|
do_check_eq(gmpAddon.URL, "http://127.0.0.1:8011/gmp-gmpopenh264-1.1.zip");
|
||||||
do_check_eq(gmpAddon.URL, "http://127.0.0.1:8011/gmp-gmpopenh264-1.1.zip");
|
do_check_eq(gmpAddon.hashFunction, "sha256");
|
||||||
do_check_eq(gmpAddon.hashFunction, "sha256");
|
do_check_eq(gmpAddon.hashValue, "1118b90d6f645eefc2b99af17bae396636ace1e33d079c88de715177584e2aee");
|
||||||
do_check_eq(gmpAddon.hashValue, "1118b90d6f645eefc2b99af17bae396636ace1e33d079c88de715177584e2aee");
|
do_check_eq(gmpAddon.version, "1.1");
|
||||||
do_check_eq(gmpAddon.version, "1.1");
|
do_check_true(gmpAddon.isValid);
|
||||||
do_check_true(gmpAddon.isValid);
|
do_check_false(gmpAddon.isInstalled);
|
||||||
do_check_true(gmpAddon.isOpenH264);
|
|
||||||
do_check_false(gmpAddon.isInstalled);
|
|
||||||
|
|
||||||
gmpAddon= gmpAddons[1];
|
gmpAddon= gmpAddons[1];
|
||||||
do_check_eq(gmpAddon.id, "NOT-gmp-gmpopenh264");
|
do_check_eq(gmpAddon.id, "NOT-gmp-gmpopenh264");
|
||||||
do_check_eq(gmpAddon.URL, "http://127.0.0.1:8011/NOT-gmp-gmpopenh264-1.1.zip");
|
do_check_eq(gmpAddon.URL, "http://127.0.0.1:8011/NOT-gmp-gmpopenh264-1.1.zip");
|
||||||
do_check_eq(gmpAddon.hashFunction, "sha512");
|
do_check_eq(gmpAddon.hashFunction, "sha512");
|
||||||
do_check_eq(gmpAddon.hashValue, "141592656f645eefc2b99af17bae396636ace1e33d079c88de715177584e2aee");
|
do_check_eq(gmpAddon.hashValue, "141592656f645eefc2b99af17bae396636ace1e33d079c88de715177584e2aee");
|
||||||
do_check_eq(gmpAddon.version, "9.1");
|
do_check_eq(gmpAddon.version, "9.1");
|
||||||
do_check_true(gmpAddon.isValid);
|
do_check_true(gmpAddon.isValid);
|
||||||
do_check_false(gmpAddon.isOpenH264);
|
do_check_false(gmpAddon.isInstalled);
|
||||||
do_check_false(gmpAddon.isInstalled);
|
|
||||||
|
|
||||||
for (let i = 2; i < gmpAddons.length; i++) {
|
for (let i = 2; i < gmpAddons.length; i++) {
|
||||||
do_check_false(gmpAddons[i].isValid);
|
do_check_false(gmpAddons[i].isValid);
|
||||||
do_check_false(gmpAddons[i].isInstalled);
|
do_check_false(gmpAddons[i].isInstalled);
|
||||||
}
|
}
|
||||||
installManager.uninit();
|
installManager.uninit();
|
||||||
run_next_test();
|
|
||||||
}, function(err) {
|
|
||||||
do_throw("multiple addons found should not reject");
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests that checking for addons when there are also updates available
|
* Tests that checking for addons when there are also updates available
|
||||||
* works as expected.
|
* works as expected.
|
||||||
*/
|
*/
|
||||||
add_test(function test_checkForAddons_updatesWithAddons() {
|
add_task(function* test_checkForAddons_updatesWithAddons() {
|
||||||
let responseXML =
|
let responseXML =
|
||||||
"<?xml version=\"1.0\"?>" +
|
"<?xml version=\"1.0\"?>" +
|
||||||
" <updates>" +
|
" <updates>" +
|
||||||
@ -416,30 +397,25 @@ add_test(function test_checkForAddons_updatesWithAddons() {
|
|||||||
"</updates>"
|
"</updates>"
|
||||||
overrideXHR(200, responseXML);
|
overrideXHR(200, responseXML);
|
||||||
let installManager = new GMPInstallManager();
|
let installManager = new GMPInstallManager();
|
||||||
let promise = installManager.checkForAddons();
|
let gmpAddons = yield installManager.checkForAddons();
|
||||||
promise.then(function(gmpAddons) {
|
do_check_eq(gmpAddons.length, 1);
|
||||||
do_check_eq(gmpAddons.length, 1);
|
let gmpAddon= gmpAddons[0];
|
||||||
let gmpAddon= gmpAddons[0];
|
do_check_eq(gmpAddon.id, "gmp-gmpopenh264");
|
||||||
do_check_eq(gmpAddon.id, "gmp-gmpopenh264");
|
do_check_eq(gmpAddon.URL, "http://127.0.0.1:8011/gmp-gmpopenh264-1.1.zip");
|
||||||
do_check_eq(gmpAddon.URL, "http://127.0.0.1:8011/gmp-gmpopenh264-1.1.zip");
|
do_check_eq(gmpAddon.hashFunction, "sha256");
|
||||||
do_check_eq(gmpAddon.hashFunction, "sha256");
|
do_check_eq(gmpAddon.hashValue, "1118b90d6f645eefc2b99af17bae396636ace1e33d079c88de715177584e2aee");
|
||||||
do_check_eq(gmpAddon.hashValue, "1118b90d6f645eefc2b99af17bae396636ace1e33d079c88de715177584e2aee");
|
do_check_eq(gmpAddon.version, "1.1");
|
||||||
do_check_eq(gmpAddon.version, "1.1");
|
do_check_true(gmpAddon.isValid);
|
||||||
do_check_true(gmpAddon.isValid);
|
do_check_false(gmpAddon.isInstalled);
|
||||||
do_check_true(gmpAddon.isOpenH264);
|
installManager.uninit();
|
||||||
do_check_false(gmpAddon.isInstalled);
|
|
||||||
installManager.uninit();
|
|
||||||
run_next_test();
|
|
||||||
}, function(err) {
|
|
||||||
do_throw("updates with addons should not reject");
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests that installing found addons works as expected
|
* Tests that installing found addons works as expected
|
||||||
*/
|
*/
|
||||||
function test_checkForAddons_installAddon(id, includeSize,wantInstallReject) {
|
function* test_checkForAddons_installAddon(id, includeSize, wantInstallReject) {
|
||||||
do_print("Running installAddon for includeSize: " + includeSize +
|
do_print("Running installAddon for id: " + id +
|
||||||
|
", includeSize: " + includeSize +
|
||||||
" and wantInstallReject: " + wantInstallReject);
|
" and wantInstallReject: " + wantInstallReject);
|
||||||
let httpServer = new HttpServer();
|
let httpServer = new HttpServer();
|
||||||
let dir = FileUtils.getDir("TmpD", [], true);
|
let dir = FileUtils.getDir("TmpD", [], true);
|
||||||
@ -455,10 +431,9 @@ function test_checkForAddons_installAddon(id, includeSize,wantInstallReject) {
|
|||||||
let zipFile = createNewZipFile(zipFileName, data);
|
let zipFile = createNewZipFile(zipFileName, data);
|
||||||
let hashFunc = "sha256";
|
let hashFunc = "sha256";
|
||||||
let expectedDigest = yield GMPDownloader.computeHash(hashFunc, zipFile);
|
let expectedDigest = yield GMPDownloader.computeHash(hashFunc, zipFile);
|
||||||
|
let fileSize = zipFile.fileSize;
|
||||||
let fileSize = zipFile.size;
|
|
||||||
if (wantInstallReject) {
|
if (wantInstallReject) {
|
||||||
fileSize = 1;
|
fileSize = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
let responseXML =
|
let responseXML =
|
||||||
@ -476,67 +451,63 @@ function test_checkForAddons_installAddon(id, includeSize,wantInstallReject) {
|
|||||||
|
|
||||||
overrideXHR(200, responseXML);
|
overrideXHR(200, responseXML);
|
||||||
let installManager = new GMPInstallManager();
|
let installManager = new GMPInstallManager();
|
||||||
let checkPromise = installManager.checkForAddons();
|
let gmpAddons = yield installManager.checkForAddons();
|
||||||
checkPromise.then(function(gmpAddons) {
|
do_check_eq(gmpAddons.length, 1);
|
||||||
do_check_eq(gmpAddons.length, 1);
|
let gmpAddon = gmpAddons[0];
|
||||||
let gmpAddon = gmpAddons[0];
|
do_check_false(gmpAddon.isInstalled);
|
||||||
do_check_false(gmpAddon.isInstalled);
|
|
||||||
|
|
||||||
GMPInstallManager.overrideLeaveDownloadedZip = true;
|
GMPInstallManager.overrideLeaveDownloadedZip = true;
|
||||||
let installPromise = installManager.installAddon(gmpAddon);
|
try {
|
||||||
installPromise.then(function(extractedPaths) {
|
let extractedPaths = yield installManager.installAddon(gmpAddon);
|
||||||
if (wantInstallReject) {
|
if (wantInstallReject) {
|
||||||
do_throw("install update should reject");
|
do_check_true(false); // installAddon() should have thrown.
|
||||||
}
|
}
|
||||||
do_check_eq(extractedPaths.length, 1);
|
do_check_eq(extractedPaths.length, 1);
|
||||||
let extractedPath = extractedPaths[0];
|
let extractedPath = extractedPaths[0];
|
||||||
|
|
||||||
do_print("Extracted path: " + extractedPath);
|
do_print("Extracted path: " + extractedPath);
|
||||||
|
|
||||||
let extractedFile = Cc["@mozilla.org/file/local;1"].
|
let extractedFile = Cc["@mozilla.org/file/local;1"].
|
||||||
createInstance(Ci.nsIFile);
|
createInstance(Ci.nsIFile);
|
||||||
extractedFile.initWithPath(extractedPath);
|
extractedFile.initWithPath(extractedPath);
|
||||||
do_check_true(extractedFile.exists());
|
do_check_true(extractedFile.exists());
|
||||||
let readData = readStringFromFile(extractedFile);
|
let readData = readStringFromFile(extractedFile);
|
||||||
do_check_eq(readData, data);
|
do_check_eq(readData, data);
|
||||||
|
|
||||||
// Check that the downloaded zip matches the offered zip exactly
|
// Check that the downloaded zip matches the offered zip exactly
|
||||||
let downloadedGMPFile = FileUtils.getFile("TmpD",
|
let downloadedGMPFile = FileUtils.getFile("TmpD",
|
||||||
[gmpAddon.id + ".zip"]);
|
[gmpAddon.id + ".zip"]);
|
||||||
do_check_true(downloadedGMPFile.exists());
|
do_check_true(downloadedGMPFile.exists());
|
||||||
let downloadedBytes = getBinaryFileData(downloadedGMPFile);
|
let downloadedBytes = getBinaryFileData(downloadedGMPFile);
|
||||||
let sourceBytes = getBinaryFileData(zipFile);
|
let sourceBytes = getBinaryFileData(zipFile);
|
||||||
do_check_true(compareBinaryData(downloadedBytes, sourceBytes));
|
do_check_true(compareBinaryData(downloadedBytes, sourceBytes));
|
||||||
|
|
||||||
// Make sure the prefs are set correctly
|
// Make sure the prefs are set correctly
|
||||||
do_check_true(!!GMPPrefs.get(GMPPrefs.KEY_ADDON_LAST_UPDATE,
|
do_check_true(!!GMPPrefs.get(GMPPrefs.KEY_ADDON_LAST_UPDATE, "",
|
||||||
gmpAddon.id, ""));
|
gmpAddon.id));
|
||||||
do_check_eq(GMPPrefs.get(GMPPrefs.KEY_ADDON_VERSION, gmpAddon.id, ""),
|
do_check_eq(GMPPrefs.get(GMPPrefs.KEY_ADDON_VERSION, "", gmpAddon.id),
|
||||||
"1.1");
|
"1.1");
|
||||||
// Make sure it reports as being installed
|
// Make sure it reports as being installed
|
||||||
do_check_true(gmpAddon.isInstalled);
|
do_check_true(gmpAddon.isInstalled);
|
||||||
|
|
||||||
// Cleanup
|
// Cleanup
|
||||||
extractedFile.parent.remove(true);
|
extractedFile.parent.remove(true);
|
||||||
zipFile.remove(false);
|
zipFile.remove(false);
|
||||||
httpServer.stop(function() {});
|
httpServer.stop(function() {});
|
||||||
do_print("Removing downloaded GMP file: " + downloadedGMPFile.path);
|
do_print("Removing downloaded GMP file: " + downloadedGMPFile.path);
|
||||||
downloadedGMPFile.remove(false);
|
downloadedGMPFile.remove(false);
|
||||||
installManager.uninit();
|
installManager.uninit();
|
||||||
}, function(err) {
|
} catch(ex) {
|
||||||
zipFile.remove(false);
|
zipFile.remove(false);
|
||||||
let downloadedGMPFile = FileUtils.getFile("TmpD",
|
let downloadedGMPFile = FileUtils.getFile("TmpD",
|
||||||
[gmpAddon.id + ".zip"]);
|
[gmpAddon.id + ".zip"]);
|
||||||
do_print("Removing from err downloaded GMP file: " +
|
do_print("Removing downloaded GMP file from exception handler: " +
|
||||||
downloadedGMPFile.path);
|
downloadedGMPFile.path);
|
||||||
downloadedGMPFile.remove(false);
|
downloadedGMPFile.remove(false);
|
||||||
if (!wantInstallReject) {
|
if (!wantInstallReject) {
|
||||||
do_throw("install update should not reject");
|
do_throw("install update should not reject");
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}, function(err) {
|
|
||||||
do_throw("checking updates to install them should not reject");
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
add_task(test_checkForAddons_installAddon.bind(null, "1", true, false));
|
add_task(test_checkForAddons_installAddon.bind(null, "1", true, false));
|
||||||
@ -544,45 +515,59 @@ add_task(test_checkForAddons_installAddon.bind(null, "2", false, false));
|
|||||||
add_task(test_checkForAddons_installAddon.bind(null, "3", true, true));
|
add_task(test_checkForAddons_installAddon.bind(null, "3", true, true));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests simpleCheckAndInstall autoupdate disabled
|
* Tests simpleCheckAndInstall when autoupdate is disabled for a GMP
|
||||||
*/
|
*/
|
||||||
add_task(function test_simpleCheckAndInstall() {
|
add_task(function* test_simpleCheckAndInstall_autoUpdateDisabled() {
|
||||||
GMPPrefs.set(GMPPrefs.KEY_ADDON_AUTOUPDATE, false, OPEN_H264_ID);
|
GMPPrefs.set(GMPPrefs.KEY_ADDON_AUTOUPDATE, false, OPEN_H264_ID);
|
||||||
let installManager = new GMPInstallManager();
|
let responseXML =
|
||||||
let promise = installManager.simpleCheckAndInstall();
|
"<?xml version=\"1.0\"?>" +
|
||||||
promise.then((result) => {
|
"<updates>" +
|
||||||
do_check_eq(result.status, "check-disabled");
|
" <addons>" +
|
||||||
}, () => {
|
// valid openh264
|
||||||
do_throw("simple check should not reject");
|
" <addon id=\"gmp-gmpopenh264\"" +
|
||||||
});
|
" URL=\"http://127.0.0.1:8011/gmp-gmpopenh264-1.1.zip\"" +
|
||||||
|
" hashFunction=\"sha256\"" +
|
||||||
|
" hashValue=\"1118b90d6f645eefc2b99af17bae396636ace1e33d079c88de715177584e2aee\"" +
|
||||||
|
" version=\"1.1\"/>" +
|
||||||
|
" </addons>" +
|
||||||
|
"</updates>"
|
||||||
|
|
||||||
|
overrideXHR(200, responseXML);
|
||||||
|
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);
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests simpleCheckAndInstall nothing to install
|
* Tests simpleCheckAndInstall nothing to install
|
||||||
*/
|
*/
|
||||||
add_task(function test_simpleCheckAndInstall() {
|
add_task(function* test_simpleCheckAndInstall_nothingToInstall() {
|
||||||
GMPPrefs.set(GMPPrefs.KEY_ADDON_AUTOUPDATE, true, OPEN_H264_ID);
|
let responseXML =
|
||||||
let installManager = new GMPInstallManager();
|
"<?xml version=\"1.0\"?>" +
|
||||||
let promise = installManager.simpleCheckAndInstall();
|
"<updates>" +
|
||||||
promise.then((result) => {
|
"</updates>"
|
||||||
do_check_eq(result.status, "nothing-new-to-install");
|
|
||||||
}, () => {
|
overrideXHR(200, responseXML);
|
||||||
do_throw("simple check should not reject");
|
let installManager = new GMPInstallManager();
|
||||||
});
|
let result = yield installManager.simpleCheckAndInstall();
|
||||||
|
do_check_eq(result.status, "nothing-new-to-install");
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests simpleCheckAndInstall too frequent
|
* Tests simpleCheckAndInstall too frequent
|
||||||
*/
|
*/
|
||||||
add_task(function test_simpleCheckAndInstall() {
|
add_task(function* test_simpleCheckAndInstall_tooFrequent() {
|
||||||
GMPPrefs.set(GMPPrefs.KEY_ADDON_AUTOUPDATE, true, OPEN_H264_ID);
|
let responseXML =
|
||||||
let installManager = new GMPInstallManager();
|
"<?xml version=\"1.0\"?>" +
|
||||||
let promise = installManager.simpleCheckAndInstall();
|
"<updates>" +
|
||||||
promise.then((result) => {
|
"</updates>"
|
||||||
do_check_eq(result.status, "too-frequent-no-check");
|
|
||||||
}, () => {
|
overrideXHR(200, responseXML);
|
||||||
do_throw("simple check should not reject");
|
let installManager = new GMPInstallManager();
|
||||||
});
|
let result = yield installManager.simpleCheckAndInstall();
|
||||||
|
do_check_eq(result.status, "too-frequent-no-check");
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -611,21 +596,21 @@ add_test(function test_installAddon_noServer() {
|
|||||||
overrideXHR(200, responseXML);
|
overrideXHR(200, responseXML);
|
||||||
let installManager = new GMPInstallManager();
|
let installManager = new GMPInstallManager();
|
||||||
let checkPromise = installManager.checkForAddons();
|
let checkPromise = installManager.checkForAddons();
|
||||||
checkPromise.then(function(gmpAddons) {
|
checkPromise.then(gmpAddons => {
|
||||||
do_check_eq(gmpAddons.length, 1);
|
do_check_eq(gmpAddons.length, 1);
|
||||||
let gmpAddon= gmpAddons[0];
|
let gmpAddon= gmpAddons[0];
|
||||||
|
|
||||||
GMPInstallManager.overrideLeaveDownloadedZip = true;
|
GMPInstallManager.overrideLeaveDownloadedZip = true;
|
||||||
let installPromise = installManager.installAddon(gmpAddon);
|
let installPromise = installManager.installAddon(gmpAddon);
|
||||||
installPromise.then(function(extractedPaths) {
|
installPromise.then(extractedPaths => {
|
||||||
do_throw("No server for install should reject");
|
do_throw("No server for install should reject");
|
||||||
}, function(err) {
|
}, err => {
|
||||||
do_check_true(!!err);
|
do_check_true(!!err);
|
||||||
installManager.uninit();
|
installManager.uninit();
|
||||||
run_next_test();
|
run_next_test();
|
||||||
});
|
});
|
||||||
}, function(err) {
|
}, () => {
|
||||||
do_throw("check should not reject for installn o server");
|
do_throw("check should not reject for install no server");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -40,11 +40,11 @@ skip-if = e10s
|
|||||||
[browser_bug616841.js]
|
[browser_bug616841.js]
|
||||||
[browser_cancelCompatCheck.js]
|
[browser_cancelCompatCheck.js]
|
||||||
[browser_checkAddonCompatibility.js]
|
[browser_checkAddonCompatibility.js]
|
||||||
|
[browser_gmpProvider.js]
|
||||||
[browser_hotfix.js]
|
[browser_hotfix.js]
|
||||||
[browser_installssl.js]
|
[browser_installssl.js]
|
||||||
[browser_newaddon.js]
|
[browser_newaddon.js]
|
||||||
skip-if = e10s
|
skip-if = e10s
|
||||||
[browser_openH264.js]
|
|
||||||
[browser_select_compatoverrides.js]
|
[browser_select_compatoverrides.js]
|
||||||
[browser_select_confirm.js]
|
[browser_select_confirm.js]
|
||||||
[browser_select_selection.js]
|
[browser_select_selection.js]
|
||||||
|
392
toolkit/mozapps/extensions/test/browser/browser_gmpProvider.js
Normal file
392
toolkit/mozapps/extensions/test/browser/browser_gmpProvider.js
Normal file
@ -0,0 +1,392 @@
|
|||||||
|
/* Any copyright is dedicated to the Public Domain.
|
||||||
|
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||||
|
*/
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
Cu.import("resource://gre/modules/Promise.jsm");
|
||||||
|
let {AddonTestUtils} = Cu.import("resource://testing-common/AddonManagerTesting.jsm", {});
|
||||||
|
let GMPScope = Cu.import("resource://gre/modules/addons/GMPProvider.jsm");
|
||||||
|
|
||||||
|
const TEST_DATE = new Date(2013, 0, 1, 12);
|
||||||
|
|
||||||
|
let gManagerWindow;
|
||||||
|
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,
|
||||||
|
});
|
||||||
|
gMockAddons.push(mockAddon);
|
||||||
|
if (mockAddon.id.indexOf("gmp-eme-") == 0) {
|
||||||
|
gMockEmeAddons.push(mockAddon);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let gInstalledAddonId = "";
|
||||||
|
let gInstallDeferred = null;
|
||||||
|
let gPrefs = Services.prefs;
|
||||||
|
let getKey = GMPScope.GMPPrefs.getPrefKey;
|
||||||
|
|
||||||
|
function MockGMPInstallManager() {
|
||||||
|
}
|
||||||
|
|
||||||
|
MockGMPInstallManager.prototype = {
|
||||||
|
checkForAddons: () => Promise.resolve(gMockAddons),
|
||||||
|
|
||||||
|
installAddon: addon => {
|
||||||
|
gInstalledAddonId = addon.id;
|
||||||
|
gInstallDeferred.resolve();
|
||||||
|
return Promise.resolve();
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
let gOptionsObserver = {
|
||||||
|
lastDisplayed: null,
|
||||||
|
observe: function(aSubject, aTopic, aData) {
|
||||||
|
if (aTopic == AddonManager.OPTIONS_NOTIFICATION_DISPLAYED) {
|
||||||
|
this.lastDisplayed = aData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function getInstallItem() {
|
||||||
|
let doc = gManagerWindow.document;
|
||||||
|
let list = doc.getElementById("addon-list");
|
||||||
|
|
||||||
|
let node = list.firstChild;
|
||||||
|
while (node) {
|
||||||
|
if (node.getAttribute("status") == "installing") {
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
node = node.nextSibling;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function openDetailsView(aId) {
|
||||||
|
let item = get_addon_element(gManagerWindow, aId);
|
||||||
|
Assert.ok(item, "Should have got add-on element.");
|
||||||
|
is_element_visible(item, "Add-on element should be visible.");
|
||||||
|
|
||||||
|
EventUtils.synthesizeMouseAtCenter(item, { clickCount: 1 }, gManagerWindow);
|
||||||
|
EventUtils.synthesizeMouseAtCenter(item, { clickCount: 2 }, gManagerWindow);
|
||||||
|
|
||||||
|
let deferred = Promise.defer();
|
||||||
|
wait_for_view_load(gManagerWindow, deferred.resolve);
|
||||||
|
return deferred.promise;
|
||||||
|
}
|
||||||
|
|
||||||
|
add_task(function* initializeState() {
|
||||||
|
gPrefs.setBoolPref(GMPScope.KEY_LOGGING_DUMP, true);
|
||||||
|
gPrefs.setIntPref(GMPScope.KEY_LOGGING_LEVEL, 0);
|
||||||
|
|
||||||
|
gManagerWindow = yield open_manager();
|
||||||
|
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||||
|
|
||||||
|
registerCleanupFunction(Task.async(function*() {
|
||||||
|
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(GMPScope.KEY_LOGGING_DUMP);
|
||||||
|
gPrefs.clearUserPref(GMPScope.KEY_LOGGING_LEVEL);
|
||||||
|
gPrefs.clearUserPref(GMPScope.KEY_PROVIDER_LASTCHECK);
|
||||||
|
gPrefs.clearUserPref(GMPScope.KEY_EME_ENABLED);
|
||||||
|
yield GMPScope.GMPProvider.shutdown();
|
||||||
|
GMPScope.GMPProvider.startup();
|
||||||
|
}));
|
||||||
|
|
||||||
|
let chrome = Cc["@mozilla.org/chrome/chrome-registry;1"].getService(Ci.nsIXULChromeRegistry);
|
||||||
|
gIsEnUsLocale = chrome.getSelectedLocale("global") == "en-US";
|
||||||
|
|
||||||
|
Services.obs.addObserver(gOptionsObserver, AddonManager.OPTIONS_NOTIFICATION_DISPLAYED, false);
|
||||||
|
|
||||||
|
// Start out with plugins not being installed, disabled and automatic updates
|
||||||
|
// disabled.
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
yield GMPScope.GMPProvider.shutdown();
|
||||||
|
GMPScope.GMPProvider.startup();
|
||||||
|
});
|
||||||
|
|
||||||
|
add_task(function* testNotInstalled() {
|
||||||
|
Assert.ok(gCategoryUtilities.isTypeVisible("plugin"), "Plugin tab visible.");
|
||||||
|
yield gCategoryUtilities.openType("plugin");
|
||||||
|
|
||||||
|
for (let addon of gMockAddons) {
|
||||||
|
let item = get_addon_element(gManagerWindow, addon.id);
|
||||||
|
Assert.ok(item, "Got add-on element:" + addon.id);
|
||||||
|
item.parentNode.ensureElementIsVisible(item);
|
||||||
|
is(item.getAttribute("active"), "false");
|
||||||
|
|
||||||
|
let el = item.ownerDocument.getAnonymousElementByAttribute(item, "anonid", "warning");
|
||||||
|
is_element_visible(el, "Warning notification is visible.");
|
||||||
|
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.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
add_task(function* testNotInstalledDetails() {
|
||||||
|
for (let addon of gMockAddons) {
|
||||||
|
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_visible(el, "Find updates link is visible.");
|
||||||
|
el = doc.getElementById("detail-warning");
|
||||||
|
is_element_visible(el, "Warning notification is visible.");
|
||||||
|
el = doc.getElementsByTagName("setting")[0];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
add_task(function* testInstalled() {
|
||||||
|
for (let addon of gMockAddons) {
|
||||||
|
gPrefs.setBoolPref(getKey(GMPScope.KEY_PLUGIN_ENABLED, addon.id), true);
|
||||||
|
gPrefs.setIntPref(getKey(GMPScope.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");
|
||||||
|
|
||||||
|
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"), "true");
|
||||||
|
|
||||||
|
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_hidden(el, "disabled-postfix is hidden.");
|
||||||
|
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 alwaysActivate = item.ownerDocument.getAnonymousElementByAttribute(item, "anonid", "always-activate-menuitem");
|
||||||
|
is(menu.selectedItem, alwaysActivate, "Plugin state should be always-activate.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
add_task(function* testInstalledDetails() {
|
||||||
|
for (let addon of gMockAddons) {
|
||||||
|
yield openDetailsView(addon.id);
|
||||||
|
let doc = gManagerWindow.document;
|
||||||
|
|
||||||
|
let el = doc.getElementsByClassName("disabled-postfix")[0];
|
||||||
|
is_element_hidden(el, "disabled-postfix is hidden.");
|
||||||
|
el = doc.getElementById("detail-findUpdates-btn");
|
||||||
|
is_element_visible(el, "Find updates link is visible.");
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
add_task(function* testInstalledGlobalEmeDisabled() {
|
||||||
|
gPrefs.setBoolPref(GMPScope.KEY_EME_ENABLED, false);
|
||||||
|
for (let addon of gMockEmeAddons) {
|
||||||
|
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.");
|
||||||
|
}
|
||||||
|
gPrefs.clearUserPref(GMPScope.KEY_EME_ENABLED);
|
||||||
|
});
|
||||||
|
|
||||||
|
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_visible(el, "Find updates link is visible.");
|
||||||
|
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.clearUserPref(GMPScope.KEY_EME_ENABLED);
|
||||||
|
});
|
||||||
|
|
||||||
|
add_task(function* testPreferencesButton() {
|
||||||
|
|
||||||
|
let prefValues = [
|
||||||
|
{ enabled: false, version: "" },
|
||||||
|
{ enabled: false, version: "1.2.3.4" },
|
||||||
|
{ enabled: true, version: "" },
|
||||||
|
{ enabled: true, version: "1.2.3.4" },
|
||||||
|
];
|
||||||
|
|
||||||
|
for (let preferences of prefValues) {
|
||||||
|
dump("Testing preferences button with pref settings: " +
|
||||||
|
JSON.stringify(preferences) + "\n");
|
||||||
|
for (let addon of gMockAddons) {
|
||||||
|
yield close_manager(gManagerWindow);
|
||||||
|
gManagerWindow = yield open_manager();
|
||||||
|
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||||
|
gPrefs.setCharPref(getKey(GMPScope.KEY_PLUGIN_VERSION, addon.id),
|
||||||
|
preferences.version);
|
||||||
|
gPrefs.setBoolPref(getKey(GMPScope.KEY_PLUGIN_ENABLED, addon.id),
|
||||||
|
preferences.enabled);
|
||||||
|
|
||||||
|
yield gCategoryUtilities.openType("plugin");
|
||||||
|
let doc = gManagerWindow.document;
|
||||||
|
let item = get_addon_element(gManagerWindow, addon.id);
|
||||||
|
|
||||||
|
let button = doc.getAnonymousElementByAttribute(item, "anonid", "preferences-btn");
|
||||||
|
EventUtils.synthesizeMouseAtCenter(button, { clickCount: 1 }, gManagerWindow);
|
||||||
|
let deferred = Promise.defer();
|
||||||
|
wait_for_view_load(gManagerWindow, deferred.resolve);
|
||||||
|
yield deferred.promise;
|
||||||
|
|
||||||
|
is(gOptionsObserver.lastDisplayed, addon.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
add_task(function* testUpdateButton() {
|
||||||
|
gPrefs.clearUserPref(GMPScope.KEY_PROVIDER_LASTCHECK);
|
||||||
|
|
||||||
|
let originalInstallManager = GMPScope.GMPInstallManager;
|
||||||
|
Object.defineProperty(GMPScope, "GMPInstallManager", {
|
||||||
|
value: MockGMPInstallManager,
|
||||||
|
writable: true,
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true
|
||||||
|
});
|
||||||
|
|
||||||
|
for (let addon of gMockAddons) {
|
||||||
|
yield gCategoryUtilities.openType("plugin");
|
||||||
|
let doc = gManagerWindow.document;
|
||||||
|
let item = get_addon_element(gManagerWindow, addon.id);
|
||||||
|
|
||||||
|
gInstalledAddonId = "";
|
||||||
|
gInstallDeferred = Promise.defer();
|
||||||
|
|
||||||
|
let button = doc.getAnonymousElementByAttribute(item, "anonid", "preferences-btn");
|
||||||
|
EventUtils.synthesizeMouseAtCenter(button, { clickCount: 1 }, gManagerWindow);
|
||||||
|
let deferred = Promise.defer();
|
||||||
|
wait_for_view_load(gManagerWindow, deferred.resolve);
|
||||||
|
yield deferred.promise;
|
||||||
|
|
||||||
|
button = doc.getElementById("detail-findUpdates-btn");
|
||||||
|
Assert.ok(button != null, "Got detail-findUpdates-btn");
|
||||||
|
EventUtils.synthesizeMouseAtCenter(button, { clickCount: 1 }, gManagerWindow);
|
||||||
|
yield gInstallDeferred.promise;
|
||||||
|
|
||||||
|
Assert.equal(gInstalledAddonId, addon.id);
|
||||||
|
}
|
||||||
|
Object.defineProperty(GMPScope, "GMPInstallManager", {
|
||||||
|
value: originalInstallManager,
|
||||||
|
writable: true,
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
add_task(function* testHidden() {
|
||||||
|
gPrefs.clearUserPref(GMPScope.KEY_PROVIDER_LASTCHECK);
|
||||||
|
|
||||||
|
for (let addon of gMockAddons) {
|
||||||
|
gPrefs.setBoolPref(getKey(GMPScope.KEY_PLUGIN_HIDDEN, addon.id), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hiding of plugins requires a restart of the GMP provider.
|
||||||
|
yield GMPScope.GMPProvider.shutdown();
|
||||||
|
GMPScope.GMPProvider.startup();
|
||||||
|
|
||||||
|
for (let addon of gMockAddons) {
|
||||||
|
yield gCategoryUtilities.openType("plugin");
|
||||||
|
let doc = gManagerWindow.document;
|
||||||
|
let item = get_addon_element(gManagerWindow, addon.id);
|
||||||
|
Assert.equal(item, null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
add_task(function* test_cleanup() {
|
||||||
|
yield close_manager(gManagerWindow);
|
||||||
|
});
|
@ -1,278 +0,0 @@
|
|||||||
/* Any copyright is dedicated to the Public Domain.
|
|
||||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
|
||||||
*/
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
Cu.import("resource://gre/modules/Promise.jsm");
|
|
||||||
let {AddonTestUtils} = Cu.import("resource://testing-common/AddonManagerTesting.jsm", {});
|
|
||||||
let GMPScope = Cu.import("resource://gre/modules/addons/GMPProvider.jsm");
|
|
||||||
|
|
||||||
const OPENH264_PLUGIN_ID = "gmp-gmpopenh264";
|
|
||||||
const OPENH264_PREF_BRANCH = "media." + OPENH264_PLUGIN_ID + ".";
|
|
||||||
const OPENH264_PREF_ENABLED = OPENH264_PREF_BRANCH + "enabled";
|
|
||||||
const OPENH264_PREF_VERSION = OPENH264_PREF_BRANCH + "version";
|
|
||||||
const OPENH264_PREF_LASTUPDATE = OPENH264_PREF_BRANCH + "lastUpdate";
|
|
||||||
const OPENH264_PREF_AUTOUPDATE = OPENH264_PREF_BRANCH + "autoupdate";
|
|
||||||
const PREF_LOGGING = OPENH264_PREF_BRANCH + "provider.logging";
|
|
||||||
const PREF_LOGGING_LEVEL = PREF_LOGGING + ".level";
|
|
||||||
const PREF_LOGGING_DUMP = PREF_LOGGING + ".dump";
|
|
||||||
const GMP_PREF_LASTCHECK = "media.gmp-manager.lastCheck";
|
|
||||||
const GMP_PREF_LOG = "media.gmp-manager.log";
|
|
||||||
|
|
||||||
const TEST_DATE = new Date(2013, 0, 1, 12);
|
|
||||||
|
|
||||||
let gManagerWindow;
|
|
||||||
let gCategoryUtilities;
|
|
||||||
let gIsEnUsLocale;
|
|
||||||
|
|
||||||
let MockGMPAddon = Object.freeze({
|
|
||||||
id: OPENH264_PLUGIN_ID,
|
|
||||||
isOpenH264: true,
|
|
||||||
isInstalled: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
let gInstalledAddonId = "";
|
|
||||||
let gInstallDeferred = null;
|
|
||||||
|
|
||||||
function MockGMPInstallManager() {
|
|
||||||
}
|
|
||||||
|
|
||||||
MockGMPInstallManager.prototype = {
|
|
||||||
checkForAddons: () => Promise.resolve([MockGMPAddon]),
|
|
||||||
|
|
||||||
installAddon: addon => {
|
|
||||||
gInstalledAddonId = addon.id;
|
|
||||||
gInstallDeferred.resolve();
|
|
||||||
return Promise.resolve();
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
let gOptionsObserver = {
|
|
||||||
lastDisplayed: null,
|
|
||||||
observe: function(aSubject, aTopic, aData) {
|
|
||||||
if (aTopic == AddonManager.OPTIONS_NOTIFICATION_DISPLAYED) {
|
|
||||||
this.lastDisplayed = aData;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
function getInstallItem() {
|
|
||||||
let doc = gManagerWindow.document;
|
|
||||||
let list = doc.getElementById("addon-list");
|
|
||||||
|
|
||||||
let node = list.firstChild;
|
|
||||||
while (node) {
|
|
||||||
if (node.getAttribute("status") == "installing") {
|
|
||||||
return node;
|
|
||||||
}
|
|
||||||
node = node.nextSibling;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
function openDetailsView(aId) {
|
|
||||||
let item = get_addon_element(gManagerWindow, aId);
|
|
||||||
Assert.ok(item, "Should have got add-on element.");
|
|
||||||
is_element_visible(item, "Add-on element should be visible.");
|
|
||||||
|
|
||||||
EventUtils.synthesizeMouseAtCenter(item, { clickCount: 1 }, gManagerWindow);
|
|
||||||
EventUtils.synthesizeMouseAtCenter(item, { clickCount: 2 }, gManagerWindow);
|
|
||||||
|
|
||||||
let deferred = Promise.defer();
|
|
||||||
wait_for_view_load(gManagerWindow, deferred.resolve);
|
|
||||||
return deferred.promise;
|
|
||||||
}
|
|
||||||
|
|
||||||
add_task(function* initializeState() {
|
|
||||||
Services.prefs.setBoolPref(PREF_LOGGING_DUMP, true);
|
|
||||||
Services.prefs.setIntPref(PREF_LOGGING_LEVEL, 0);
|
|
||||||
Services.prefs.setBoolPref(GMP_PREF_LOG, true);
|
|
||||||
|
|
||||||
gManagerWindow = yield open_manager();
|
|
||||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
|
||||||
|
|
||||||
registerCleanupFunction(() => {
|
|
||||||
Services.obs.removeObserver(gOptionsObserver, AddonManager.OPTIONS_NOTIFICATION_DISPLAYED);
|
|
||||||
|
|
||||||
Services.prefs.clearUserPref(OPENH264_PREF_ENABLED);
|
|
||||||
Services.prefs.clearUserPref(OPENH264_PREF_VERSION);
|
|
||||||
Services.prefs.clearUserPref(OPENH264_PREF_LASTUPDATE);
|
|
||||||
Services.prefs.clearUserPref(OPENH264_PREF_AUTOUPDATE);
|
|
||||||
Services.prefs.clearUserPref(PREF_LOGGING_DUMP);
|
|
||||||
Services.prefs.clearUserPref(PREF_LOGGING_LEVEL);
|
|
||||||
Services.prefs.clearUserPref(GMP_PREF_LOG);
|
|
||||||
Services.prefs.clearUserPref(GMP_PREF_LASTCHECK);
|
|
||||||
});
|
|
||||||
|
|
||||||
let chrome = Cc["@mozilla.org/chrome/chrome-registry;1"].getService(Ci.nsIXULChromeRegistry);
|
|
||||||
gIsEnUsLocale = chrome.getSelectedLocale("global") == "en-US";
|
|
||||||
|
|
||||||
Services.obs.addObserver(gOptionsObserver, AddonManager.OPTIONS_NOTIFICATION_DISPLAYED, false);
|
|
||||||
|
|
||||||
// Start out with OpenH264 not being installed, disabled and automatic updates disabled.
|
|
||||||
Services.prefs.setBoolPref(OPENH264_PREF_ENABLED, false);
|
|
||||||
Services.prefs.setIntPref (OPENH264_PREF_LASTUPDATE, 0);
|
|
||||||
Services.prefs.setBoolPref(OPENH264_PREF_AUTOUPDATE, false);
|
|
||||||
Services.prefs.setCharPref(OPENH264_PREF_VERSION, "");
|
|
||||||
});
|
|
||||||
|
|
||||||
add_task(function* testNotInstalled() {
|
|
||||||
Assert.ok(gCategoryUtilities.isTypeVisible("plugin"), "Plugin tab visible.");
|
|
||||||
yield gCategoryUtilities.openType("plugin");
|
|
||||||
|
|
||||||
let item = get_addon_element(gManagerWindow, OPENH264_PLUGIN_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_visible(el, "Warning notification is visible.");
|
|
||||||
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.");
|
|
||||||
});
|
|
||||||
|
|
||||||
add_task(function* testNotInstalledDetails() {
|
|
||||||
yield openDetailsView(OPENH264_PLUGIN_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_visible(el, "Find updates link is visible.");
|
|
||||||
el = doc.getElementById("detail-warning");
|
|
||||||
is_element_visible(el, "Warning notification is visible.");
|
|
||||||
el = doc.getElementsByTagName("setting")[0];
|
|
||||||
});
|
|
||||||
|
|
||||||
add_task(function* testInstalled() {
|
|
||||||
Services.prefs.setBoolPref(OPENH264_PREF_ENABLED, true);
|
|
||||||
Services.prefs.setIntPref (OPENH264_PREF_LASTUPDATE, TEST_DATE.getTime());
|
|
||||||
Services.prefs.setBoolPref(OPENH264_PREF_AUTOUPDATE, false);
|
|
||||||
Services.prefs.setCharPref(OPENH264_PREF_VERSION, "1.2.3.4");
|
|
||||||
|
|
||||||
yield gCategoryUtilities.openType("plugin");
|
|
||||||
|
|
||||||
let item = get_addon_element(gManagerWindow, OPENH264_PLUGIN_ID);
|
|
||||||
Assert.ok(item, "Got add-on element.");
|
|
||||||
item.parentNode.ensureElementIsVisible(item);
|
|
||||||
is(item.getAttribute("active"), "true");
|
|
||||||
|
|
||||||
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_hidden(el, "disabled-postfix is hidden.");
|
|
||||||
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 alwaysActivate = item.ownerDocument.getAnonymousElementByAttribute(item, "anonid", "always-activate-menuitem");
|
|
||||||
is(menu.selectedItem, alwaysActivate, "Plugin state should be always-activate.");
|
|
||||||
});
|
|
||||||
|
|
||||||
add_task(function* testInstalledDetails() {
|
|
||||||
yield openDetailsView(OPENH264_PLUGIN_ID);
|
|
||||||
let doc = gManagerWindow.document;
|
|
||||||
|
|
||||||
let el = doc.getElementsByClassName("disabled-postfix")[0];
|
|
||||||
is_element_hidden(el, "disabled-postfix is hidden.");
|
|
||||||
el = doc.getElementById("detail-findUpdates-btn");
|
|
||||||
is_element_visible(el, "Find updates link is visible.");
|
|
||||||
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();
|
|
||||||
});
|
|
||||||
|
|
||||||
add_task(function* testPreferencesButton() {
|
|
||||||
|
|
||||||
let prefValues = [
|
|
||||||
{ enabled: false, version: "" },
|
|
||||||
{ enabled: false, version: "1.2.3.4" },
|
|
||||||
{ enabled: true, version: "" },
|
|
||||||
{ enabled: true, version: "1.2.3.4" },
|
|
||||||
];
|
|
||||||
|
|
||||||
for (let prefs of prefValues) {
|
|
||||||
dump("Testing preferences button with pref settings: " + JSON.stringify(prefs) + "\n");
|
|
||||||
Services.prefs.setCharPref(OPENH264_PREF_VERSION, prefs.version);
|
|
||||||
Services.prefs.setBoolPref(OPENH264_PREF_ENABLED, prefs.enabled);
|
|
||||||
|
|
||||||
yield gCategoryUtilities.openType("plugin");
|
|
||||||
let doc = gManagerWindow.document;
|
|
||||||
let item = get_addon_element(gManagerWindow, OPENH264_PLUGIN_ID);
|
|
||||||
|
|
||||||
let button = doc.getAnonymousElementByAttribute(item, "anonid", "preferences-btn");
|
|
||||||
EventUtils.synthesizeMouseAtCenter(button, { clickCount: 1 }, gManagerWindow);
|
|
||||||
let deferred = Promise.defer();
|
|
||||||
wait_for_view_load(gManagerWindow, deferred.resolve);
|
|
||||||
yield deferred.promise;
|
|
||||||
|
|
||||||
is(gOptionsObserver.lastDisplayed, OPENH264_PLUGIN_ID);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
add_task(function* testUpdateButton() {
|
|
||||||
Services.prefs.clearUserPref(GMP_PREF_LASTCHECK);
|
|
||||||
|
|
||||||
yield gCategoryUtilities.openType("plugin");
|
|
||||||
let doc = gManagerWindow.document;
|
|
||||||
let item = get_addon_element(gManagerWindow, OPENH264_PLUGIN_ID);
|
|
||||||
|
|
||||||
Object.defineProperty(GMPScope, "GMPInstallManager", {
|
|
||||||
value: MockGMPInstallManager,
|
|
||||||
writable: true,
|
|
||||||
enumerable: true,
|
|
||||||
configurable: true
|
|
||||||
});
|
|
||||||
gInstalledAddonId = "";
|
|
||||||
gInstallDeferred = Promise.defer();
|
|
||||||
|
|
||||||
let button = doc.getAnonymousElementByAttribute(item, "anonid", "preferences-btn");
|
|
||||||
EventUtils.synthesizeMouseAtCenter(button, { clickCount: 1 }, gManagerWindow);
|
|
||||||
let deferred = Promise.defer();
|
|
||||||
wait_for_view_load(gManagerWindow, deferred.resolve);
|
|
||||||
yield deferred.promise;
|
|
||||||
|
|
||||||
button = doc.getElementById("detail-findUpdates-btn");
|
|
||||||
Assert.ok(button != null, "Got detail-findUpdates-btn");
|
|
||||||
EventUtils.synthesizeMouseAtCenter(button, { clickCount: 1 }, gManagerWindow);
|
|
||||||
yield gInstallDeferred.promise;
|
|
||||||
|
|
||||||
Assert.equal(gInstalledAddonId, OPENH264_PLUGIN_ID);
|
|
||||||
delete GMPScope.GMPInstallManager;
|
|
||||||
});
|
|
||||||
|
|
||||||
add_task(function* test_cleanup() {
|
|
||||||
yield close_manager(gManagerWindow);
|
|
||||||
});
|
|
@ -102,7 +102,7 @@ var gPluginIDs = [null, null, null, null, null];
|
|||||||
function run_test() {
|
function run_test() {
|
||||||
do_test_pending();
|
do_test_pending();
|
||||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
|
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
|
||||||
Services.prefs.setBoolPref("media.gmp-gmpopenh264.provider.enabled", false);
|
Services.prefs.setBoolPref("media.gmp-provider.enabled", false);
|
||||||
|
|
||||||
startupManager();
|
startupManager();
|
||||||
|
|
||||||
|
330
toolkit/mozapps/extensions/test/xpcshell/test_gmpProvider.js
Normal file
330
toolkit/mozapps/extensions/test/xpcshell/test_gmpProvider.js
Normal file
@ -0,0 +1,330 @@
|
|||||||
|
/* Any copyright is dedicated to the Public Domain.
|
||||||
|
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
|
||||||
|
let GMPScope = Cu.import("resource://gre/modules/addons/GMPProvider.jsm");
|
||||||
|
|
||||||
|
XPCOMUtils.defineLazyGetter(this, "pluginsBundle",
|
||||||
|
() => Services.strings.createBundle("chrome://global/locale/plugins.properties"));
|
||||||
|
|
||||||
|
let gMockAddons = new Map();
|
||||||
|
let gMockEmeAddons = new Map();
|
||||||
|
|
||||||
|
for (let plugin of GMPScope.GMP_PLUGINS) {
|
||||||
|
let mockAddon = Object.freeze({
|
||||||
|
id: plugin.id,
|
||||||
|
isValid: true,
|
||||||
|
isInstalled: false,
|
||||||
|
nameId: plugin.name,
|
||||||
|
descriptionId: plugin.description,
|
||||||
|
});
|
||||||
|
gMockAddons.set(mockAddon.id, mockAddon);
|
||||||
|
if (mockAddon.id.indexOf("gmp-eme-") == 0) {
|
||||||
|
gMockEmeAddons.set(mockAddon.id, mockAddon);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let gInstalledAddonId = "";
|
||||||
|
let gPrefs = Services.prefs;
|
||||||
|
let gGetKey = GMPScope.GMPPrefs.getPrefKey;
|
||||||
|
|
||||||
|
function MockGMPInstallManager() {
|
||||||
|
}
|
||||||
|
|
||||||
|
MockGMPInstallManager.prototype = {
|
||||||
|
checkForAddons: () => Promise.resolve([...gMockAddons.values()]),
|
||||||
|
|
||||||
|
installAddon: addon => {
|
||||||
|
gInstalledAddonId = addon.id;
|
||||||
|
return Promise.resolve();
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
for (let addon of gMockAddons.values()) {
|
||||||
|
gPrefs.setBoolPref(gGetKey(GMPScope.KEY_PLUGIN_HIDDEN, addon.id), false);
|
||||||
|
}
|
||||||
|
GMPScope.GMPProvider.shutdown();
|
||||||
|
GMPScope.GMPProvider.startup();
|
||||||
|
|
||||||
|
run_next_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);
|
||||||
|
}
|
||||||
|
|
||||||
|
let addons = yield promiseAddonsByIDs([...gMockAddons.keys()]);
|
||||||
|
Assert.equal(addons.length, gMockAddons.size);
|
||||||
|
|
||||||
|
for (let addon of addons) {
|
||||||
|
Assert.ok(!addon.isInstalled);
|
||||||
|
Assert.equal(addon.type, "plugin");
|
||||||
|
Assert.equal(addon.version, "");
|
||||||
|
|
||||||
|
let mockAddon = gMockAddons.get(addon.id);
|
||||||
|
|
||||||
|
Assert.notEqual(mockAddon, null);
|
||||||
|
let name = pluginsBundle.GetStringFromName(mockAddon.nameId);
|
||||||
|
Assert.equal(addon.name, name);
|
||||||
|
let description = pluginsBundle.GetStringFromName(mockAddon.descriptionId);
|
||||||
|
Assert.equal(addon.description, description);
|
||||||
|
|
||||||
|
Assert.ok(!addon.isActive);
|
||||||
|
Assert.ok(!addon.appDisabled);
|
||||||
|
Assert.ok(addon.userDisabled);
|
||||||
|
|
||||||
|
Assert.equal(addon.blocklistState, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||||
|
Assert.equal(addon.size, 0);
|
||||||
|
Assert.equal(addon.scope, AddonManager.SCOPE_APPLICATION);
|
||||||
|
Assert.equal(addon.pendingOperations, AddonManager.PENDING_NONE);
|
||||||
|
Assert.equal(addon.operationsRequiringRestart, AddonManager.PENDING_NONE);
|
||||||
|
|
||||||
|
Assert.equal(addon.permissions, AddonManager.PERM_CAN_UPGRADE |
|
||||||
|
AddonManager.PERM_CAN_ENABLE);
|
||||||
|
|
||||||
|
Assert.equal(addon.updateDate, null);
|
||||||
|
|
||||||
|
Assert.ok(addon.isCompatible);
|
||||||
|
Assert.ok(addon.isPlatformCompatible);
|
||||||
|
Assert.ok(addon.providesUpdatesSecurely);
|
||||||
|
Assert.ok(!addon.foreignInstall);
|
||||||
|
|
||||||
|
let mimetypes = addon.pluginMimeTypes;
|
||||||
|
Assert.ok(mimetypes);
|
||||||
|
Assert.equal(mimetypes.length, 0);
|
||||||
|
let libraries = addon.pluginLibraries;
|
||||||
|
Assert.ok(libraries);
|
||||||
|
Assert.equal(libraries.length, 0);
|
||||||
|
Assert.equal(addon.pluginFullpath, "");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
add_task(function* test_installed() {
|
||||||
|
const TEST_DATE = new Date(2013, 0, 1, 12);
|
||||||
|
const TEST_VERSION = "1.2.3.4";
|
||||||
|
const TEST_TIME_SEC = Math.round(TEST_DATE.getTime() / 1000);
|
||||||
|
|
||||||
|
let addons = yield promiseAddonsByIDs([...gMockAddons.keys()]);
|
||||||
|
Assert.equal(addons.length, gMockAddons.size);
|
||||||
|
|
||||||
|
for (let addon of addons) {
|
||||||
|
let mockAddon = gMockAddons.get(addon.id);
|
||||||
|
Assert.notEqual(mockAddon, null);
|
||||||
|
|
||||||
|
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),
|
||||||
|
"" + TEST_TIME_SEC);
|
||||||
|
gPrefs.setCharPref(gGetKey(GMPScope.KEY_PLUGIN_VERSION, mockAddon.id),
|
||||||
|
TEST_VERSION);
|
||||||
|
|
||||||
|
Assert.ok(addon.isInstalled);
|
||||||
|
Assert.equal(addon.type, "plugin");
|
||||||
|
Assert.ok(!addon.isActive);
|
||||||
|
Assert.ok(!addon.appDisabled);
|
||||||
|
Assert.ok(addon.userDisabled);
|
||||||
|
|
||||||
|
let name = pluginsBundle.GetStringFromName(mockAddon.nameId);
|
||||||
|
Assert.equal(addon.name, name);
|
||||||
|
Assert.equal(addon.version, TEST_VERSION);
|
||||||
|
|
||||||
|
Assert.equal(addon.permissions, AddonManager.PERM_CAN_UPGRADE |
|
||||||
|
AddonManager.PERM_CAN_ENABLE);
|
||||||
|
|
||||||
|
Assert.equal(addon.updateDate.getTime(), TEST_TIME_SEC * 1000);
|
||||||
|
|
||||||
|
let mimetypes = addon.pluginMimeTypes;
|
||||||
|
Assert.ok(mimetypes);
|
||||||
|
Assert.equal(mimetypes.length, 0);
|
||||||
|
let libraries = addon.pluginLibraries;
|
||||||
|
Assert.ok(libraries);
|
||||||
|
Assert.equal(libraries.length, 1);
|
||||||
|
Assert.equal(libraries[0], TEST_VERSION);
|
||||||
|
let fullpath = addon.pluginFullpath;
|
||||||
|
Assert.equal(fullpath.length, 1);
|
||||||
|
Assert.equal(fullpath[0], file.path);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
add_task(function* test_enable() {
|
||||||
|
let addons = yield promiseAddonsByIDs([...gMockAddons.keys()]);
|
||||||
|
Assert.equal(addons.length, gMockAddons.size);
|
||||||
|
|
||||||
|
for (let addon of addons) {
|
||||||
|
gPrefs.setBoolPref(gGetKey(GMPScope.KEY_PLUGIN_ENABLED, addon.id), true);
|
||||||
|
|
||||||
|
Assert.ok(addon.isActive);
|
||||||
|
Assert.ok(!addon.appDisabled);
|
||||||
|
Assert.ok(!addon.userDisabled);
|
||||||
|
|
||||||
|
Assert.equal(addon.permissions, AddonManager.PERM_CAN_UPGRADE |
|
||||||
|
AddonManager.PERM_CAN_DISABLE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
add_task(function* test_globalEmeDisabled() {
|
||||||
|
let addons = yield promiseAddonsByIDs([...gMockEmeAddons.keys()]);
|
||||||
|
Assert.equal(addons.length, gMockEmeAddons.size);
|
||||||
|
|
||||||
|
gPrefs.setBoolPref(GMPScope.KEY_EME_ENABLED, false);
|
||||||
|
GMPScope.GMPProvider.shutdown();
|
||||||
|
GMPScope.GMPProvider.startup();
|
||||||
|
for (let addon of addons) {
|
||||||
|
Assert.ok(!addon.isActive);
|
||||||
|
Assert.ok(!addon.appDisabled);
|
||||||
|
Assert.ok(addon.userDisabled);
|
||||||
|
|
||||||
|
Assert.equal(addon.permissions, AddonManager.PERM_CAN_UPGRADE |
|
||||||
|
AddonManager.PERM_CAN_ENABLE);
|
||||||
|
}
|
||||||
|
gPrefs.clearUserPref(GMPScope.KEY_EME_ENABLED);
|
||||||
|
GMPScope.GMPProvider.shutdown();
|
||||||
|
GMPScope.GMPProvider.startup();
|
||||||
|
});
|
||||||
|
|
||||||
|
add_task(function* test_autoUpdatePrefPersistance() {
|
||||||
|
let addons = yield promiseAddonsByIDs([...gMockAddons.keys()]);
|
||||||
|
Assert.equal(addons.length, gMockAddons.size);
|
||||||
|
|
||||||
|
for (let addon of addons) {
|
||||||
|
let autoupdateKey = gGetKey(GMPScope.KEY_PLUGIN_AUTOUPDATE, addon.id);
|
||||||
|
gPrefs.clearUserPref(autoupdateKey);
|
||||||
|
|
||||||
|
addon.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DISABLE;
|
||||||
|
Assert.ok(!gPrefs.getBoolPref(autoupdateKey));
|
||||||
|
|
||||||
|
addon.applyBackgroundUpdates = AddonManager.AUTOUPDATE_ENABLE;
|
||||||
|
Assert.equal(addon.applyBackgroundUpdates, AddonManager.AUTOUPDATE_ENABLE);
|
||||||
|
Assert.ok(gPrefs.getBoolPref(autoupdateKey));
|
||||||
|
|
||||||
|
addon.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DEFAULT;
|
||||||
|
Assert.ok(!gPrefs.prefHasUserValue(autoupdateKey));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
add_task(function* test_pluginRegistration() {
|
||||||
|
const TEST_VERSION = "1.2.3.4";
|
||||||
|
|
||||||
|
for (let addon of gMockAddons.values()) {
|
||||||
|
let file = Services.dirsvc.get("ProfD", Ci.nsIFile);
|
||||||
|
file.append(addon.id);
|
||||||
|
file.append(TEST_VERSION);
|
||||||
|
|
||||||
|
let addedPaths = [];
|
||||||
|
let removedPaths = [];
|
||||||
|
let clearPaths = () => { addedPaths = []; removedPaths = []; }
|
||||||
|
|
||||||
|
let MockGMPService = {
|
||||||
|
addPluginDirectory: path => addedPaths.push(path),
|
||||||
|
removePluginDirectory: path => removedPaths.push(path),
|
||||||
|
};
|
||||||
|
|
||||||
|
GMPScope.gmpService = MockGMPService;
|
||||||
|
gPrefs.setBoolPref(gGetKey(GMPScope.KEY_PLUGIN_ENABLED, addon.id), true);
|
||||||
|
|
||||||
|
// Check that the plugin gets registered after startup.
|
||||||
|
gPrefs.setCharPref(gGetKey(GMPScope.KEY_PLUGIN_VERSION, addon.id),
|
||||||
|
TEST_VERSION);
|
||||||
|
clearPaths();
|
||||||
|
yield promiseRestartManager();
|
||||||
|
Assert.notEqual(addedPaths.indexOf(file.path), -1);
|
||||||
|
Assert.deepEqual(removedPaths, []);
|
||||||
|
|
||||||
|
// Check that clearing the version doesn't trigger registration.
|
||||||
|
clearPaths();
|
||||||
|
gPrefs.clearUserPref(gGetKey(GMPScope.KEY_PLUGIN_VERSION, addon.id));
|
||||||
|
Assert.deepEqual(addedPaths, []);
|
||||||
|
Assert.deepEqual(removedPaths, [file.path]);
|
||||||
|
|
||||||
|
// Restarting with no version set should not trigger registration.
|
||||||
|
clearPaths();
|
||||||
|
yield promiseRestartManager();
|
||||||
|
Assert.equal(addedPaths.indexOf(file.path), -1);
|
||||||
|
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),
|
||||||
|
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),
|
||||||
|
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),
|
||||||
|
TEST_VERSION);
|
||||||
|
clearPaths();
|
||||||
|
gPrefs.setBoolPref(gGetKey(GMPScope.KEY_PLUGIN_ENABLED, addon.id), false);
|
||||||
|
Assert.deepEqual(addedPaths, []);
|
||||||
|
Assert.deepEqual(removedPaths, [file.path]);
|
||||||
|
|
||||||
|
// Restarting with the plugin disabled should not cause registration.
|
||||||
|
clearPaths();
|
||||||
|
yield promiseRestartManager();
|
||||||
|
Assert.equal(addedPaths.indexOf(file.path), -1);
|
||||||
|
Assert.equal(removedPaths.indexOf(file.path), -1);
|
||||||
|
|
||||||
|
// Re-enabling the plugin should cause registration.
|
||||||
|
clearPaths();
|
||||||
|
gPrefs.setBoolPref(gGetKey(GMPScope.KEY_PLUGIN_ENABLED, addon.id), true);
|
||||||
|
Assert.deepEqual(addedPaths, [file.path]);
|
||||||
|
Assert.deepEqual(removedPaths, []);
|
||||||
|
GMPScope = Cu.import("resource://gre/modules/addons/GMPProvider.jsm");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
add_task(function* test_periodicUpdate() {
|
||||||
|
Object.defineProperty(GMPScope, "GMPInstallManager", {
|
||||||
|
value: MockGMPInstallManager,
|
||||||
|
writable: true,
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true
|
||||||
|
});
|
||||||
|
|
||||||
|
let addons = yield promiseAddonsByIDs([...gMockAddons.keys()]);
|
||||||
|
Assert.equal(addons.length, gMockAddons.size);
|
||||||
|
|
||||||
|
for (let addon of addons) {
|
||||||
|
gPrefs.clearUserPref(gGetKey(GMPScope.KEY_PLUGIN_AUTOUPDATE, addon.id));
|
||||||
|
|
||||||
|
addon.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DISABLE;
|
||||||
|
gPrefs.setIntPref(GMPScope.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);
|
||||||
|
result =
|
||||||
|
yield addon.findUpdates({}, AddonManager.UPDATE_WHEN_PERIODIC_UPDATE);
|
||||||
|
Assert.strictEqual(result, false);
|
||||||
|
|
||||||
|
gPrefs.setIntPref(GMPScope.KEY_PROVIDER_LASTCHECK,
|
||||||
|
Date.now() / 1000 - 2 * GMPScope.SEC_IN_A_DAY);
|
||||||
|
gInstalledAddonId = "";
|
||||||
|
result =
|
||||||
|
yield addon.findUpdates({}, AddonManager.UPDATE_WHEN_PERIODIC_UPDATE);
|
||||||
|
Assert.strictEqual(result, true);
|
||||||
|
Assert.equal(gInstalledAddonId, addon.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
GMPScope = Cu.import("resource://gre/modules/addons/GMPProvider.jsm");
|
||||||
|
});
|
@ -1,279 +0,0 @@
|
|||||||
/* Any copyright is dedicated to the Public Domain.
|
|
||||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
|
|
||||||
|
|
||||||
const OPENH264_PLUGIN_ID = "gmp-gmpopenh264";
|
|
||||||
const OPENH264_PREF_BRANCH = "media." + OPENH264_PLUGIN_ID + ".";
|
|
||||||
const OPENH264_PREF_ENABLED = OPENH264_PREF_BRANCH + "enabled";
|
|
||||||
const OPENH264_PREF_VERSION = OPENH264_PREF_BRANCH + "version";
|
|
||||||
const OPENH264_PREF_LASTUPDATE = OPENH264_PREF_BRANCH + "lastUpdate";
|
|
||||||
const OPENH264_PREF_AUTOUPDATE = OPENH264_PREF_BRANCH + "autoupdate";
|
|
||||||
const PREF_LOGGING = OPENH264_PREF_BRANCH + "provider.logging";
|
|
||||||
const PREF_LOGGING_LEVEL = PREF_LOGGING + ".level";
|
|
||||||
const PREF_LOGGING_DUMP = PREF_LOGGING + ".dump";
|
|
||||||
const GMP_PREF_LASTCHECK = "media.gmp-manager.lastCheck";
|
|
||||||
const GMP_PREF_LOG = "media.gmp-manager.log";
|
|
||||||
const SEC_IN_A_DAY = 24 * 60 * 60;
|
|
||||||
|
|
||||||
XPCOMUtils.defineLazyGetter(this, "pluginsBundle",
|
|
||||||
() => Services.strings.createBundle("chrome://global/locale/plugins.properties"));
|
|
||||||
|
|
||||||
let MockGMPAddon = Object.freeze({
|
|
||||||
id: OPENH264_PLUGIN_ID,
|
|
||||||
isOpenH264: true,
|
|
||||||
isInstalled: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
let gInstalledAddonId = "";
|
|
||||||
|
|
||||||
function MockGMPInstallManager() {
|
|
||||||
}
|
|
||||||
|
|
||||||
MockGMPInstallManager.prototype = {
|
|
||||||
checkForAddons: () => Promise.resolve([MockGMPAddon]),
|
|
||||||
|
|
||||||
installAddon: addon => {
|
|
||||||
gInstalledAddonId = addon.id;
|
|
||||||
return Promise.resolve();
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
function run_test() {
|
|
||||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
|
|
||||||
startupManager();
|
|
||||||
|
|
||||||
Services.prefs.setBoolPref(PREF_LOGGING_DUMP, true);
|
|
||||||
Services.prefs.setIntPref(PREF_LOGGING_LEVEL, 0);
|
|
||||||
Services.prefs.setBoolPref(GMP_PREF_LOG, true);
|
|
||||||
|
|
||||||
run_next_test();
|
|
||||||
}
|
|
||||||
|
|
||||||
add_task(function* test_notInstalled() {
|
|
||||||
Services.prefs.setCharPref(OPENH264_PREF_VERSION, "");
|
|
||||||
Services.prefs.setBoolPref(OPENH264_PREF_ENABLED, false);
|
|
||||||
|
|
||||||
let addons = yield promiseAddonsByIDs([OPENH264_PLUGIN_ID]);
|
|
||||||
Assert.equal(addons.length, 1);
|
|
||||||
let addon = addons[0];
|
|
||||||
|
|
||||||
Assert.ok(!addon.isInstalled);
|
|
||||||
Assert.equal(addon.type, "plugin");
|
|
||||||
Assert.equal(addon.version, "");
|
|
||||||
|
|
||||||
let name = pluginsBundle.GetStringFromName("openH264_name");
|
|
||||||
Assert.equal(addon.name, name);
|
|
||||||
let description = pluginsBundle.GetStringFromName("openH264_description");
|
|
||||||
Assert.equal(addon.description, description);
|
|
||||||
|
|
||||||
Assert.ok(!addon.isActive);
|
|
||||||
Assert.ok(!addon.appDisabled);
|
|
||||||
Assert.ok(addon.userDisabled);
|
|
||||||
|
|
||||||
Assert.equal(addon.blocklistState, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
|
||||||
Assert.equal(addon.size, 0);
|
|
||||||
Assert.equal(addon.scope, AddonManager.SCOPE_APPLICATION);
|
|
||||||
Assert.equal(addon.pendingOperations, AddonManager.PENDING_NONE);
|
|
||||||
Assert.equal(addon.operationsRequiringRestart, AddonManager.PENDING_NONE);
|
|
||||||
|
|
||||||
Assert.equal(addon.permissions, AddonManager.PERM_CAN_UPGRADE |
|
|
||||||
AddonManager.PERM_CAN_ENABLE);
|
|
||||||
|
|
||||||
Assert.equal(addon.updateDate, null);
|
|
||||||
|
|
||||||
Assert.ok(addon.isCompatible);
|
|
||||||
Assert.ok(addon.isPlatformCompatible);
|
|
||||||
Assert.ok(addon.providesUpdatesSecurely);
|
|
||||||
Assert.ok(!addon.foreignInstall);
|
|
||||||
|
|
||||||
let mimetypes = addon.pluginMimeTypes;
|
|
||||||
Assert.ok(mimetypes);
|
|
||||||
Assert.equal(mimetypes.length, 0);
|
|
||||||
let libraries = addon.pluginLibraries;
|
|
||||||
Assert.ok(libraries);
|
|
||||||
Assert.equal(libraries.length, 0);
|
|
||||||
Assert.equal(addon.pluginFullpath, "");
|
|
||||||
});
|
|
||||||
|
|
||||||
add_task(function* test_installed() {
|
|
||||||
const TEST_DATE = new Date(2013, 0, 1, 12);
|
|
||||||
const TEST_VERSION = "1.2.3.4";
|
|
||||||
const TEST_TIME_SEC = Math.round(TEST_DATE.getTime() / 1000);
|
|
||||||
|
|
||||||
let file = Services.dirsvc.get("ProfD", Ci.nsIFile);
|
|
||||||
file.append(OPENH264_PLUGIN_ID);
|
|
||||||
file.append(TEST_VERSION);
|
|
||||||
|
|
||||||
Services.prefs.setBoolPref(OPENH264_PREF_ENABLED, false);
|
|
||||||
Services.prefs.setCharPref(OPENH264_PREF_LASTUPDATE, "" + TEST_TIME_SEC);
|
|
||||||
Services.prefs.setCharPref(OPENH264_PREF_VERSION, TEST_VERSION);
|
|
||||||
|
|
||||||
let addons = yield promiseAddonsByIDs([OPENH264_PLUGIN_ID]);
|
|
||||||
Assert.equal(addons.length, 1);
|
|
||||||
let addon = addons[0];
|
|
||||||
|
|
||||||
Assert.ok(addon.isInstalled);
|
|
||||||
Assert.equal(addon.type, "plugin");
|
|
||||||
let name = pluginsBundle.GetStringFromName("openH264_name");
|
|
||||||
Assert.equal(addon.name, name);
|
|
||||||
Assert.equal(addon.version, TEST_VERSION);
|
|
||||||
|
|
||||||
Assert.ok(!addon.isActive);
|
|
||||||
Assert.ok(!addon.appDisabled);
|
|
||||||
Assert.ok(addon.userDisabled);
|
|
||||||
|
|
||||||
Assert.equal(addon.permissions, AddonManager.PERM_CAN_UPGRADE |
|
|
||||||
AddonManager.PERM_CAN_ENABLE);
|
|
||||||
|
|
||||||
Assert.equal(addon.updateDate.getTime(), TEST_TIME_SEC * 1000);
|
|
||||||
|
|
||||||
let mimetypes = addon.pluginMimeTypes;
|
|
||||||
Assert.ok(mimetypes);
|
|
||||||
Assert.equal(mimetypes.length, 0);
|
|
||||||
let libraries = addon.pluginLibraries;
|
|
||||||
Assert.ok(libraries);
|
|
||||||
Assert.equal(libraries.length, 1);
|
|
||||||
Assert.equal(libraries[0], TEST_VERSION);
|
|
||||||
let fullpath = addon.pluginFullpath;
|
|
||||||
Assert.equal(fullpath.length, 1);
|
|
||||||
Assert.equal(fullpath[0], file.path);
|
|
||||||
});
|
|
||||||
|
|
||||||
add_task(function* test_enable() {
|
|
||||||
Services.prefs.setBoolPref(OPENH264_PREF_ENABLED, true);
|
|
||||||
|
|
||||||
let addons = yield promiseAddonsByIDs([OPENH264_PLUGIN_ID]);
|
|
||||||
Assert.equal(addons.length, 1);
|
|
||||||
let addon = addons[0];
|
|
||||||
|
|
||||||
Assert.ok(addon.isActive);
|
|
||||||
Assert.ok(!addon.appDisabled);
|
|
||||||
Assert.ok(!addon.userDisabled);
|
|
||||||
|
|
||||||
Assert.equal(addon.permissions, AddonManager.PERM_CAN_UPGRADE |
|
|
||||||
AddonManager.PERM_CAN_DISABLE);
|
|
||||||
});
|
|
||||||
|
|
||||||
add_task(function* test_autoUpdatePrefPersistance() {
|
|
||||||
Services.prefs.clearUserPref(OPENH264_PREF_AUTOUPDATE);
|
|
||||||
let addons = yield promiseAddonsByIDs([OPENH264_PLUGIN_ID]);
|
|
||||||
let prefs = Services.prefs;
|
|
||||||
Assert.equal(addons.length, 1);
|
|
||||||
let addon = addons[0];
|
|
||||||
|
|
||||||
addon.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DISABLE;
|
|
||||||
Assert.ok(!prefs.getBoolPref(OPENH264_PREF_AUTOUPDATE));
|
|
||||||
|
|
||||||
addon.applyBackgroundUpdates = AddonManager.AUTOUPDATE_ENABLE;
|
|
||||||
Assert.equal(addon.applyBackgroundUpdates, AddonManager.AUTOUPDATE_ENABLE);
|
|
||||||
Assert.ok(prefs.getBoolPref(OPENH264_PREF_AUTOUPDATE));
|
|
||||||
|
|
||||||
addon.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DEFAULT;
|
|
||||||
Assert.ok(!prefs.prefHasUserValue(OPENH264_PREF_AUTOUPDATE));
|
|
||||||
});
|
|
||||||
|
|
||||||
add_task(function* test_pluginRegistration() {
|
|
||||||
const TEST_VERSION = "1.2.3.4";
|
|
||||||
|
|
||||||
let file = Services.dirsvc.get("ProfD", Ci.nsIFile);
|
|
||||||
file.append(OPENH264_PLUGIN_ID);
|
|
||||||
file.append(TEST_VERSION);
|
|
||||||
|
|
||||||
let addedPaths = [];
|
|
||||||
let removedPaths = [];
|
|
||||||
let clearPaths = () => { addedPaths = []; removedPaths = []; }
|
|
||||||
|
|
||||||
let MockGMPService = {
|
|
||||||
addPluginDirectory: path => addedPaths.push(path),
|
|
||||||
removePluginDirectory: path => removedPaths.push(path),
|
|
||||||
};
|
|
||||||
|
|
||||||
let GMPScope = Cu.import("resource://gre/modules/addons/GMPProvider.jsm");
|
|
||||||
GMPScope.gmpService = MockGMPService;
|
|
||||||
Services.prefs.setBoolPref(OPENH264_PREF_ENABLED, true);
|
|
||||||
|
|
||||||
// Check that the OpenH264 plugin gets registered after startup.
|
|
||||||
Services.prefs.setCharPref(OPENH264_PREF_VERSION, TEST_VERSION);
|
|
||||||
clearPaths();
|
|
||||||
yield promiseRestartManager();
|
|
||||||
Assert.notEqual(addedPaths.indexOf(file.path), -1);
|
|
||||||
Assert.deepEqual(removedPaths, []);
|
|
||||||
|
|
||||||
// Check that clearing the version doesn't trigger registration.
|
|
||||||
clearPaths();
|
|
||||||
Services.prefs.clearUserPref(OPENH264_PREF_VERSION);
|
|
||||||
Assert.deepEqual(addedPaths, []);
|
|
||||||
Assert.deepEqual(removedPaths, [file.path]);
|
|
||||||
|
|
||||||
// Restarting with no version set should not trigger registration.
|
|
||||||
clearPaths();
|
|
||||||
yield promiseRestartManager();
|
|
||||||
Assert.equal(addedPaths.indexOf(file.path), -1);
|
|
||||||
Assert.equal(removedPaths.indexOf(file.path), -1);
|
|
||||||
|
|
||||||
// Changing the pref mid-session should cause unregistration and registration.
|
|
||||||
Services.prefs.setCharPref(OPENH264_PREF_VERSION, TEST_VERSION);
|
|
||||||
clearPaths();
|
|
||||||
const TEST_VERSION_2 = "5.6.7.8";
|
|
||||||
let file2 = Services.dirsvc.get("ProfD", Ci.nsIFile);
|
|
||||||
file2.append(OPENH264_PLUGIN_ID);
|
|
||||||
file2.append(TEST_VERSION_2);
|
|
||||||
Services.prefs.setCharPref(OPENH264_PREF_VERSION, TEST_VERSION_2);
|
|
||||||
Assert.deepEqual(addedPaths, [file2.path]);
|
|
||||||
Assert.deepEqual(removedPaths, [file.path]);
|
|
||||||
|
|
||||||
// Disabling OpenH264 should cause unregistration.
|
|
||||||
Services.prefs.setCharPref(OPENH264_PREF_VERSION, TEST_VERSION);
|
|
||||||
clearPaths();
|
|
||||||
Services.prefs.setBoolPref(OPENH264_PREF_ENABLED, false);
|
|
||||||
Assert.deepEqual(addedPaths, []);
|
|
||||||
Assert.deepEqual(removedPaths, [file.path]);
|
|
||||||
|
|
||||||
// Restarting with OpenH264 disabled should not cause registration.
|
|
||||||
clearPaths();
|
|
||||||
yield promiseRestartManager();
|
|
||||||
Assert.equal(addedPaths.indexOf(file.path), -1);
|
|
||||||
Assert.equal(removedPaths.indexOf(file.path), -1);
|
|
||||||
|
|
||||||
// Re-enabling OpenH264 should cause registration.
|
|
||||||
clearPaths();
|
|
||||||
Services.prefs.setBoolPref(OPENH264_PREF_ENABLED, true);
|
|
||||||
Assert.deepEqual(addedPaths, [file.path]);
|
|
||||||
Assert.deepEqual(removedPaths, []);
|
|
||||||
});
|
|
||||||
|
|
||||||
add_task(function* test_periodicUpdate() {
|
|
||||||
let GMPScope = Cu.import("resource://gre/modules/addons/GMPProvider.jsm");
|
|
||||||
Object.defineProperty(GMPScope, "GMPInstallManager", {
|
|
||||||
value: MockGMPInstallManager,
|
|
||||||
writable: true,
|
|
||||||
enumerable: true,
|
|
||||||
configurable: true
|
|
||||||
});
|
|
||||||
|
|
||||||
Services.prefs.clearUserPref(OPENH264_PREF_AUTOUPDATE);
|
|
||||||
let addons = yield promiseAddonsByIDs([OPENH264_PLUGIN_ID]);
|
|
||||||
let prefs = Services.prefs;
|
|
||||||
Assert.equal(addons.length, 1);
|
|
||||||
let addon = addons[0];
|
|
||||||
|
|
||||||
addon.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DISABLE;
|
|
||||||
Services.prefs.setIntPref(GMP_PREF_LASTCHECK, 0);
|
|
||||||
let result = yield addon.findUpdates({}, AddonManager.UPDATE_WHEN_PERIODIC_UPDATE);
|
|
||||||
Assert.strictEqual(result, false);
|
|
||||||
|
|
||||||
addon.applyBackgroundUpdates = AddonManager.AUTOUPDATE_ENABLE;
|
|
||||||
Services.prefs.setIntPref(GMP_PREF_LASTCHECK, Date.now() / 1000 - 60);
|
|
||||||
result = yield addon.findUpdates({}, AddonManager.UPDATE_WHEN_PERIODIC_UPDATE);
|
|
||||||
Assert.strictEqual(result, false);
|
|
||||||
|
|
||||||
Services.prefs.setIntPref(GMP_PREF_LASTCHECK, Date.now() / 1000 - 2 * SEC_IN_A_DAY);
|
|
||||||
gInstalledAddonId = "";
|
|
||||||
result = yield addon.findUpdates({}, AddonManager.UPDATE_WHEN_PERIODIC_UPDATE);
|
|
||||||
Assert.strictEqual(result, true);
|
|
||||||
Assert.equal(gInstalledAddonId, OPENH264_PLUGIN_ID);
|
|
||||||
});
|
|
@ -67,7 +67,7 @@ function run_test() {
|
|||||||
do_test_pending();
|
do_test_pending();
|
||||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
|
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
|
||||||
|
|
||||||
Services.prefs.setBoolPref("media.gmp-gmpopenh264.provider.enabled", false);
|
Services.prefs.setBoolPref("media.gmp-provider.enabled", false);
|
||||||
|
|
||||||
startupManager();
|
startupManager();
|
||||||
AddonManager.addAddonListener(AddonListener);
|
AddonManager.addAddonListener(AddonListener);
|
||||||
|
@ -12,10 +12,10 @@ support-files =
|
|||||||
[test_asyncBlocklistLoad.js]
|
[test_asyncBlocklistLoad.js]
|
||||||
[test_cacheflush.js]
|
[test_cacheflush.js]
|
||||||
[test_DeferredSave.js]
|
[test_DeferredSave.js]
|
||||||
|
[test_gmpProvider.js]
|
||||||
|
run-if = appname == "firefox"
|
||||||
[test_isReady.js]
|
[test_isReady.js]
|
||||||
[test_metadata_update.js]
|
[test_metadata_update.js]
|
||||||
[test_openh264.js]
|
|
||||||
run-if = appname == "firefox"
|
|
||||||
[test_pluginInfoURL.js]
|
[test_pluginInfoURL.js]
|
||||||
[test_provider_markSafe.js]
|
[test_provider_markSafe.js]
|
||||||
[test_provider_shutdown.js]
|
[test_provider_shutdown.js]
|
||||||
|
Loading…
Reference in New Issue
Block a user