mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Bug 781386: add pref to avoid loading built-in providers during test runs, r=markh/mixedpuppy
--HG-- rename : browser/base/content/test/browser_shareButton.js => browser/base/content/test/browser_social_shareButton.js extra : rebase_source : df925f95972462d0f8d07f1e0810dc22da0f1911
This commit is contained in:
parent
bff9984693
commit
5384be9bf6
@ -156,7 +156,7 @@ _BROWSER_FILES = \
|
||||
browser_bug749738.js \
|
||||
browser_bug763468.js \
|
||||
browser_bug767836.js \
|
||||
browser_shareButton.js \
|
||||
browser_social_shareButton.js \
|
||||
browser_canonizeURL.js \
|
||||
browser_customize.js \
|
||||
browser_findbarClose.js \
|
||||
|
@ -2,8 +2,6 @@
|
||||
* 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/. */
|
||||
|
||||
let SocialService = Cu.import("resource://gre/modules/SocialService.jsm", {}).SocialService;
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
@ -14,10 +12,8 @@ function test() {
|
||||
workerURL: "http://example.com/browser/browser/base/content/test/social_worker.js",
|
||||
iconURL: "chrome://branding/content/icon48.png"
|
||||
};
|
||||
runSocialTestWithProvider(manifest, function () {
|
||||
runSocialTests(tests, undefined, undefined, function () {
|
||||
SocialService.removeProvider(Social.provider.origin, finish);
|
||||
});
|
||||
runSocialTestWithProvider(manifest, function (finishcb) {
|
||||
runSocialTests(tests, undefined, undefined, finishcb);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,8 @@ let prefName = "social.enabled",
|
||||
shareButton,
|
||||
sharePopup,
|
||||
okButton,
|
||||
undoButton;
|
||||
undoButton,
|
||||
gFinishCB;
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
@ -18,11 +19,7 @@ function test() {
|
||||
executeSoon(tabLoaded);
|
||||
}, true);
|
||||
|
||||
// Enable the service to start
|
||||
Services.prefs.setBoolPref(prefName, true);
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
Services.prefs.clearUserPref(prefName);
|
||||
gBrowser.removeTab(tab);
|
||||
});
|
||||
}
|
||||
@ -30,19 +27,20 @@ function test() {
|
||||
function tabLoaded() {
|
||||
ok(Social, "Social module loaded");
|
||||
|
||||
// If the UI is already active, run the test immediately, otherwise wait
|
||||
// for initialization.
|
||||
if (Social.provider) {
|
||||
executeSoon(testInitial);
|
||||
} else {
|
||||
Services.obs.addObserver(function obs() {
|
||||
Services.obs.removeObserver(obs, "test-social-ui-ready");
|
||||
executeSoon(testInitial);
|
||||
}, "test-social-ui-ready", false);
|
||||
}
|
||||
let manifest = { // normal provider
|
||||
name: "provider 1",
|
||||
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",
|
||||
iconURL: "chrome://branding/content/icon48.png"
|
||||
};
|
||||
runSocialTestWithProvider(manifest, function (finishcb) {
|
||||
gFinishCB = finishcb;
|
||||
testInitial();
|
||||
});
|
||||
}
|
||||
|
||||
function testInitial() {
|
||||
function testInitial(finishcb) {
|
||||
ok(Social.provider, "Social provider is active");
|
||||
ok(Social.provider.enabled, "Social provider is enabled");
|
||||
ok(Social.provider.port, "Social provider has a port to its FrameWorker");
|
||||
@ -116,19 +114,33 @@ function checkShortcutWorked(keyTarget) {
|
||||
|
||||
function checkOKButton() {
|
||||
is(document.activeElement, okButton, "ok button should be focused by default");
|
||||
checkNextInTabOrder(undoButton, function () {
|
||||
checkNextInTabOrder(okButton, testCloseBySpace);
|
||||
});
|
||||
}
|
||||
|
||||
function checkNextInTabOrder(element, next) {
|
||||
// This particular test doesn't really apply on Mac, since buttons aren't
|
||||
// focusable by default.
|
||||
// This rest of particular test doesn't really apply on Mac, since buttons
|
||||
// aren't focusable by default.
|
||||
if (navigator.platform.indexOf("Mac") != -1) {
|
||||
executeSoon(next);
|
||||
executeSoon(testCloseBySpace);
|
||||
return;
|
||||
}
|
||||
|
||||
let displayName = document.getElementById("socialUserDisplayName");
|
||||
|
||||
// Linux has the buttons in the [unshare] [ok] order, so displayName will come first.
|
||||
if (navigator.platform.indexOf("Linux") != -1) {
|
||||
checkNextInTabOrder(displayName, function () {
|
||||
checkNextInTabOrder(undoButton, function () {
|
||||
checkNextInTabOrder(okButton, testCloseBySpace);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
checkNextInTabOrder(undoButton, function () {
|
||||
checkNextInTabOrder(displayName, function () {
|
||||
checkNextInTabOrder(okButton, testCloseBySpace);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function checkNextInTabOrder(element, next) {
|
||||
function listener() {
|
||||
element.removeEventListener("focus", listener);
|
||||
is(document.activeElement, element, element.id + " should be next in tab order");
|
||||
@ -155,5 +167,5 @@ function testCloseBySpace() {
|
||||
function testDisable() {
|
||||
Services.prefs.setBoolPref(prefName, false);
|
||||
is(shareButton.hidden, true, "Share button should be hidden when pref is disabled");
|
||||
finish();
|
||||
gFinishCB();
|
||||
}
|
@ -2,8 +2,6 @@
|
||||
* 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/. */
|
||||
|
||||
let SocialService = Cu.import("resource://gre/modules/SocialService.jsm", {}).SocialService;
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
@ -17,7 +15,7 @@ function test() {
|
||||
runSocialTestWithProvider(manifest, doTest);
|
||||
}
|
||||
|
||||
function doTest() {
|
||||
function doTest(finishcb) {
|
||||
ok(SocialSidebar.canShow, "social sidebar should be able to be shown");
|
||||
ok(SocialSidebar.enabled, "social sidebar should be on by default");
|
||||
|
||||
@ -50,8 +48,8 @@ function doTest() {
|
||||
|
||||
checkShown(true);
|
||||
|
||||
// Remove the test provider
|
||||
SocialService.removeProvider(Social.provider.origin, finish);
|
||||
// Finish the test
|
||||
finishcb();
|
||||
});
|
||||
|
||||
// Toggle it back on
|
||||
|
@ -2,8 +2,6 @@
|
||||
* 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/. */
|
||||
|
||||
let SocialService = Cu.import("resource://gre/modules/SocialService.jsm", {}).SocialService;
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
@ -13,10 +11,8 @@ function test() {
|
||||
workerURL: "https://example1.com/worker.js",
|
||||
iconURL: "chrome://branding/content/icon48.png"
|
||||
};
|
||||
runSocialTestWithProvider(manifest, function () {
|
||||
runSocialTests(tests, undefined, undefined, function () {
|
||||
SocialService.removeProvider(Social.provider.origin, finish);
|
||||
});
|
||||
runSocialTestWithProvider(manifest, function (finishcb) {
|
||||
runSocialTests(tests, undefined, undefined, finishcb);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -89,8 +89,13 @@ function waitForCondition(condition, nextTest, errorMsg) {
|
||||
}
|
||||
|
||||
function runSocialTestWithProvider(manifest, callback) {
|
||||
let SocialService = Cu.import("resource://gre/modules/SocialService.jsm", {}).SocialService;
|
||||
|
||||
info("runSocialTestWithProvider: " + manifest.toSource());
|
||||
|
||||
let oldProvider;
|
||||
function saveOldProviderAndStartTestWith(provider) {
|
||||
SocialService.addProvider(manifest, function(provider) {
|
||||
info("runSocialTestWithProvider: provider added");
|
||||
oldProvider = Social.provider;
|
||||
Social.provider = provider;
|
||||
|
||||
@ -102,20 +107,10 @@ function runSocialTestWithProvider(manifest, callback) {
|
||||
Services.prefs.clearUserPref("social.enabled");
|
||||
});
|
||||
|
||||
callback();
|
||||
}
|
||||
|
||||
SocialService.addProvider(manifest, function(provider) {
|
||||
// If the UI is already active, run the test immediately, otherwise wait
|
||||
// for initialization.
|
||||
if (Social.provider) {
|
||||
saveOldProviderAndStartTestWith(provider);
|
||||
} else {
|
||||
Services.obs.addObserver(function obs() {
|
||||
Services.obs.removeObserver(obs, "test-social-ui-ready");
|
||||
saveOldProviderAndStartTestWith(provider);
|
||||
}, "test-social-ui-ready", false);
|
||||
function finishSocialTest() {
|
||||
SocialService.removeProvider(provider.origin, finish);
|
||||
}
|
||||
callback(finishSocialTest);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,6 @@ let Social = {
|
||||
if (providers.length)
|
||||
this.provider = providers[0];
|
||||
callback();
|
||||
Services.obs.notifyObservers(null, "test-social-ui-ready", "");
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
|
@ -356,6 +356,7 @@ class Automation(object):
|
||||
{'allowXULXBL':[(l.host, 'noxul' not in l.options) for l in locations]});
|
||||
|
||||
part = """\
|
||||
user_pref("social.skipLoadingProviders", true);
|
||||
user_pref("browser.console.showInPanel", true);
|
||||
user_pref("browser.dom.window.dump.enabled", true);
|
||||
user_pref("browser.firstrun.show.localepicker", false);
|
||||
|
@ -41,6 +41,15 @@ XPCOMUtils.defineLazyGetter(SocialServiceInternal, "providers", function () {
|
||||
// Initialize the MozSocialAPI
|
||||
MozSocialAPI.enabled = SocialServiceInternal.enabled;
|
||||
|
||||
// Don't load any providers from prefs if the test pref is set
|
||||
let skipLoading = false;
|
||||
try {
|
||||
skipLoading = Services.prefs.getBoolPref("social.skipLoadingProviders");
|
||||
} catch (ex) {}
|
||||
|
||||
if (skipLoading)
|
||||
return {};
|
||||
|
||||
// Now retrieve the providers
|
||||
let providers = {};
|
||||
let MANIFEST_PREFS = Services.prefs.getBranch("social.manifest.");
|
||||
|
Loading…
Reference in New Issue
Block a user