2012-07-13 13:51:35 -07:00
|
|
|
/* 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",
|
2012-08-20 14:18:50 -07:00
|
|
|
origin: "https://example.com",
|
|
|
|
sidebarURL: "https://example.com/browser/browser/base/content/test/social_sidebar.html",
|
|
|
|
workerURL: "https://example.com/browser/browser/base/content/test/social_worker.js",
|
2012-07-13 13:51:35 -07:00
|
|
|
iconURL: "chrome://branding/content/icon48.png"
|
|
|
|
};
|
2012-08-08 18:09:37 -07:00
|
|
|
runSocialTestWithProvider(manifest, function (finishcb) {
|
|
|
|
runSocialTests(tests, undefined, undefined, finishcb);
|
2012-07-24 14:29:46 -07:00
|
|
|
});
|
2012-07-13 13:51:35 -07:00
|
|
|
}
|
|
|
|
|
2012-07-24 14:29:46 -07:00
|
|
|
var tests = {
|
|
|
|
testStatusIcons: function(next) {
|
|
|
|
let iconsReady = false;
|
|
|
|
let gotSidebarMessage = false;
|
2012-07-13 13:51:35 -07:00
|
|
|
|
2012-07-24 14:29:46 -07:00
|
|
|
function checkNext() {
|
|
|
|
if (iconsReady && gotSidebarMessage)
|
|
|
|
triggerIconPanel();
|
|
|
|
}
|
2012-07-13 13:51:35 -07:00
|
|
|
|
2012-07-24 14:29:46 -07:00
|
|
|
function triggerIconPanel() {
|
|
|
|
let statusIcons = document.getElementById("social-status-iconbox");
|
2012-09-11 19:48:38 -07:00
|
|
|
waitForCondition(function() statusIcons.firstChild && !statusIcons.firstChild.hidden,
|
|
|
|
function() {
|
|
|
|
// Click the button to trigger its contentPanel
|
|
|
|
let panel = document.getElementById("social-notification-panel");
|
|
|
|
EventUtils.synthesizeMouseAtCenter(statusIcons.firstChild, {});
|
|
|
|
}, "Status icon didn't become non-hidden");
|
2012-07-24 14:29:46 -07:00
|
|
|
}
|
2012-07-13 13:51:35 -07:00
|
|
|
|
2012-09-11 19:48:38 -07:00
|
|
|
let port = Social.provider.getWorkerPort();
|
2012-07-24 14:29:46 -07:00
|
|
|
ok(port, "provider has a port");
|
2012-08-20 11:25:47 -07:00
|
|
|
port.onmessage = function (e) {
|
2012-07-24 14:29:46 -07:00
|
|
|
let topic = e.data.topic;
|
|
|
|
switch (topic) {
|
2012-09-11 19:48:38 -07:00
|
|
|
case "test-init-done":
|
|
|
|
iconsReady = true;
|
|
|
|
checkNext();
|
|
|
|
break;
|
2012-07-24 14:29:46 -07:00
|
|
|
case "got-panel-message":
|
|
|
|
ok(true, "got panel message");
|
2012-08-24 20:54:03 -07:00
|
|
|
// Check the panel isn't in our history.
|
|
|
|
ensureSocialUrlNotRemembered(e.data.location);
|
2012-07-24 14:29:46 -07:00
|
|
|
break;
|
2012-08-20 11:25:47 -07:00
|
|
|
case "got-social-panel-visibility":
|
|
|
|
if (e.data.result == "shown") {
|
|
|
|
ok(true, "panel shown");
|
|
|
|
let panel = document.getElementById("social-notification-panel");
|
|
|
|
panel.hidePopup();
|
|
|
|
} else if (e.data.result == "hidden") {
|
|
|
|
ok(true, "panel hidden");
|
2012-09-11 19:48:38 -07:00
|
|
|
port.close();
|
2012-08-20 11:25:47 -07:00
|
|
|
next();
|
|
|
|
}
|
2012-08-26 16:51:24 -07:00
|
|
|
break;
|
2012-07-24 14:29:46 -07:00
|
|
|
case "got-sidebar-message":
|
|
|
|
// The sidebar message will always come first, since it loads by default
|
|
|
|
ok(true, "got sidebar message");
|
|
|
|
gotSidebarMessage = true;
|
2012-09-06 13:14:34 -07:00
|
|
|
// load a status panel
|
|
|
|
port.postMessage({topic: "test-ambient-notification"});
|
2012-07-24 14:29:46 -07:00
|
|
|
checkNext();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-08-20 11:25:47 -07:00
|
|
|
port.postMessage({topic: "test-init"});
|
2012-07-13 13:51:35 -07:00
|
|
|
}
|
|
|
|
}
|