1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/base/content/test/social/browser_social_isVisible.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,67 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +function test() { 1.9 + waitForExplicitFinish(); 1.10 + 1.11 + let manifest = { // normal provider 1.12 + name: "provider 1", 1.13 + origin: "https://example.com", 1.14 + sidebarURL: "https://example.com/browser/browser/base/content/test/social/social_sidebar.html", 1.15 + workerURL: "https://example.com/browser/browser/base/content/test/social/social_worker.js", 1.16 + iconURL: "https://example.com/browser/browser/base/content/test/general/moz.png" 1.17 + }; 1.18 + runSocialTestWithProvider(manifest, function (finishcb) { 1.19 + SocialSidebar.show(); 1.20 + runSocialTests(tests, undefined, undefined, finishcb); 1.21 + }); 1.22 +} 1.23 + 1.24 +var tests = { 1.25 + testSidebarMessage: function(next) { 1.26 + let port = SocialSidebar.provider.getWorkerPort(); 1.27 + ok(port, "provider has a port"); 1.28 + port.postMessage({topic: "test-init"}); 1.29 + port.onmessage = function (e) { 1.30 + let topic = e.data.topic; 1.31 + switch (topic) { 1.32 + case "got-sidebar-message": 1.33 + // The sidebar message will always come first, since it loads by default 1.34 + ok(true, "got sidebar message"); 1.35 + port.close(); 1.36 + next(); 1.37 + break; 1.38 + } 1.39 + }; 1.40 + }, 1.41 + testIsVisible: function(next) { 1.42 + let port = SocialSidebar.provider.getWorkerPort(); 1.43 + port.postMessage({topic: "test-init"}); 1.44 + port.onmessage = function (e) { 1.45 + let topic = e.data.topic; 1.46 + switch (topic) { 1.47 + case "got-isVisible-response": 1.48 + is(e.data.result, true, "Sidebar should be visible by default"); 1.49 + SocialSidebar.toggleSidebar(); 1.50 + port.close(); 1.51 + next(); 1.52 + } 1.53 + }; 1.54 + port.postMessage({topic: "test-isVisible"}); 1.55 + }, 1.56 + testIsNotVisible: function(next) { 1.57 + let port = SocialSidebar.provider.getWorkerPort(); 1.58 + port.postMessage({topic: "test-init"}); 1.59 + port.onmessage = function (e) { 1.60 + let topic = e.data.topic; 1.61 + switch (topic) { 1.62 + case "got-isVisible-response": 1.63 + is(e.data.result, false, "Sidebar should be hidden"); 1.64 + port.close(); 1.65 + next(); 1.66 + } 1.67 + }; 1.68 + port.postMessage({topic: "test-isVisible"}); 1.69 + } 1.70 +}