|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 function test() { |
|
6 waitForExplicitFinish(); |
|
7 |
|
8 runSocialTestWithProvider(gProviders, function (finishcb) { |
|
9 runSocialTests(tests, undefined, undefined, function() { |
|
10 finishcb(); |
|
11 }); |
|
12 }); |
|
13 } |
|
14 |
|
15 let gProviders = [ |
|
16 { |
|
17 name: "provider 1", |
|
18 origin: "https://example.com", |
|
19 sidebarURL: "https://example.com/browser/browser/base/content/test/social/social_sidebar.html?provider1", |
|
20 workerURL: "https://example.com/browser/browser/base/content/test/social/social_worker.js", |
|
21 iconURL: "chrome://branding/content/icon48.png" |
|
22 }, |
|
23 { |
|
24 name: "provider 2", |
|
25 origin: "https://test1.example.com", |
|
26 sidebarURL: "https://test1.example.com/browser/browser/base/content/test/social/social_sidebar.html?provider2", |
|
27 workerURL: "https://test1.example.com/browser/browser/base/content/test/social/social_worker.js", |
|
28 iconURL: "chrome://branding/content/icon48.png" |
|
29 } |
|
30 ]; |
|
31 |
|
32 var tests = { |
|
33 testWorkersAlive: function(next) { |
|
34 // verify we can get a message from all providers that are enabled |
|
35 let messageReceived = 0; |
|
36 function oneWorkerTest(provider) { |
|
37 let port = provider.getWorkerPort(); |
|
38 port.onmessage = function (e) { |
|
39 let topic = e.data.topic; |
|
40 switch (topic) { |
|
41 case "test-init-done": |
|
42 ok(true, "got message from provider " + provider.name); |
|
43 port.close(); |
|
44 messageReceived++; |
|
45 break; |
|
46 } |
|
47 }; |
|
48 port.postMessage({topic: "test-init"}); |
|
49 } |
|
50 |
|
51 for (let p of Social.providers) { |
|
52 oneWorkerTest(p); |
|
53 } |
|
54 |
|
55 waitForCondition(function() messageReceived == Social.providers.length, |
|
56 next, "received messages from all workers"); |
|
57 }, |
|
58 |
|
59 testMultipleWorkerEnabling: function(next) { |
|
60 // test that all workers are enabled when we allow multiple workers |
|
61 for (let p of Social.providers) { |
|
62 ok(p.enabled, "provider enabled"); |
|
63 let port = p.getWorkerPort(); |
|
64 ok(port, "worker enabled"); |
|
65 port.close(); |
|
66 } |
|
67 next(); |
|
68 } |
|
69 } |