Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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/. */
5 function test() {
6 waitForExplicitFinish();
8 let manifest = { // normal provider
9 name: "provider 1",
10 origin: "https://example.com",
11 sidebarURL: "https://example.com/browser/browser/base/content/test/social/social_sidebar.html",
12 workerURL: "https://example.com/browser/browser/base/content/test/social/social_worker.js",
13 iconURL: "https://example.com/browser/browser/base/content/test/general/moz.png"
14 };
15 runSocialTestWithProvider(manifest, function (finishcb) {
16 SocialSidebar.show();
17 runSocialTests(tests, undefined, undefined, finishcb);
18 });
19 }
21 var tests = {
22 testSidebarMessage: function(next) {
23 let port = SocialSidebar.provider.getWorkerPort();
24 ok(port, "provider has a port");
25 port.postMessage({topic: "test-init"});
26 port.onmessage = function (e) {
27 let topic = e.data.topic;
28 switch (topic) {
29 case "got-sidebar-message":
30 // The sidebar message will always come first, since it loads by default
31 ok(true, "got sidebar message");
32 port.close();
33 next();
34 break;
35 }
36 };
37 },
38 testIsVisible: function(next) {
39 let port = SocialSidebar.provider.getWorkerPort();
40 port.postMessage({topic: "test-init"});
41 port.onmessage = function (e) {
42 let topic = e.data.topic;
43 switch (topic) {
44 case "got-isVisible-response":
45 is(e.data.result, true, "Sidebar should be visible by default");
46 SocialSidebar.toggleSidebar();
47 port.close();
48 next();
49 }
50 };
51 port.postMessage({topic: "test-isVisible"});
52 },
53 testIsNotVisible: function(next) {
54 let port = SocialSidebar.provider.getWorkerPort();
55 port.postMessage({topic: "test-init"});
56 port.onmessage = function (e) {
57 let topic = e.data.topic;
58 switch (topic) {
59 case "got-isVisible-response":
60 is(e.data.result, false, "Sidebar should be hidden");
61 port.close();
62 next();
63 }
64 };
65 port.postMessage({topic: "test-isVisible"});
66 }
67 }