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
This commit is contained in:
Gavin Sharp 2012-12-08 04:28:54 -08:00
parent 3b897d976a
commit c44b1b1a68
21 changed files with 199 additions and 158 deletions

View File

@ -10,6 +10,7 @@ relativesrcdir = @relativesrcdir@
DIRS += \ DIRS += \
newtab \ newtab \
social \
$(NULL) $(NULL)
include $(DEPTH)/config/autoconf.mk include $(DEPTH)/config/autoconf.mk
@ -286,22 +287,6 @@ _BROWSER_FILES = \
blockPluginVulnerableNoUpdate.xml \ blockPluginVulnerableNoUpdate.xml \
blockNoPlugins.xml \ blockNoPlugins.xml \
browser_utilityOverlay.js \ browser_utilityOverlay.js \
browser_social.js \
browser_social_toolbar.js \
browser_social_shareButton.js \
browser_social_sidebar.js \
browser_social_flyout.js \
browser_social_mozSocial_API.js \
browser_social_isVisible.js \
browser_social_chatwindow.js \
browser_social_multiprovider.js \
social_panel.html \
social_share_image.png \
social_sidebar.html \
social_chat.html \
social_flyout.html \
social_window.html \
social_worker.js \
browser_bug676619.js \ browser_bug676619.js \
download_page.html \ download_page.html \
$(NULL) $(NULL)

View File

@ -88,15 +88,6 @@ function waitForCondition(condition, nextTest, errorMsg) {
var moveOn = function() { clearInterval(interval); nextTest(); }; 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 ensureSocialUrlNotRemembered(url) {
let gh = Cc["@mozilla.org/browser/global-history;2"]
.getService(Ci.nsIGlobalHistory2);
let uri = Services.io.newURI(url, null, null);
ok(!gh.isVisited(uri), "social URL " + url + " should not be in global history");
}
function getTestPlugin() { function getTestPlugin() {
var ph = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost); var ph = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost);
var tags = ph.getPluginTags(); var tags = ph.getPluginTags();
@ -110,109 +101,6 @@ function getTestPlugin() {
return null; return null;
} }
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.
registerCleanupFunction(function () {
manifests.forEach(function (m) {
for (let what of ['sidebarURL', 'workerURL', 'iconURL']) {
if (m[what]) {
ensureSocialUrlNotRemembered(m[what]);
}
}
});
});
info("runSocialTestWithProvider: " + manifests.toSource());
let providersAdded = 0;
let firstProvider;
manifests.forEach(function (m) {
SocialService.addProvider(m, function(provider) {
provider.active = true;
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
Social.provider = firstProvider;
Social.enabled = true;
registerCleanupFunction(function () {
// disable social before removing the providers to avoid providers
// being activated immediately before we get around to removing it.
Services.prefs.clearUserPref("social.enabled");
// if one test happens to fail, it is likely finishSocialTest will not
// be called, causing most future social tests to also fail as they
// attempt to add a provider which already exists - so work
// around that by also attempting to remove the test provider.
manifests.forEach(function (m) {
try {
SocialService.removeProvider(m.origin, finish);
} catch (ex) {}
});
});
function finishSocialTest() {
SocialService.removeProvider(provider.origin, finish);
}
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();
}
function updateBlocklist(aCallback) { function updateBlocklist(aCallback) {
var blocklistNotifier = Cc["@mozilla.org/extensions/blocklist;1"] var blocklistNotifier = Cc["@mozilla.org/extensions/blocklist;1"]
.getService(Ci.nsITimerCallback); .getService(Ci.nsITimerCallback);

View File

@ -0,0 +1,36 @@
# 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/.
DEPTH = @DEPTH@
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = @relativesrcdir@
include $(DEPTH)/config/autoconf.mk
_BROWSER_FILES = \
head.js \
browser_social.js \
browser_social_toolbar.js \
browser_social_shareButton.js \
browser_social_sidebar.js \
browser_social_flyout.js \
browser_social_mozSocial_API.js \
browser_social_isVisible.js \
browser_social_chatwindow.js \
browser_social_multiprovider.js \
social_panel.html \
social_share_image.png \
social_sidebar.html \
social_chat.html \
social_flyout.html \
social_window.html \
social_worker.js \
$(NULL)
include $(topsrcdir)/config/rules.mk
libs:: $(_BROWSER_FILES)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/browser/$(relativesrcdir)

View File

@ -30,8 +30,8 @@ function test() {
let manifest = { // normal provider let manifest = { // normal provider
name: "provider 1", name: "provider 1",
origin: "https://example.com", origin: "https://example.com",
sidebarURL: "https://example.com/browser/browser/base/content/test/social_sidebar.html", sidebarURL: "https://example.com/browser/browser/base/content/test/social/social_sidebar.html",
workerURL: "https://example.com/browser/browser/base/content/test/social_worker.js", workerURL: "https://example.com/browser/browser/base/content/test/social/social_worker.js",
iconURL: "https://example.com/browser/browser/base/content/test/moz.png" iconURL: "https://example.com/browser/browser/base/content/test/moz.png"
}; };
runSocialTestWithProvider(manifest, function (finishcb) { runSocialTestWithProvider(manifest, function (finishcb) {
@ -53,6 +53,7 @@ var tests = {
togglePrivateBrowsing(function () { togglePrivateBrowsing(function () {
ok(!Social.enabled, "Social shuts down during private browsing"); ok(!Social.enabled, "Social shuts down during private browsing");
togglePrivateBrowsing(function () { togglePrivateBrowsing(function () {
ok(Social.provider.getWorkerPort(), "port still obtainable after PB")
ok(Social.enabled, "Social enabled after private browsing"); ok(Social.enabled, "Social enabled after private browsing");
next(); next();
}); });
@ -66,6 +67,7 @@ var tests = {
// test PB from the perspective of entering PB without social enabled // test PB from the perspective of entering PB without social enabled
// we expect social to be enabled at the start of the test, we need // we expect social to be enabled at the start of the test, we need
// to disable it before testing PB transitions. // to disable it before testing PB transitions.
ok(Social.enabled, "social is still enabled");
let port = Social.provider.getWorkerPort(); let port = Social.provider.getWorkerPort();
ok(port, "provider has a port"); ok(port, "provider has a port");
port.postMessage({topic: "test-init"}); port.postMessage({topic: "test-init"});

View File

@ -8,8 +8,8 @@ function test() {
let manifest = { // normal provider let manifest = { // normal provider
name: "provider 1", name: "provider 1",
origin: "https://example.com", origin: "https://example.com",
sidebarURL: "https://example.com/browser/browser/base/content/test/social_sidebar.html", sidebarURL: "https://example.com/browser/browser/base/content/test/social/social_sidebar.html",
workerURL: "https://example.com/browser/browser/base/content/test/social_worker.js", workerURL: "https://example.com/browser/browser/base/content/test/social/social_worker.js",
iconURL: "https://example.com/browser/browser/base/content/test/moz.png" iconURL: "https://example.com/browser/browser/base/content/test/moz.png"
}; };
let oldwidth = window.outerWidth; // we futz with this, so we restore it let oldwidth = window.outerWidth; // we futz with this, so we restore it
@ -102,7 +102,7 @@ var tests = {
// The worker then makes the same call again - as that second call also // The worker then makes the same call again - as that second call also
// specifies "minimized" the chat should *not* be restored. // specifies "minimized" the chat should *not* be restored.
testWorkerChatWindowMinimized: function(next) { testWorkerChatWindowMinimized: function(next) {
const chatUrl = "https://example.com/browser/browser/base/content/test/social_chat.html"; const chatUrl = "https://example.com/browser/browser/base/content/test/social/social_chat.html";
let port = Social.provider.getWorkerPort(); let port = Social.provider.getWorkerPort();
let seen_opened = false; let seen_opened = false;
ok(port, "provider has a port"); ok(port, "provider has a port");
@ -175,7 +175,7 @@ var tests = {
} }
}, },
testWorkerChatWindow: function(next) { testWorkerChatWindow: function(next) {
const chatUrl = "https://example.com/browser/browser/base/content/test/social_chat.html"; const chatUrl = "https://example.com/browser/browser/base/content/test/social/social_chat.html";
let port = Social.provider.getWorkerPort(); let port = Social.provider.getWorkerPort();
ok(port, "provider has a port"); ok(port, "provider has a port");
port.postMessage({topic: "test-init"}); port.postMessage({topic: "test-init"});
@ -414,7 +414,7 @@ var tests = {
testSecondTopLevelWindow: function(next) { testSecondTopLevelWindow: function(next) {
// Bug 817782 - check chats work in new top-level windows. // Bug 817782 - check chats work in new top-level windows.
const chatUrl = "https://example.com/browser/browser/base/content/test/social_chat.html"; const chatUrl = "https://example.com/browser/browser/base/content/test/social/social_chat.html";
let port = Social.provider.getWorkerPort(); let port = Social.provider.getWorkerPort();
let secondWindow; let secondWindow;
port.onmessage = function(e) { port.onmessage = function(e) {
@ -437,7 +437,7 @@ var tests = {
testChatWindowChooser: function(next) { testChatWindowChooser: function(next) {
// Tests that when a worker creates a chat, it is opened in the correct // Tests that when a worker creates a chat, it is opened in the correct
// window. // window.
const chatUrl = "https://example.com/browser/browser/base/content/test/social_chat.html"; const chatUrl = "https://example.com/browser/browser/base/content/test/social/social_chat.html";
let chatId = 1; let chatId = 1;
let port = Social.provider.getWorkerPort(); let port = Social.provider.getWorkerPort();
port.postMessage({topic: "test-init"}); port.postMessage({topic: "test-init"});
@ -481,7 +481,7 @@ var tests = {
// XXX - note this must be the last test until we restore the login state // XXX - note this must be the last test until we restore the login state
// between tests... // between tests...
testCloseOnLogout: function(next) { testCloseOnLogout: function(next) {
const chatUrl = "https://example.com/browser/browser/base/content/test/social_chat.html"; const chatUrl = "https://example.com/browser/browser/base/content/test/social/social_chat.html";
let port = Social.provider.getWorkerPort(); let port = Social.provider.getWorkerPort();
ok(port, "provider has a port"); ok(port, "provider has a port");
port.postMessage({topic: "test-init"}); port.postMessage({topic: "test-init"});
@ -552,7 +552,7 @@ function get3ChatsForCollapsing(mode, cb) {
} }
function makeChat(mode, uniqueid, cb) { function makeChat(mode, uniqueid, cb) {
const chatUrl = "https://example.com/browser/browser/base/content/test/social_chat.html"; const chatUrl = "https://example.com/browser/browser/base/content/test/social/social_chat.html";
let provider = Social.provider; let provider = Social.provider;
window.SocialChatBar.openChat(provider, chatUrl + "?id=" + uniqueid, function(chat) { window.SocialChatBar.openChat(provider, chatUrl + "?id=" + uniqueid, function(chat) {
// we can't callback immediately or we might close the chat during // we can't callback immediately or we might close the chat during

View File

@ -8,8 +8,8 @@ function test() {
let manifest = { // normal provider let manifest = { // normal provider
name: "provider 1", name: "provider 1",
origin: "https://example.com", origin: "https://example.com",
sidebarURL: "https://example.com/browser/browser/base/content/test/social_sidebar.html", sidebarURL: "https://example.com/browser/browser/base/content/test/social/social_sidebar.html",
workerURL: "https://example.com/browser/browser/base/content/test/social_worker.js", workerURL: "https://example.com/browser/browser/base/content/test/social/social_worker.js",
iconURL: "https://example.com/browser/browser/base/content/test/moz.png" iconURL: "https://example.com/browser/browser/base/content/test/moz.png"
}; };
runSocialTestWithProvider(manifest, function (finishcb) { runSocialTestWithProvider(manifest, function (finishcb) {

View File

@ -8,8 +8,8 @@ function test() {
let manifest = { // normal provider let manifest = { // normal provider
name: "provider 1", name: "provider 1",
origin: "https://example.com", origin: "https://example.com",
sidebarURL: "https://example.com/browser/browser/base/content/test/social_sidebar.html", sidebarURL: "https://example.com/browser/browser/base/content/test/social/social_sidebar.html",
workerURL: "https://example.com/browser/browser/base/content/test/social_worker.js", workerURL: "https://example.com/browser/browser/base/content/test/social/social_worker.js",
iconURL: "https://example.com/browser/browser/base/content/test/moz.png" iconURL: "https://example.com/browser/browser/base/content/test/moz.png"
}; };
runSocialTestWithProvider(manifest, function (finishcb) { runSocialTestWithProvider(manifest, function (finishcb) {

View File

@ -8,8 +8,8 @@ function test() {
let manifest = { // normal provider let manifest = { // normal provider
name: "provider 1", name: "provider 1",
origin: "https://example.com", origin: "https://example.com",
sidebarURL: "https://example.com/browser/browser/base/content/test/social_sidebar.html", sidebarURL: "https://example.com/browser/browser/base/content/test/social/social_sidebar.html",
workerURL: "https://example.com/browser/browser/base/content/test/social_worker.js", workerURL: "https://example.com/browser/browser/base/content/test/social/social_worker.js",
iconURL: "https://example.com/browser/browser/base/content/test/moz.png" iconURL: "https://example.com/browser/browser/base/content/test/moz.png"
}; };
runSocialTestWithProvider(manifest, function (finishcb) { runSocialTestWithProvider(manifest, function (finishcb) {

View File

@ -14,15 +14,15 @@ let gProviders = [
{ {
name: "provider 1", name: "provider 1",
origin: "https://example.com", origin: "https://example.com",
sidebarURL: "https://example.com/browser/browser/base/content/test/social_sidebar.html?provider1", sidebarURL: "https://example.com/browser/browser/base/content/test/social/social_sidebar.html?provider1",
workerURL: "https://example.com/browser/browser/base/content/test/social_worker.js", workerURL: "https://example.com/browser/browser/base/content/test/social/social_worker.js",
iconURL: "chrome://branding/content/icon48.png" iconURL: "chrome://branding/content/icon48.png"
}, },
{ {
name: "provider 2", name: "provider 2",
origin: "https://test1.example.com", origin: "https://test1.example.com",
sidebarURL: "https://test1.example.com/browser/browser/base/content/test/social_sidebar.html?provider2", sidebarURL: "https://test1.example.com/browser/browser/base/content/test/social/social_sidebar.html?provider2",
workerURL: "https://test1.example.com/browser/browser/base/content/test/social_worker.js", workerURL: "https://test1.example.com/browser/browser/base/content/test/social/social_worker.js",
iconURL: "chrome://branding/content/icon48.png" iconURL: "chrome://branding/content/icon48.png"
} }
]; ];

View File

@ -27,8 +27,8 @@ function tabLoaded() {
let manifest = { // normal provider let manifest = { // normal provider
name: "provider 1", name: "provider 1",
origin: "https://example.com", origin: "https://example.com",
sidebarURL: "https://example.com/browser/browser/base/content/test/social_sidebar.html", sidebarURL: "https://example.com/browser/browser/base/content/test/social/social_sidebar.html",
workerURL: "https://example.com/browser/browser/base/content/test/social_worker.js", workerURL: "https://example.com/browser/browser/base/content/test/social/social_worker.js",
iconURL: "https://example.com/browser/browser/base/content/test/moz.png" iconURL: "https://example.com/browser/browser/base/content/test/moz.png"
}; };
runSocialTestWithProvider(manifest, function (finishcb) { runSocialTestWithProvider(manifest, function (finishcb) {
@ -68,7 +68,7 @@ function testInitial(finishcb) {
is(shareButton.getAttribute("tooltiptext"), "Share this page", "check tooltip text is correct"); is(shareButton.getAttribute("tooltiptext"), "Share this page", "check tooltip text is correct");
is(shareStatusLabel.getAttribute("value"), "", "check status label text is blank"); is(shareStatusLabel.getAttribute("value"), "", "check status label text is blank");
// Check the relative URL was resolved correctly (note this image has offsets of zero...) // Check the relative URL was resolved correctly (note this image has offsets of zero...)
is(shareButton.src, 'https://example.com/browser/browser/base/content/test/social_share_image.png', "check image url is correct"); is(shareButton.src, 'https://example.com/browser/browser/base/content/test/social/social_share_image.png', "check image url is correct");
// Test clicking the share button // Test clicking the share button
shareButton.addEventListener("click", function listener() { shareButton.addEventListener("click", function listener() {
@ -77,7 +77,7 @@ function testInitial(finishcb) {
is(shareButton.getAttribute("tooltiptext"), "Unshare this page", "check tooltip text is correct"); is(shareButton.getAttribute("tooltiptext"), "Unshare this page", "check tooltip text is correct");
is(shareStatusLabel.getAttribute("value"), "This page has been shared", "check status label text is correct"); is(shareStatusLabel.getAttribute("value"), "This page has been shared", "check status label text is correct");
// Check the URL and offsets were applied correctly // Check the URL and offsets were applied correctly
is(shareButton.src, 'https://example.com/browser/browser/base/content/test/social_share_image.png', "check image url is correct"); is(shareButton.src, 'https://example.com/browser/browser/base/content/test/social/social_share_image.png', "check image url is correct");
executeSoon(testSecondClick.bind(window, testPopupOKButton)); executeSoon(testSecondClick.bind(window, testPopupOKButton));
}); });
shareButton.click(); shareButton.click();

View File

@ -8,8 +8,8 @@ function test() {
let manifest = { // normal provider let manifest = { // normal provider
name: "provider 1", name: "provider 1",
origin: "https://example.com", origin: "https://example.com",
sidebarURL: "https://example.com/browser/browser/base/content/test/social_sidebar.html", sidebarURL: "https://example.com/browser/browser/base/content/test/social/social_sidebar.html",
workerURL: "https://example.com/browser/browser/base/content/test/social_worker.js", workerURL: "https://example.com/browser/browser/base/content/test/social/social_worker.js",
iconURL: "https://example.com/browser/browser/base/content/test/moz.png" iconURL: "https://example.com/browser/browser/base/content/test/moz.png"
}; };
runSocialTestWithProvider(manifest, doTest); runSocialTestWithProvider(manifest, doTest);

View File

@ -8,7 +8,7 @@ function test() {
let manifest = { // normal provider let manifest = { // normal provider
name: "provider 1", name: "provider 1",
origin: "https://example.com", origin: "https://example.com",
workerURL: "https://example.com/browser/browser/base/content/test/social_worker.js", workerURL: "https://example.com/browser/browser/base/content/test/social/social_worker.js",
iconURL: "https://example.com/browser/browser/base/content/test/moz.png" iconURL: "https://example.com/browser/browser/base/content/test/moz.png"
}; };
runSocialTestWithProvider(manifest, function (finishcb) { runSocialTestWithProvider(manifest, function (finishcb) {

View File

@ -0,0 +1,129 @@
/* 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 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 ensureSocialUrlNotRemembered(url) {
let gh = Cc["@mozilla.org/browser/global-history;2"]
.getService(Ci.nsIGlobalHistory2);
let uri = Services.io.newURI(url, null, null);
ok(!gh.isVisited(uri), "social URL " + url + " should not be in global history");
}
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.
registerCleanupFunction(function () {
manifests.forEach(function (m) {
for (let what of ['sidebarURL', 'workerURL', 'iconURL']) {
if (m[what]) {
ensureSocialUrlNotRemembered(m[what]);
}
}
});
});
info("runSocialTestWithProvider: " + manifests.toSource());
let providersAdded = 0;
let firstProvider;
manifests.forEach(function (m) {
SocialService.addProvider(m, function(provider) {
provider.active = true;
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
Social.provider = firstProvider;
Social.enabled = true;
registerCleanupFunction(function () {
// disable social before removing the providers to avoid providers
// being activated immediately before we get around to removing it.
Services.prefs.clearUserPref("social.enabled");
// if one test happens to fail, it is likely finishSocialTest will not
// be called, causing most future social tests to also fail as they
// attempt to add a provider which already exists - so work
// around that by also attempting to remove the test provider.
manifests.forEach(function (m) {
try {
SocialService.removeProvider(m.origin, finish);
} catch (ex) {}
});
});
function finishSocialTest() {
SocialService.removeProvider(provider.origin, finish);
}
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();
}

View File

Before

Width:  |  Height:  |  Size: 934 B

After

Width:  |  Height:  |  Size: 934 B

View File

@ -105,7 +105,7 @@ onconnect = function(e) {
let icon = { let icon = {
name: "testIcon", name: "testIcon",
iconURL: "chrome://browser/skin/Info.png", iconURL: "chrome://browser/skin/Info.png",
contentPanel: "https://example.com/browser/browser/base/content/test/social_panel.html", contentPanel: "https://example.com/browser/browser/base/content/test/social/social_panel.html",
counter: 1 counter: 1
}; };
apiPort.postMessage({topic: "social.ambient-notification", data: icon}); apiPort.postMessage({topic: "social.ambient-notification", data: icon});
@ -122,9 +122,9 @@ onconnect = function(e) {
data: { data: {
images: { images: {
// this one is relative to test we handle relative ones. // this one is relative to test we handle relative ones.
share: "browser/browser/base/content/test/social_share_image.png", share: "browser/browser/base/content/test/social/social_share_image.png",
// absolute to check we handle them too. // absolute to check we handle them too.
unshare: "https://example.com/browser/browser/base/content/test/social_share_image.png" unshare: "https://example.com/browser/browser/base/content/test/social/social_share_image.png"
}, },
messages: { messages: {
shareTooltip: "Share this page", shareTooltip: "Share this page",

View File

@ -99,6 +99,7 @@ if [ "$ENABLE_TESTS" ]; then
add_makefiles " add_makefiles "
browser/base/content/test/Makefile browser/base/content/test/Makefile
browser/base/content/test/newtab/Makefile browser/base/content/test/newtab/Makefile
browser/base/content/test/social/Makefile
browser/components/certerror/test/Makefile browser/components/certerror/test/Makefile
browser/components/dirprovider/tests/Makefile browser/components/dirprovider/tests/Makefile
browser/components/downloads/test/Makefile browser/components/downloads/test/Makefile