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 | runSocialTestWithProvider(gProviders, function (finishcb) { |
michael@0 | 9 | runSocialTests(tests, undefined, undefined, function() { |
michael@0 | 10 | finishcb(); |
michael@0 | 11 | }); |
michael@0 | 12 | }); |
michael@0 | 13 | } |
michael@0 | 14 | |
michael@0 | 15 | let gProviders = [ |
michael@0 | 16 | { |
michael@0 | 17 | name: "provider 1", |
michael@0 | 18 | origin: "https://example.com", |
michael@0 | 19 | sidebarURL: "https://example.com/browser/browser/base/content/test/social/social_sidebar.html?provider1", |
michael@0 | 20 | workerURL: "https://example.com/browser/browser/base/content/test/social/social_worker.js", |
michael@0 | 21 | iconURL: "chrome://branding/content/icon48.png" |
michael@0 | 22 | }, |
michael@0 | 23 | { |
michael@0 | 24 | name: "provider 2", |
michael@0 | 25 | origin: "https://test1.example.com", |
michael@0 | 26 | sidebarURL: "https://test1.example.com/browser/browser/base/content/test/social/social_sidebar.html?provider2", |
michael@0 | 27 | workerURL: "https://test1.example.com/browser/browser/base/content/test/social/social_worker.js", |
michael@0 | 28 | iconURL: "chrome://branding/content/icon48.png" |
michael@0 | 29 | } |
michael@0 | 30 | ]; |
michael@0 | 31 | |
michael@0 | 32 | var tests = { |
michael@0 | 33 | testWorkersAlive: function(next) { |
michael@0 | 34 | // verify we can get a message from all providers that are enabled |
michael@0 | 35 | let messageReceived = 0; |
michael@0 | 36 | function oneWorkerTest(provider) { |
michael@0 | 37 | let port = provider.getWorkerPort(); |
michael@0 | 38 | port.onmessage = function (e) { |
michael@0 | 39 | let topic = e.data.topic; |
michael@0 | 40 | switch (topic) { |
michael@0 | 41 | case "test-init-done": |
michael@0 | 42 | ok(true, "got message from provider " + provider.name); |
michael@0 | 43 | port.close(); |
michael@0 | 44 | messageReceived++; |
michael@0 | 45 | break; |
michael@0 | 46 | } |
michael@0 | 47 | }; |
michael@0 | 48 | port.postMessage({topic: "test-init"}); |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | for (let p of Social.providers) { |
michael@0 | 52 | oneWorkerTest(p); |
michael@0 | 53 | } |
michael@0 | 54 | |
michael@0 | 55 | waitForCondition(function() messageReceived == Social.providers.length, |
michael@0 | 56 | next, "received messages from all workers"); |
michael@0 | 57 | }, |
michael@0 | 58 | |
michael@0 | 59 | testMultipleWorkerEnabling: function(next) { |
michael@0 | 60 | // test that all workers are enabled when we allow multiple workers |
michael@0 | 61 | for (let p of Social.providers) { |
michael@0 | 62 | ok(p.enabled, "provider enabled"); |
michael@0 | 63 | let port = p.getWorkerPort(); |
michael@0 | 64 | ok(port, "worker enabled"); |
michael@0 | 65 | port.close(); |
michael@0 | 66 | } |
michael@0 | 67 | next(); |
michael@0 | 68 | } |
michael@0 | 69 | } |