michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: let manifest = { // normal provider michael@0: name: "provider 1", michael@0: origin: "https://example.com", michael@0: sidebarURL: "https://example.com/browser/browser/base/content/test/social/social_sidebar.html", michael@0: workerURL: "https://example.com/browser/browser/base/content/test/social/social_worker.js", michael@0: iconURL: "https://example.com/browser/browser/base/content/test/general/moz.png" michael@0: }; michael@0: runSocialTestWithProvider(manifest, function (finishcb) { michael@0: SocialSidebar.show(); michael@0: runSocialTests(tests, undefined, undefined, finishcb); michael@0: }); michael@0: } michael@0: michael@0: var tests = { michael@0: testSidebarMessage: function(next) { michael@0: let port = SocialSidebar.provider.getWorkerPort(); michael@0: ok(port, "provider has a port"); michael@0: port.postMessage({topic: "test-init"}); michael@0: port.onmessage = function (e) { michael@0: let topic = e.data.topic; michael@0: switch (topic) { michael@0: case "got-sidebar-message": michael@0: // The sidebar message will always come first, since it loads by default michael@0: ok(true, "got sidebar message"); michael@0: port.close(); michael@0: next(); michael@0: break; michael@0: } michael@0: }; michael@0: }, michael@0: testIsVisible: function(next) { michael@0: let port = SocialSidebar.provider.getWorkerPort(); michael@0: port.postMessage({topic: "test-init"}); michael@0: port.onmessage = function (e) { michael@0: let topic = e.data.topic; michael@0: switch (topic) { michael@0: case "got-isVisible-response": michael@0: is(e.data.result, true, "Sidebar should be visible by default"); michael@0: SocialSidebar.toggleSidebar(); michael@0: port.close(); michael@0: next(); michael@0: } michael@0: }; michael@0: port.postMessage({topic: "test-isVisible"}); michael@0: }, michael@0: testIsNotVisible: function(next) { michael@0: let port = SocialSidebar.provider.getWorkerPort(); michael@0: port.postMessage({topic: "test-init"}); michael@0: port.onmessage = function (e) { michael@0: let topic = e.data.topic; michael@0: switch (topic) { michael@0: case "got-isVisible-response": michael@0: is(e.data.result, false, "Sidebar should be hidden"); michael@0: port.close(); michael@0: next(); michael@0: } michael@0: }; michael@0: port.postMessage({topic: "test-isVisible"}); michael@0: } michael@0: }