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: runSocialTestWithProvider(gProviders, function (finishcb) { michael@0: runSocialTests(tests, undefined, undefined, function() { michael@0: finishcb(); michael@0: }); michael@0: }); michael@0: } michael@0: michael@0: let gProviders = [ michael@0: { 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?provider1", michael@0: workerURL: "https://example.com/browser/browser/base/content/test/social/social_worker.js", michael@0: iconURL: "chrome://branding/content/icon48.png" michael@0: }, michael@0: { michael@0: name: "provider 2", michael@0: origin: "https://test1.example.com", michael@0: sidebarURL: "https://test1.example.com/browser/browser/base/content/test/social/social_sidebar.html?provider2", michael@0: workerURL: "https://test1.example.com/browser/browser/base/content/test/social/social_worker.js", michael@0: iconURL: "chrome://branding/content/icon48.png" michael@0: } michael@0: ]; michael@0: michael@0: var tests = { michael@0: testWorkersAlive: function(next) { michael@0: // verify we can get a message from all providers that are enabled michael@0: let messageReceived = 0; michael@0: function oneWorkerTest(provider) { michael@0: let port = provider.getWorkerPort(); michael@0: port.onmessage = function (e) { michael@0: let topic = e.data.topic; michael@0: switch (topic) { michael@0: case "test-init-done": michael@0: ok(true, "got message from provider " + provider.name); michael@0: port.close(); michael@0: messageReceived++; michael@0: break; michael@0: } michael@0: }; michael@0: port.postMessage({topic: "test-init"}); michael@0: } michael@0: michael@0: for (let p of Social.providers) { michael@0: oneWorkerTest(p); michael@0: } michael@0: michael@0: waitForCondition(function() messageReceived == Social.providers.length, michael@0: next, "received messages from all workers"); michael@0: }, michael@0: michael@0: testMultipleWorkerEnabling: function(next) { michael@0: // test that all workers are enabled when we allow multiple workers michael@0: for (let p of Social.providers) { michael@0: ok(p.enabled, "provider enabled"); michael@0: let port = p.getWorkerPort(); michael@0: ok(port, "worker enabled"); michael@0: port.close(); michael@0: } michael@0: next(); michael@0: } michael@0: }