2013-04-23 21:58:24 +04:00
|
|
|
/* 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 = Components.classes["@mozilla.org/calendar/startup-service;1"]
|
|
|
|
.getService(Components.interfaces.nsIObserver);
|
|
|
|
|
|
|
|
let first = {
|
|
|
|
startup: function(aListener) {
|
|
|
|
second.canStart = true;
|
|
|
|
aListener.onResult(null, Cr.NS_OK);
|
|
|
|
},
|
|
|
|
shutdown: function(aListener) {
|
2015-02-23 03:24:29 +03:00
|
|
|
ok(this.canStop);
|
2013-04-23 21:58:24 +04:00
|
|
|
aListener.onResult(null, Cr.NS_OK);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
let second = {
|
|
|
|
startup: function(aListener) {
|
2015-02-23 03:24:29 +03:00
|
|
|
ok(this.canStart);
|
2013-04-23 21:58:24 +04:00
|
|
|
aListener.onResult(null, Cr.NS_OK);
|
|
|
|
},
|
|
|
|
shutdown: function(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);
|
2015-02-23 03:24:29 +03:00
|
|
|
ok(second.canStart);
|
2013-04-23 21:58:24 +04:00
|
|
|
|
|
|
|
// Pretend a stop run
|
|
|
|
ssvc.observe(null, "profile-before-change", null);
|
2015-02-23 03:24:29 +03:00
|
|
|
ok(first.canStop);
|
2013-04-23 21:58:24 +04:00
|
|
|
}
|