gecko/browser/base/content/test/social/head.js

202 lines
7.3 KiB
JavaScript
Raw Normal View History

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
/* 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/. */
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Promise",
"resource://gre/modules/commonjs/sdk/core/promise.js");
XPCOMUtils.defineLazyModuleGetter(this, "Task",
"resource://gre/modules/Task.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
"resource://gre/modules/PlacesUtils.jsm");
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
function waitForCondition(condition, nextTest, errorMsg) {
var tries = 0;
var interval = setInterval(function() {
if (tries >= 30) {
ok(false, errorMsg);
moveOn();
}
if (condition()) {
moveOn();
}
tries++;
}, 100);
var moveOn = function() { clearInterval(interval); nextTest(); };
}
// Check that a specified (string) URL hasn't been "remembered" (ie, is not
// in history, will not appear in about:newtab or auto-complete, etc.)
function promiseSocialUrlNotRemembered(url) {
let deferred = Promise.defer();
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
let uri = Services.io.newURI(url, null, null);
PlacesUtils.asyncHistory.isURIVisited(uri, function(aURI, aIsVisited) {
ok(!aIsVisited, "social URL " + url + " should not be in global history");
deferred.resolve();
});
return deferred.promise;
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
}
let gURLsNotRemembered = [];
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
function runSocialTestWithProvider(manifest, callback) {
let SocialService = Cu.import("resource://gre/modules/SocialService.jsm", {}).SocialService;
let manifests = Array.isArray(manifest) ? manifest : [manifest];
// Check that none of the provider's content ends up in history.
function finishCleanUp() {
for (let i = 0; i < manifests.length; i++) {
let m = manifests[i];
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
for (let what of ['sidebarURL', 'workerURL', 'iconURL']) {
if (m[what]) {
yield promiseSocialUrlNotRemembered(m[what]);
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
}
};
}
for (let i = 0; i < gURLsNotRemembered.length; i++) {
yield promiseSocialUrlNotRemembered(gURLsNotRemembered[i]);
}
gURLsNotRemembered = [];
}
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
info("runSocialTestWithProvider: " + manifests.toSource());
let finishCount = 0;
function finishIfDone(callFinish) {
finishCount++;
if (finishCount == manifests.length)
Task.spawn(finishCleanUp).then(finish);
}
function removeAddedProviders(cleanup) {
manifests.forEach(function (m) {
// If we're "cleaning up", don't call finish when done.
let callback = cleanup ? function () {} : finishIfDone;
// Similarly, if we're cleaning up, catch exceptions from removeProvider
let removeProvider = SocialService.removeProvider.bind(SocialService);
if (cleanup) {
removeProvider = function (origin, cb) {
try {
SocialService.removeProvider(origin, cb);
} catch (ex) {
// Ignore "provider doesn't exist" errors.
if (ex.message == "SocialService.removeProvider: no provider with this origin exists!")
return;
info("Failed to clean up provider " + origin + ": " + ex);
}
}
}
removeProvider(m.origin, callback);
});
}
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
let providersAdded = 0;
let firstProvider;
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
manifests.forEach(function (m) {
SocialService.addProvider(m, function(provider) {
provider.active = true;
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
providersAdded++;
info("runSocialTestWithProvider: provider added");
// we want to set the first specified provider as the UI's provider
if (provider.origin == manifests[0].origin) {
firstProvider = provider;
}
// If we've added all the providers we need, call the callback to start
// the tests (and give it a callback it can call to finish them)
if (providersAdded == manifests.length) {
// Set the UI's provider and enable the feature
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
Social.provider = firstProvider;
Social.enabled = true;
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
function finishSocialTest(cleanup) {
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
// disable social before removing the providers to avoid providers
// being activated immediately before we get around to removing it.
Services.prefs.clearUserPref("social.enabled");
removeAddedProviders(cleanup);
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
}
registerCleanupFunction(function () {
finishSocialTest(true);
});
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
callback(finishSocialTest);
}
});
});
}
function runSocialTests(tests, cbPreTest, cbPostTest, cbFinish) {
let testIter = Iterator(tests);
if (cbPreTest === undefined) {
cbPreTest = function(cb) {cb()};
}
if (cbPostTest === undefined) {
cbPostTest = function(cb) {cb()};
}
function runNextTest() {
let name, func;
try {
[name, func] = testIter.next();
} catch (err if err instanceof StopIteration) {
// out of items:
(cbFinish || finish)();
return;
}
// We run on a timeout as the frameworker also makes use of timeouts, so
// this helps keep the debug messages sane.
executeSoon(function() {
function cleanupAndRunNextTest() {
info("sub-test " + name + " complete");
cbPostTest(runNextTest);
}
cbPreTest(function() {
info("sub-test " + name + " starting");
try {
func.call(tests, cleanupAndRunNextTest);
} catch (ex) {
ok(false, "sub-test " + name + " failed: " + ex.toString() +"\n"+ex.stack);
cleanupAndRunNextTest();
}
})
});
}
runNextTest();
}
// A fairly large hammer which checks all aspects of the SocialUI for
// internal consistency.
function checkSocialUI(win) {
let win = win || window;
let doc = win.document;
let provider = Social.provider;
let enabled = win.SocialUI.enabled;
function isbool(a, b, msg) {
is(!!a, !!b, msg);
}
isbool(win.SocialSidebar.canShow, enabled, "social sidebar active?");
if (enabled)
isbool(win.SocialSidebar.opened, enabled, "social sidebar open?");
isbool(win.SocialChatBar.isAvailable, enabled && Social.haveLoggedInUser(), "chatbar available?");
isbool(!win.SocialChatBar.chatbar.hidden, enabled && Social.haveLoggedInUser(), "chatbar visible?");
isbool(!win.SocialShareButton.shareButton.hidden, enabled && provider.recommendInfo, "share button visible?");
isbool(!doc.getElementById("social-toolbar-item").hidden, enabled, "toolbar items visible?");
if (enabled)
is(win.SocialToolbar.button.style.listStyleImage, 'url("' + provider.iconURL + '")', "toolbar button has provider icon");
// and for good measure, check all the social commands.
// Social:Remove - never disabled directly but parent nodes are
isbool(!doc.getElementById("Social:Toggle").hidden, enabled, "Social:Toggle visible?");
isbool(!doc.getElementById("Social:ToggleNotifications").hidden, enabled, "Social:ToggleNotifications visible?");
isbool(!doc.getElementById("Social:FocusChat").hidden, enabled && Social.haveLoggedInUser(), "Social:FocusChat visible?");
isbool(doc.getElementById("Social:FocusChat").getAttribute("disabled"), enabled ? "false" : "true", "Social:FocusChat disabled?");
is(doc.getElementById("Social:SharePage").getAttribute("disabled"), enabled && provider.recommendInfo ? "false" : "true", "Social:SharePage visible?");
// broadcasters.
isbool(!doc.getElementById("socialActiveBroadcaster").hidden, enabled, "socialActiveBroadcaster hidden?");
}