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.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | function test() { |
michael@0 | 6 | waitForExplicitFinish(); |
michael@0 | 7 | |
michael@0 | 8 | let manifest = { // normal provider |
michael@0 | 9 | name: "provider 1", |
michael@0 | 10 | origin: "https://example.com", |
michael@0 | 11 | sidebarURL: "https://example.com/browser/browser/base/content/test/social/social_sidebar.html", |
michael@0 | 12 | workerURL: "https://example.com/browser/browser/base/content/test/social/social_worker.js", |
michael@0 | 13 | iconURL: "https://example.com/browser/browser/base/content/test/general/moz.png" |
michael@0 | 14 | }; |
michael@0 | 15 | runSocialTestWithProvider(manifest, function (finishcb) { |
michael@0 | 16 | SocialSidebar.show(); |
michael@0 | 17 | runSocialTests(tests, undefined, undefined, finishcb); |
michael@0 | 18 | }); |
michael@0 | 19 | } |
michael@0 | 20 | |
michael@0 | 21 | var tests = { |
michael@0 | 22 | testSidebarMessage: function(next) { |
michael@0 | 23 | let port = SocialSidebar.provider.getWorkerPort(); |
michael@0 | 24 | ok(port, "provider has a port"); |
michael@0 | 25 | port.postMessage({topic: "test-init"}); |
michael@0 | 26 | port.onmessage = function (e) { |
michael@0 | 27 | let topic = e.data.topic; |
michael@0 | 28 | switch (topic) { |
michael@0 | 29 | case "got-sidebar-message": |
michael@0 | 30 | // The sidebar message will always come first, since it loads by default |
michael@0 | 31 | ok(true, "got sidebar message"); |
michael@0 | 32 | port.close(); |
michael@0 | 33 | next(); |
michael@0 | 34 | break; |
michael@0 | 35 | } |
michael@0 | 36 | }; |
michael@0 | 37 | }, |
michael@0 | 38 | testIsVisible: function(next) { |
michael@0 | 39 | let port = SocialSidebar.provider.getWorkerPort(); |
michael@0 | 40 | port.postMessage({topic: "test-init"}); |
michael@0 | 41 | port.onmessage = function (e) { |
michael@0 | 42 | let topic = e.data.topic; |
michael@0 | 43 | switch (topic) { |
michael@0 | 44 | case "got-isVisible-response": |
michael@0 | 45 | is(e.data.result, true, "Sidebar should be visible by default"); |
michael@0 | 46 | SocialSidebar.toggleSidebar(); |
michael@0 | 47 | port.close(); |
michael@0 | 48 | next(); |
michael@0 | 49 | } |
michael@0 | 50 | }; |
michael@0 | 51 | port.postMessage({topic: "test-isVisible"}); |
michael@0 | 52 | }, |
michael@0 | 53 | testIsNotVisible: function(next) { |
michael@0 | 54 | let port = SocialSidebar.provider.getWorkerPort(); |
michael@0 | 55 | port.postMessage({topic: "test-init"}); |
michael@0 | 56 | port.onmessage = function (e) { |
michael@0 | 57 | let topic = e.data.topic; |
michael@0 | 58 | switch (topic) { |
michael@0 | 59 | case "got-isVisible-response": |
michael@0 | 60 | is(e.data.result, false, "Sidebar should be hidden"); |
michael@0 | 61 | port.close(); |
michael@0 | 62 | next(); |
michael@0 | 63 | } |
michael@0 | 64 | }; |
michael@0 | 65 | port.postMessage({topic: "test-isVisible"}); |
michael@0 | 66 | } |
michael@0 | 67 | } |