1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
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);
do_check_eq(install.addon.mpcOptedOut, multiprocessCompatible === false)
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);
do_check_eq(addon.mpcOptedOut, multiprocessCompatible === false);
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 [undefined, 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);
}
|