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
|
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
function run_test() {
let ssvc = Cc["@mozilla.org/calendar/startup-service;1"].getService(Ci.nsIObserver);
let first = {
startup(aListener) {
second.canStart = true;
aListener.onResult(null, Cr.NS_OK);
},
shutdown(aListener) {
ok(this.canStop);
aListener.onResult(null, Cr.NS_OK);
},
};
let second = {
startup(aListener) {
ok(this.canStart);
aListener.onResult(null, Cr.NS_OK);
},
shutdown(aListener) {
first.canStop = true;
aListener.onResult(null, Cr.NS_OK);
},
};
// Change the startup order so we can test our services
let oldStartupOrder = ssvc.wrappedJSObject.getStartupOrder;
ssvc.wrappedJSObject.getStartupOrder = function () {
let origOrder = oldStartupOrder.call(this);
let notify = origOrder[origOrder.length - 1];
return [first, second, notify];
};
// Pretend a startup run
ssvc.observe(null, "profile-after-change", null);
ok(second.canStart);
// Pretend a stop run
ssvc.observe(null, "profile-before-change", null);
ok(first.canStop);
}
|