2012-07-11 10:43:56 -07: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 test() {
|
2012-07-13 09:36:00 -07:00
|
|
|
waitForExplicitFinish();
|
|
|
|
|
|
|
|
let manifest = {
|
2012-07-11 10:43:56 -07:00
|
|
|
origin: 'http://example.com',
|
|
|
|
name: "Example Provider",
|
|
|
|
workerURL: "http://example.com/browser/toolkit/components/social/test/browser/worker_social.js"
|
2012-07-13 09:36:00 -07:00
|
|
|
};
|
2012-07-11 10:43:56 -07:00
|
|
|
|
2012-07-13 09:36:00 -07:00
|
|
|
ensureSocialEnabled();
|
2012-07-11 10:43:56 -07:00
|
|
|
|
2012-07-13 09:36:00 -07:00
|
|
|
SocialService.addProvider(manifest, function (provider) {
|
|
|
|
ok(provider.enabled, "provider is initially enabled");
|
2012-09-11 19:48:38 -07:00
|
|
|
let port = provider.getWorkerPort();
|
|
|
|
ok(port, "should be able to get a port from enabled provider");
|
|
|
|
port.close();
|
2012-07-13 09:36:00 -07:00
|
|
|
ok(provider.workerAPI, "should be able to get a workerAPI from enabled provider");
|
2012-07-11 10:43:56 -07:00
|
|
|
|
2012-07-13 09:36:00 -07:00
|
|
|
provider.enabled = false;
|
2012-07-11 10:43:56 -07:00
|
|
|
|
2012-07-13 09:36:00 -07:00
|
|
|
ok(!provider.enabled, "provider is now disabled");
|
2012-09-11 19:48:38 -07:00
|
|
|
port = provider.getWorkerPort();
|
|
|
|
ok(!port, "shouldn't be able to get a port from disabled provider");
|
2012-07-13 09:36:00 -07:00
|
|
|
ok(!provider.workerAPI, "shouldn't be able to get a workerAPI from disabled provider");
|
2012-07-11 10:43:56 -07:00
|
|
|
|
2012-07-13 09:36:00 -07:00
|
|
|
provider.enabled = true;
|
2012-07-11 10:43:56 -07:00
|
|
|
|
2012-07-13 09:36:00 -07:00
|
|
|
ok(provider.enabled, "provider is re-enabled");
|
2012-09-11 19:48:38 -07:00
|
|
|
let port = provider.getWorkerPort();
|
|
|
|
ok(port, "should be able to get a port from re-enabled provider");
|
|
|
|
port.close();
|
2012-07-13 09:36:00 -07:00
|
|
|
ok(provider.workerAPI, "should be able to get a workerAPI from re-enabled provider");
|
|
|
|
|
|
|
|
SocialService.removeProvider(provider.origin, finish);
|
|
|
|
});
|
2012-07-11 10:43:56 -07:00
|
|
|
}
|