diff options
author | Matt A. Tobin <email@mattatobin.com> | 2018-02-11 07:03:16 -0500 |
---|---|---|
committer | Matt A. Tobin <email@mattatobin.com> | 2018-02-11 07:03:16 -0500 |
commit | 203eb0f61a09372310a2a8fb57e169cb3f47800b (patch) | |
tree | 8490329d3dae4de3c7ffd127bce1f65fdc009abd /toolkit/mozapps/extensions/test/xpcshell/test_multiprocessCompatible.js | |
parent | e45706ca3acbb6530419433212becc61d5953a2d (diff) | |
parent | 8f6d3dab81c7f8f97ef197e26ab9439b09735b8f (diff) | |
download | UXP-203eb0f61a09372310a2a8fb57e169cb3f47800b.tar UXP-203eb0f61a09372310a2a8fb57e169cb3f47800b.tar.gz UXP-203eb0f61a09372310a2a8fb57e169cb3f47800b.tar.lz UXP-203eb0f61a09372310a2a8fb57e169cb3f47800b.tar.xz UXP-203eb0f61a09372310a2a8fb57e169cb3f47800b.zip |
Merge branch 'ext-work'FF_Checkpoint_1
Diffstat (limited to 'toolkit/mozapps/extensions/test/xpcshell/test_multiprocessCompatible.js')
-rw-r--r-- | toolkit/mozapps/extensions/test/xpcshell/test_multiprocessCompatible.js | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_multiprocessCompatible.js b/toolkit/mozapps/extensions/test/xpcshell/test_multiprocessCompatible.js new file mode 100644 index 000000000..ab5a976cc --- /dev/null +++ b/toolkit/mozapps/extensions/test/xpcshell/test_multiprocessCompatible.js @@ -0,0 +1,118 @@ +Components.utils.import("resource://testing-common/httpd.js"); +var gServer; + +const profileDir = gProfD.clone(); +profileDir.append("extensions"); + +Services.prefs.setBoolPref(PREF_EM_CHECK_UPDATE_SECURITY, false); + +function build_test(multiprocessCompatible, bootstrap, updateMultiprocessCompatible) { + return function* () { + dump("Running test" + + " multiprocessCompatible: " + multiprocessCompatible + + " bootstrap: " + bootstrap + + " updateMultiprocessCompatible: " + updateMultiprocessCompatible + + "\n"); + + let addonData = { + id: "addon@tests.mozilla.org", + name: "Test Add-on", + version: "1.0", + multiprocessCompatible, + bootstrap, + updateURL: "http://localhost:" + gPort + "/updaterdf", + targetApplications: [{ + id: "xpcshell@tests.mozilla.org", + minVersion: "1", + maxVersion: "1" + }] + } + + gServer.registerPathHandler("/updaterdf", function(request, response) { + let updateData = {}; + updateData[addonData.id] = [{ + version: "1.0", + targetApplications: [{ + id: "xpcshell@tests.mozilla.org", + minVersion: "1", + maxVersion: "1" + }] + }]; + + if (updateMultiprocessCompatible !== undefined) { + updateData[addonData.id][0].multiprocessCompatible = updateMultiprocessCompatible; + } + + response.setStatusLine(request.httpVersion, 200, "OK"); + response.write(createUpdateRDF(updateData)); + }); + + let expectedMPC = updateMultiprocessCompatible === undefined ? + multiprocessCompatible : + updateMultiprocessCompatible; + + let xpifile = createTempXPIFile(addonData); + let install = yield new Promise(resolve => AddonManager.getInstallForFile(xpifile, resolve)); + do_check_eq(install.addon.multiprocessCompatible, multiprocessCompatible); + yield promiseCompleteAllInstalls([install]); + + if (!bootstrap) { + yield promiseRestartManager(); + do_check_true(isExtensionInAddonsList(profileDir, addonData.id)); + do_check_eq(isItemMarkedMPIncompatible(addonData.id), !multiprocessCompatible); + } + + let addon = yield promiseAddonByID(addonData.id); + do_check_neq(addon, null); + do_check_eq(addon.multiprocessCompatible, multiprocessCompatible); + + yield promiseFindAddonUpdates(addon); + + // Should have applied the compatibility change + do_check_eq(addon.multiprocessCompatible, expectedMPC); + yield promiseRestartManager(); + + addon = yield promiseAddonByID(addonData.id); + // Should have persisted the compatibility change + do_check_eq(addon.multiprocessCompatible, expectedMPC); + if (!bootstrap) { + do_check_true(isExtensionInAddonsList(profileDir, addonData.id)); + do_check_eq(isItemMarkedMPIncompatible(addonData.id), !multiprocessCompatible); + } + + addon.uninstall(); + yield promiseRestartManager(); + + gServer.registerPathHandler("/updaterdf", null); + } +} + +/* Builds a set of tests to run the same steps for every combination of: + * The add-on being restartless + * The initial add-on supporting multiprocess + * The update saying the add-on should or should not support multiprocess (or not say anything at all) + */ +for (let bootstrap of [false, true]) { + for (let multiprocessCompatible of [false, true]) { + for (let updateMultiprocessCompatible of [undefined, false, true]) { + add_task(build_test(multiprocessCompatible, bootstrap, updateMultiprocessCompatible)); + } + } +} + +function run_test() { + createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1"); + startupManager(); + + // Create and configure the HTTP server. + gServer = new HttpServer(); + gServer.registerDirectory("/data/", gTmpD); + gServer.start(-1); + gPort = gServer.identity.primaryPort; + + run_next_test(); +} + +function end_test() { + gServer.stop(do_test_finished); +} |