gecko/browser/base/content/test/social/browser_social_isVisible.js
Gavin Sharp c44b1b1a68 Bug 820273 - Move social tests to make them easier to run alone. r=felipe
--HG--
rename : browser/base/content/test/browser_social.js => browser/base/content/test/social/browser_social.js
rename : browser/base/content/test/browser_social_chatwindow.js => browser/base/content/test/social/browser_social_chatwindow.js
rename : browser/base/content/test/browser_social_flyout.js => browser/base/content/test/social/browser_social_flyout.js
rename : browser/base/content/test/browser_social_isVisible.js => browser/base/content/test/social/browser_social_isVisible.js
rename : browser/base/content/test/browser_social_mozSocial_API.js => browser/base/content/test/social/browser_social_mozSocial_API.js
rename : browser/base/content/test/browser_social_shareButton.js => browser/base/content/test/social/browser_social_shareButton.js
rename : browser/base/content/test/browser_social_sidebar.js => browser/base/content/test/social/browser_social_sidebar.js
rename : browser/base/content/test/browser_social_toolbar.js => browser/base/content/test/social/browser_social_toolbar.js
rename : browser/base/content/test/social_chat.html => browser/base/content/test/social/social_chat.html
rename : browser/base/content/test/social_flyout.html => browser/base/content/test/social/social_flyout.html
rename : browser/base/content/test/social_panel.html => browser/base/content/test/social/social_panel.html
rename : browser/base/content/test/social_share_image.png => browser/base/content/test/social/social_share_image.png
rename : browser/base/content/test/social_sidebar.html => browser/base/content/test/social/social_sidebar.html
rename : browser/base/content/test/social_window.html => browser/base/content/test/social/social_window.html
rename : browser/base/content/test/social_worker.js => browser/base/content/test/social/social_worker.js
2012-12-08 04:28:54 -08:00

68 lines
2.2 KiB
JavaScript

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