зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1219101 more updates to current infra for socialapi tests, fixes intermittent bug 1219101, r=markh
MozReview-Commit-ID: JOwtSkjIwQ1 --HG-- extra : rebase_source : 01187c73d6f6cc3126ce67f9bceb731074b0ea2b
This commit is contained in:
Родитель
7b6a6a19d3
Коммит
5639861258
|
@ -24,6 +24,10 @@ var manifestUpgrade = { // used for testing install
|
|||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
PopupNotifications.panel.setAttribute("animate", "false");
|
||||
registerCleanupFunction(function () {
|
||||
PopupNotifications.panel.removeAttribute("animate");
|
||||
});
|
||||
|
||||
let prefname = getManifestPrefname(manifest);
|
||||
// ensure that manifest2 is NOT showing as builtin
|
||||
|
@ -189,7 +193,7 @@ var tests = {
|
|||
testDirectoryInstall: function(next) {
|
||||
AddonManager.addAddonListener(installListener(next, manifest2));
|
||||
|
||||
ensureEventFired(PopupNotifications.panel, "popupshown").then(() => {
|
||||
BrowserTestUtils.waitForEvent(PopupNotifications.panel, "popupshown").then(() => {
|
||||
let panel = document.getElementById("servicesInstall-notification");
|
||||
info("servicesInstall-notification panel opened");
|
||||
panel.button.click();
|
||||
|
|
|
@ -22,6 +22,36 @@ var manifest_bad = { // normal provider
|
|||
iconURL: "https://test1.example.com/browser/browser/base/content/test/general/moz.png"
|
||||
};
|
||||
|
||||
// blocklist testing
|
||||
function updateBlocklist() {
|
||||
var blocklistNotifier = Cc["@mozilla.org/extensions/blocklist;1"]
|
||||
.getService(Ci.nsITimerCallback);
|
||||
let promise = promiseObserverNotified("blocklist-updated");
|
||||
blocklistNotifier.notify(null);
|
||||
return promise;
|
||||
}
|
||||
|
||||
var _originalTestBlocklistURL = null;
|
||||
function setAndUpdateBlocklist(aURL) {
|
||||
if (!_originalTestBlocklistURL)
|
||||
_originalTestBlocklistURL = Services.prefs.getCharPref("extensions.blocklist.url");
|
||||
Services.prefs.setCharPref("extensions.blocklist.url", aURL);
|
||||
return updateBlocklist();
|
||||
}
|
||||
|
||||
function resetBlocklist() {
|
||||
// XXX - this has "forked" from the head.js helpers in our parent directory :(
|
||||
// But let's reuse their blockNoPlugins.xml. Later, we should arrange to
|
||||
// use their head.js helpers directly
|
||||
let noBlockedURL = "http://example.com/browser/browser/base/content/test/plugins/blockNoPlugins.xml";
|
||||
return new Promise(resolve => {
|
||||
setAndUpdateBlocklist(noBlockedURL).then(() => {
|
||||
Services.prefs.setCharPref("extensions.blocklist.url", _originalTestBlocklistURL);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
// turn on logging for nsBlocklistService.js
|
||||
|
@ -31,17 +61,17 @@ function test() {
|
|||
});
|
||||
|
||||
runSocialTests(tests, undefined, undefined, function () {
|
||||
resetBlocklist(finish); //restore to original pref
|
||||
resetBlocklist().then(finish); //restore to original pref
|
||||
});
|
||||
}
|
||||
|
||||
var tests = {
|
||||
testSimpleBlocklist: function(next) {
|
||||
// this really just tests adding and clearing our blocklist for later tests
|
||||
setAndUpdateBlocklist(blocklistURL, function() {
|
||||
setAndUpdateBlocklist(blocklistURL).then(() => {
|
||||
ok(Services.blocklist.isAddonBlocklisted(SocialService.createWrapper(manifest_bad)), "blocking 'blocked'");
|
||||
ok(!Services.blocklist.isAddonBlocklisted(SocialService.createWrapper(manifest)), "not blocking 'good'");
|
||||
resetBlocklist(function() {
|
||||
resetBlocklist().then(() => {
|
||||
ok(!Services.blocklist.isAddonBlocklisted(SocialService.createWrapper(manifest_bad)), "blocklist cleared");
|
||||
next();
|
||||
});
|
||||
|
@ -51,10 +81,10 @@ var tests = {
|
|||
function finishTest(isgood) {
|
||||
ok(isgood, "adding non-blocked provider ok");
|
||||
Services.prefs.clearUserPref("social.manifest.good");
|
||||
resetBlocklist(next);
|
||||
resetBlocklist().then(next);
|
||||
}
|
||||
setManifestPref("social.manifest.good", manifest);
|
||||
setAndUpdateBlocklist(blocklistURL, function() {
|
||||
setAndUpdateBlocklist(blocklistURL).then(() => {
|
||||
try {
|
||||
SocialService.addProvider(manifest, function(provider) {
|
||||
try {
|
||||
|
@ -77,10 +107,10 @@ var tests = {
|
|||
function finishTest(good) {
|
||||
ok(good, "Unable to add blocklisted provider");
|
||||
Services.prefs.clearUserPref("social.manifest.blocked");
|
||||
resetBlocklist(next);
|
||||
resetBlocklist().then(next);
|
||||
}
|
||||
setManifestPref("social.manifest.blocked", manifest_bad);
|
||||
setAndUpdateBlocklist(blocklistURL, function() {
|
||||
setAndUpdateBlocklist(blocklistURL).then(() => {
|
||||
try {
|
||||
SocialService.addProvider(manifest_bad, function(provider) {
|
||||
SocialService.disableProvider(provider.origin, function() {
|
||||
|
@ -96,37 +126,27 @@ var tests = {
|
|||
},
|
||||
testInstallingBlockedProvider: function(next) {
|
||||
function finishTest(good) {
|
||||
ok(good, "Unable to add blocklisted provider");
|
||||
Services.prefs.clearUserPref("social.whitelist");
|
||||
resetBlocklist(next);
|
||||
ok(good, "Unable to install blocklisted provider");
|
||||
resetBlocklist().then(next);
|
||||
}
|
||||
let activationURL = manifest_bad.origin + "/browser/browser/base/content/test/social/social_activate.html"
|
||||
addTab(activationURL, function(tab) {
|
||||
let doc = tab.linkedBrowser.contentDocument;
|
||||
let installFrom = doc.nodePrincipal.origin;
|
||||
// whitelist to avoid the 3rd party install dialog, we only want to test
|
||||
// the blocklist inside installProvider.
|
||||
Services.prefs.setCharPref("social.whitelist", installFrom);
|
||||
setAndUpdateBlocklist(blocklistURL, function() {
|
||||
setAndUpdateBlocklist(blocklistURL).then(() => {
|
||||
try {
|
||||
// expecting an exception when attempting to install a hard blocked
|
||||
// provider
|
||||
let data = {
|
||||
origin: doc.nodePrincipal.origin,
|
||||
url: doc.location.href,
|
||||
origin: manifest_bad.origin,
|
||||
url: activationURL,
|
||||
manifest: manifest_bad,
|
||||
window: window
|
||||
}
|
||||
Social.installProvider(data, function(addonManifest) {
|
||||
gBrowser.removeTab(tab);
|
||||
finishTest(false);
|
||||
});
|
||||
} catch(e) {
|
||||
gBrowser.removeTab(tab);
|
||||
finishTest(true);
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
testBlockingExistingProvider: function(next) {
|
||||
let listener = {
|
||||
|
|
|
@ -167,7 +167,7 @@ var tests = {
|
|||
SocialUI.onCustomizeEnd(window);
|
||||
|
||||
let testData = corpus[0];
|
||||
addTab(testData.url, function(tab) {
|
||||
BrowserTestUtils.openNewForegroundTab(gBrowser, testData.url).then(tab => {
|
||||
SocialService.addProvider(manifest, function(provider) {
|
||||
is(SocialUI.enabled, true, "SocialUI is enabled");
|
||||
checkSocialUI();
|
||||
|
@ -177,8 +177,7 @@ var tests = {
|
|||
ok(!shareButton.hasAttribute("disabled"), "share button is enabled");
|
||||
// button should be visible
|
||||
is(shareButton.hidden, false, "share button is visible");
|
||||
gBrowser.removeTab(tab);
|
||||
next();
|
||||
BrowserTestUtils.removeTab(tab).then(next);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
@ -196,7 +195,7 @@ var tests = {
|
|||
|
||||
let mm = getGroupMessageManager("social");
|
||||
mm.addMessageListener("sharedata", function handler(msg) {
|
||||
gBrowser.removeTab(testTab);
|
||||
BrowserTestUtils.removeTab(testTab).then(() => {
|
||||
hasoptions(testData.options, JSON.parse(msg.data));
|
||||
testData = corpus[testIndex++];
|
||||
BrowserTestUtils.waitForCondition(() => { return SocialShare.currentShare == null; },"share panel closed").then(() => {
|
||||
|
@ -209,9 +208,10 @@ var tests = {
|
|||
});
|
||||
SocialShare.iframe.messageManager.sendAsyncMessage("closeself", {});
|
||||
});
|
||||
});
|
||||
|
||||
function runOneTest() {
|
||||
addTab(testData.url, function(tab) {
|
||||
BrowserTestUtils.openNewForegroundTab(gBrowser, testData.url).then(tab => {
|
||||
testTab = tab;
|
||||
|
||||
let shareButton = SocialShare.shareButton;
|
||||
|
@ -284,15 +284,16 @@ var tests = {
|
|||
is(msg.data, expecting, "microformats data ok");
|
||||
BrowserTestUtils.waitForCondition(() => { return SocialShare.currentShare == null; },
|
||||
"share panel closed").then(() => {
|
||||
gBrowser.removeTab(testTab);
|
||||
mm.removeMessageListener("sharedata", handler);
|
||||
BrowserTestUtils.removeTab(testTab).then(() => {
|
||||
SocialService.disableProvider(manifest.origin, next);
|
||||
});
|
||||
});
|
||||
SocialShare.iframe.messageManager.sendAsyncMessage("closeself", {});
|
||||
});
|
||||
|
||||
let url = "https://example.com/browser/browser/base/content/test/social/microformats.html"
|
||||
addTab(url, function(tab) {
|
||||
BrowserTestUtils.openNewForegroundTab(gBrowser, url).then(tab => {
|
||||
testTab = tab;
|
||||
|
||||
let shareButton = SocialShare.shareButton;
|
||||
|
@ -321,7 +322,7 @@ var tests = {
|
|||
// ensure correct state
|
||||
SocialUI.onCustomizeEnd(window);
|
||||
|
||||
ensureEventFired(iframe, "load").then(() => {
|
||||
ensureFrameLoaded(iframe).then(() => {
|
||||
let subframe = iframe.contentDocument.getElementById("activation-frame");
|
||||
ensureFrameLoaded(subframe, activationPage).then(() => {
|
||||
is(subframe.contentDocument.location.href, activationPage, "activation page loaded");
|
||||
|
@ -332,7 +333,7 @@ var tests = {
|
|||
|
||||
BrowserTestUtils.waitForCondition(() => { return SocialShare.currentShare == null; },
|
||||
"share panel closed").then(() => {
|
||||
ensureBrowserTabClosed(testTab).then(() => {
|
||||
BrowserTestUtils.removeTab(testTab).then(() => {
|
||||
mm.removeMessageListener("sharedata", handler);
|
||||
SocialService.uninstallProvider(manifest.origin, next);
|
||||
});
|
||||
|
@ -343,7 +344,7 @@ var tests = {
|
|||
sendActivationEvent(subframe);
|
||||
});
|
||||
});
|
||||
addTab(activationPage, function(tab) {
|
||||
BrowserTestUtils.openNewForegroundTab(gBrowser, activationPage).then(tab => {
|
||||
let shareButton = SocialShare.shareButton;
|
||||
// verify the attribute for proper css
|
||||
ok(!shareButton.hasAttribute("disabled"), "share button is enabled");
|
||||
|
@ -363,8 +364,8 @@ var tests = {
|
|||
SocialShare._createFrame();
|
||||
|
||||
SocialService.addProvider(manifest, () => {
|
||||
addTab(activationPage, (tab) => {
|
||||
ensureEventFired(SocialShare.iframe, "load").then(() => {
|
||||
BrowserTestUtils.openNewForegroundTab(gBrowser, activationPage).then(tab => {
|
||||
ensureFrameLoaded(SocialShare.iframe).then(() => {
|
||||
// send keys to the input field. An unexpected failure will happen
|
||||
// if the onbeforeunload handler is fired.
|
||||
EventUtils.sendKey("f");
|
||||
|
@ -377,7 +378,7 @@ var tests = {
|
|||
let topwin = Services.wm.getMostRecentWindow(null);
|
||||
is(topwin, window, "no dialog is open");
|
||||
|
||||
ensureBrowserTabClosed(testTab).then(() => {
|
||||
BrowserTestUtils.removeTab(testTab).then(() => {
|
||||
SocialService.disableProvider(manifest.origin, next);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -14,49 +14,39 @@ var SocialService = Cu.import("resource://gre/modules/SocialService.jsm", {}).So
|
|||
|
||||
var tabsToRemove = [];
|
||||
|
||||
|
||||
function removeAllProviders(callback) {
|
||||
// all the providers may have been added.
|
||||
function removeProviders() {
|
||||
if (Social.providers.length < 1) {
|
||||
executeSoon(function() {
|
||||
is(Social.providers.length, 0, "all providers removed");
|
||||
executeSoon(callback);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
function removeProvider(provider) {
|
||||
return new Promise(resolve => {
|
||||
// a full install sets the manifest into a pref, addProvider alone doesn't,
|
||||
// make sure we uninstall if the manifest was added.
|
||||
if (Social.providers[0].manifest) {
|
||||
SocialService.uninstallProvider(Social.providers[0].origin, removeProviders);
|
||||
if (provider.manifest) {
|
||||
SocialService.uninstallProvider(provider.origin, resolve);
|
||||
} else {
|
||||
SocialService.disableProvider(Social.providers[0].origin, removeProviders);
|
||||
SocialService.disableProvider(provider.origin, resolve);
|
||||
}
|
||||
}
|
||||
removeProviders();
|
||||
});
|
||||
}
|
||||
|
||||
function postTestCleanup(callback) {
|
||||
Task.spawn(function () {
|
||||
// any tabs opened by the test.
|
||||
for (let tab of tabsToRemove)
|
||||
gBrowser.removeTab(tab);
|
||||
for (let tab of tabsToRemove) {
|
||||
yield BrowserTestUtils.removeTab(tab);
|
||||
}
|
||||
tabsToRemove = [];
|
||||
// theses tests use the notification panel but don't bother waiting for it
|
||||
// to fully open - the end result is that the panel might stay open
|
||||
//SocialUI.activationPanel.hidePopup();
|
||||
|
||||
// all the providers may have been added.
|
||||
removeAllProviders(callback);
|
||||
while (Social.providers.length > 0) {
|
||||
yield removeProvider(Social.providers[0]);
|
||||
}
|
||||
}).then(callback);
|
||||
}
|
||||
|
||||
function addTab(url, callback) {
|
||||
let tab = gBrowser.selectedTab = gBrowser.addTab(url, {skipAnimation: true});
|
||||
tab.linkedBrowser.addEventListener("load", function tabLoad(event) {
|
||||
tab.linkedBrowser.removeEventListener("load", tabLoad, true);
|
||||
function newTab(url) {
|
||||
return new Promise(resolve => {
|
||||
BrowserTestUtils.openNewForegroundTab(gBrowser, url).then(tab => {
|
||||
tabsToRemove.push(tab);
|
||||
executeSoon(function() {callback(tab)});
|
||||
}, true);
|
||||
resolve(tab);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function sendActivationEvent(tab, callback, nullManifest) {
|
||||
|
@ -68,34 +58,25 @@ function sendActivationEvent(tab, callback, nullManifest) {
|
|||
|
||||
function activateProvider(domain, callback, nullManifest) {
|
||||
let activationURL = domain+"/browser/browser/base/content/test/social/social_activate_basic.html"
|
||||
addTab(activationURL, function(tab) {
|
||||
newTab(activationURL).then(tab => {
|
||||
sendActivationEvent(tab, callback, nullManifest);
|
||||
});
|
||||
}
|
||||
|
||||
function activateIFrameProvider(domain, callback) {
|
||||
let activationURL = domain+"/browser/browser/base/content/test/social/social_activate_iframe.html"
|
||||
addTab(activationURL, function(tab) {
|
||||
newTab(activationURL).then(tab => {
|
||||
sendActivationEvent(tab, callback, false);
|
||||
});
|
||||
}
|
||||
|
||||
function waitForProviderLoad(cb) {
|
||||
waitForCondition(function() {
|
||||
let sbrowser = document.getElementById("social-sidebar-browser");
|
||||
let provider = SocialSidebar.provider;
|
||||
let postActivation = provider && gBrowser.currentURI &&
|
||||
gBrowser.currentURI.spec == provider.origin + "/browser/browser/base/content/test/social/social_postActivation.html";
|
||||
|
||||
return postActivation && sbrowser.docShellIsActive;
|
||||
}, function() {
|
||||
// executeSoon to let the browser UI observers run first
|
||||
executeSoon(cb);
|
||||
},
|
||||
"waitForProviderLoad: provider was not loaded");
|
||||
function waitForProviderLoad(origin) {
|
||||
return Promise.all([
|
||||
ensureFrameLoaded(gBrowser, origin + "/browser/browser/base/content/test/social/social_postActivation.html"),
|
||||
ensureFrameLoaded(SocialSidebar.browser)
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
function getAddonItemInList(aId, aList) {
|
||||
var item = aList.firstChild;
|
||||
while (item) {
|
||||
|
@ -133,22 +114,20 @@ function clickAddonRemoveButton(tab, aCallback) {
|
|||
|
||||
function activateOneProvider(manifest, finishActivation, aCallback) {
|
||||
let panel = document.getElementById("servicesInstall-notification");
|
||||
PopupNotifications.panel.addEventListener("popupshown", function onpopupshown() {
|
||||
PopupNotifications.panel.removeEventListener("popupshown", onpopupshown);
|
||||
BrowserTestUtils.waitForEvent(PopupNotifications.panel, "popupshown").then(() => {
|
||||
ok(!panel.hidden, "servicesInstall-notification panel opened");
|
||||
if (finishActivation)
|
||||
panel.button.click();
|
||||
else
|
||||
panel.closebutton.click();
|
||||
});
|
||||
PopupNotifications.panel.addEventListener("popuphidden", function _hidden() {
|
||||
PopupNotifications.panel.removeEventListener("popuphidden", _hidden);
|
||||
BrowserTestUtils.waitForEvent(PopupNotifications.panel, "popuphidden").then(() => {
|
||||
ok(panel.hidden, "servicesInstall-notification panel hidden");
|
||||
if (!finishActivation) {
|
||||
ok(panel.hidden, "activation panel is not showing");
|
||||
executeSoon(aCallback);
|
||||
} else {
|
||||
waitForProviderLoad(function() {
|
||||
waitForProviderLoad(manifest.origin).then(() => {
|
||||
is(SocialSidebar.provider.origin, manifest.origin, "new provider is active");
|
||||
ok(SocialSidebar.opened, "sidebar is open");
|
||||
checkSocialUI();
|
||||
|
@ -187,6 +166,10 @@ var gProviders = [
|
|||
|
||||
|
||||
function test() {
|
||||
PopupNotifications.panel.setAttribute("animate", "false");
|
||||
registerCleanupFunction(function () {
|
||||
PopupNotifications.panel.removeAttribute("animate");
|
||||
});
|
||||
waitForExplicitFinish();
|
||||
runSocialTests(tests, undefined, postTestCleanup);
|
||||
}
|
||||
|
@ -201,7 +184,7 @@ var tests = {
|
|||
ok(panel.hidden, "activation panel still hidden");
|
||||
checkSocialUI();
|
||||
Services.prefs.clearUserPref("social.remote-install.enabled");
|
||||
removeAllProviders(next);
|
||||
next();
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -212,7 +195,7 @@ var tests = {
|
|||
let panel = document.getElementById("servicesInstall-notification");
|
||||
ok(panel.hidden, "activation panel still hidden");
|
||||
checkSocialUI();
|
||||
removeAllProviders(next);
|
||||
next();
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -222,7 +205,7 @@ var tests = {
|
|||
// we deactivated leaving no providers left, so Social is disabled.
|
||||
ok(!SocialSidebar.provider, "should be no provider left after disabling");
|
||||
checkSocialUI();
|
||||
removeAllProviders(next);
|
||||
next();
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -240,7 +223,7 @@ var tests = {
|
|||
// we deactivated - the first provider should be enabled.
|
||||
is(SocialSidebar.provider.origin, Social.providers[1].origin, "original provider should have been reactivated");
|
||||
checkSocialUI();
|
||||
removeAllProviders(next);
|
||||
next();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -248,52 +231,41 @@ var tests = {
|
|||
|
||||
testAddonManagerDoubleInstall: function(next) {
|
||||
// Create a new tab and load about:addons
|
||||
let blanktab = gBrowser.addTab();
|
||||
gBrowser.selectedTab = blanktab;
|
||||
let addonsTab = gBrowser.addTab();
|
||||
gBrowser.selectedTab = addonsTab;
|
||||
BrowserOpenAddonsMgr('addons://list/service');
|
||||
|
||||
is(blanktab, gBrowser.selectedTab, "Current tab should be blank tab");
|
||||
|
||||
gBrowser.selectedBrowser.addEventListener("load", function tabLoad() {
|
||||
gBrowser.selectedBrowser.removeEventListener("load", tabLoad, true);
|
||||
let browser = blanktab.linkedBrowser;
|
||||
is(browser.currentURI.spec, "about:addons", "about:addons should load into blank tab.");
|
||||
is(addonsTab.linkedBrowser.currentURI.spec, "about:addons", "about:addons should load into blank tab.");
|
||||
|
||||
activateOneProvider(gProviders[0], true, function() {
|
||||
info("first activation completed");
|
||||
is(gBrowser.contentDocument.location.href, gProviders[0].origin + "/browser/browser/base/content/test/social/social_postActivation.html", "postActivationURL loaded");
|
||||
gBrowser.removeTab(gBrowser.selectedTab);
|
||||
BrowserTestUtils.removeTab(gBrowser.selectedTab).then(() => {
|
||||
is(gBrowser.contentDocument.location.href, gProviders[0].origin + "/browser/browser/base/content/test/social/social_activate_basic.html", "activation page selected");
|
||||
gBrowser.removeTab(gBrowser.selectedTab);
|
||||
BrowserTestUtils.removeTab(gBrowser.selectedTab).then(() => {
|
||||
tabsToRemove.pop();
|
||||
// uninstall the provider
|
||||
clickAddonRemoveButton(blanktab, function(addon) {
|
||||
clickAddonRemoveButton(addonsTab, function(addon) {
|
||||
checkSocialUI();
|
||||
activateOneProvider(gProviders[0], true, function() {
|
||||
info("second activation completed");
|
||||
is(gBrowser.contentDocument.location.href, gProviders[0].origin + "/browser/browser/base/content/test/social/social_postActivation.html", "postActivationURL loaded");
|
||||
gBrowser.removeTab(gBrowser.selectedTab);
|
||||
BrowserTestUtils.removeTab(gBrowser.selectedTab).then(() => {
|
||||
|
||||
// after closing the addons tab, verify provider is still installed
|
||||
gBrowser.tabContainer.addEventListener("TabClose", function onTabClose() {
|
||||
gBrowser.tabContainer.removeEventListener("TabClose", onTabClose);
|
||||
AddonManager.getAddonsByTypes(["service"], function(aAddons) {
|
||||
is(aAddons.length, 1, "there can be only one");
|
||||
removeAllProviders(next);
|
||||
});
|
||||
});
|
||||
|
||||
// verify only one provider in list
|
||||
AddonManager.getAddonsByTypes(["service"], function(aAddons) {
|
||||
is(aAddons.length, 1, "there can be only one");
|
||||
|
||||
let doc = blanktab.linkedBrowser.contentDocument;
|
||||
let doc = addonsTab.linkedBrowser.contentDocument;
|
||||
let list = doc.getElementById("addon-list");
|
||||
is(list.childNodes.length, 1, "only one addon is displayed");
|
||||
|
||||
gBrowser.removeTab(blanktab);
|
||||
BrowserTestUtils.removeTab(addonsTab).then(next);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -27,12 +27,12 @@ var manifests = [
|
|||
|
||||
var chatId = 0;
|
||||
function openChat(provider) {
|
||||
let deferred = Promise.defer();
|
||||
return new Promise(resolve => {
|
||||
SocialSidebar.provider = provider;
|
||||
let chatUrl = provider.origin + "/browser/browser/base/content/test/social/social_chat.html";
|
||||
let url = chatUrl + "?id=" + (chatId++);
|
||||
makeChat("normal", "chat " + chatId, (cb) => { deferred.resolve(cb); });
|
||||
return deferred.promise;
|
||||
makeChat("normal", "chat " + chatId, (cb) => { resolve(cb); });
|
||||
});
|
||||
}
|
||||
|
||||
function windowHasChats(win) {
|
||||
|
@ -74,23 +74,19 @@ function test() {
|
|||
var tests = {
|
||||
testOpenCloseChat: function(next) {
|
||||
openChat(SocialSidebar.provider).then((cb) => {
|
||||
waitForCondition(function() {
|
||||
return cb.minimized;
|
||||
}, function() {
|
||||
BrowserTestUtils.waitForCondition(() => { return cb.minimized; },
|
||||
"chatbox is minimized").then(() => {
|
||||
ok(cb.minimized, "chat is minimized after toggle");
|
||||
waitForCondition(function() {
|
||||
return !cb.minimized;
|
||||
}, function() {
|
||||
BrowserTestUtils.waitForCondition(() => { return !cb.minimized; },
|
||||
"chatbox is not minimized").then(() => {
|
||||
ok(!cb.minimized, "chat is not minimized after toggle");
|
||||
promiseNodeRemoved(cb).then(next);
|
||||
let mm = cb.content.messageManager;
|
||||
mm.sendAsyncMessage("socialTest-CloseSelf", {});
|
||||
info("close chat window requested");
|
||||
},
|
||||
"chatbox is not minimized");
|
||||
});
|
||||
cb.toggle();
|
||||
},
|
||||
"chatbox is minimized");
|
||||
});
|
||||
|
||||
ok(!cb.minimized, "chat is not minimized on open");
|
||||
// toggle to minimize chat
|
||||
|
|
|
@ -42,7 +42,7 @@ function test() {
|
|||
runSocialTestWithProvider(manifest, function (finishcb) {
|
||||
SocialSidebar.show();
|
||||
runSocialTests(tests, preSubTest, postSubTest, function () {
|
||||
ensureBrowserTabClosed(tab).then(finishcb);
|
||||
BrowserTestUtils.removeTab(tab).then(finishcb);
|
||||
});
|
||||
});
|
||||
}, true);
|
||||
|
@ -56,10 +56,11 @@ var tests = {
|
|||
let chatbar = getChatBar();
|
||||
openChatViaUser();
|
||||
ok(chatbar.firstElementChild, "chat opened");
|
||||
waitForCondition(() => isChatFocused(chatbar.selectedChat), function() {
|
||||
BrowserTestUtils.waitForCondition(() => isChatFocused(chatbar.selectedChat),
|
||||
"chat should be focused").then(() => {
|
||||
is(chatbar.selectedChat, chatbar.firstElementChild, "chat is selected");
|
||||
next();
|
||||
}, "chat should be focused");
|
||||
});
|
||||
});
|
||||
},
|
||||
};
|
||||
|
|
|
@ -58,14 +58,13 @@ var tests = {
|
|||
|
||||
let mm = getGroupMessageManager("social");
|
||||
mm.addMessageListener("sharedata", function handler(msg) {
|
||||
gBrowser.removeTab(testTab);
|
||||
is(msg.data, expecting, "microformats data ok");
|
||||
mm.removeMessageListener("sharedata", handler);
|
||||
next();
|
||||
BrowserTestUtils.removeTab(testTab).then(next);
|
||||
});
|
||||
|
||||
let url = "https://example.com/browser/browser/base/content/test/social/microformats.html"
|
||||
addTab(url, function(tab) {
|
||||
BrowserTestUtils.openNewForegroundTab(gBrowser, url).then(tab => {
|
||||
testTab = tab;
|
||||
let doc = tab.linkedBrowser.contentDocument;
|
||||
target = doc.getElementById("test-review");
|
||||
|
|
|
@ -17,12 +17,10 @@ function openPanel(url, panelCallback, loadCallback) {
|
|||
// wait for both open and loaded before callback. Since the test doesn't close
|
||||
// the panel between opens, we cannot rely on events here. We need to ensure
|
||||
// popupshown happens before we finish out the tests.
|
||||
waitForCondition(function() {
|
||||
BrowserTestUtils.waitForCondition(function() {
|
||||
return SocialFlyout.panel.state == "open" &&
|
||||
SocialFlyout.iframe.contentDocument.readyState == "complete";
|
||||
},
|
||||
function () { executeSoon(loadCallback) },
|
||||
"flyout is open and loaded");
|
||||
},"flyout is open and loaded").then(() => { executeSoon(loadCallback) });
|
||||
}
|
||||
|
||||
function openChat(url, panelCallback, loadCallback) {
|
||||
|
@ -138,12 +136,11 @@ var tests = {
|
|||
function() { // the "load" callback.
|
||||
todo_is(panelCallbackCount, 0, "Bug 833207 - should be no callback when error page loads.");
|
||||
let chat = getChatBar().selectedChat;
|
||||
waitForCondition(() => chat.content != null && chat.contentDocument.documentURI.indexOf("about:socialerror?mode=tryAgainOnly")==0,
|
||||
function() {
|
||||
BrowserTestUtils.waitForCondition(() => chat.content != null && chat.contentDocument.documentURI.indexOf("about:socialerror?mode=tryAgainOnly")==0,
|
||||
"error page didn't appear").then(() => {
|
||||
chat.close();
|
||||
next();
|
||||
},
|
||||
"error page didn't appear");
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
@ -167,26 +164,23 @@ var tests = {
|
|||
let chat = getChatBar().selectedChat;
|
||||
is(chat.contentDocument.documentURI, url, "correct url loaded");
|
||||
// toggle to a detached window.
|
||||
chat.swapWindows().then(
|
||||
chat => {
|
||||
chat.swapWindows().then(chat => {
|
||||
ok(!!chat.content, "we have chat content 1");
|
||||
waitForCondition(() => chat.content != null && chat.contentDocument.readyState == "complete",
|
||||
function() {
|
||||
BrowserTestUtils.waitForCondition(() => chat.content != null && chat.contentDocument.readyState == "complete",
|
||||
"swapped window loaded").then(() => {
|
||||
// now go offline and reload the chat - about:socialerror should be loaded.
|
||||
goOffline().then(function() {
|
||||
goOffline().then(() => {
|
||||
ok(!!chat.content, "we have chat content 2");
|
||||
chat.contentDocument.location.reload();
|
||||
info("chat reload called");
|
||||
waitForCondition(() => chat.contentDocument.documentURI.indexOf("about:socialerror?mode=tryAgainOnly")==0,
|
||||
function() {
|
||||
BrowserTestUtils.waitForCondition(() => chat.contentDocument.documentURI.indexOf("about:socialerror?mode=tryAgainOnly")==0,
|
||||
"error page didn't appear").then(() => {
|
||||
chat.close();
|
||||
next();
|
||||
},
|
||||
"error page didn't appear");
|
||||
});
|
||||
}, "swapped window loaded");
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -8,9 +8,6 @@ function test() {
|
|||
addMessageListener("socialTest-CloseSelf", function(e) {
|
||||
content.close();
|
||||
});
|
||||
addEventListener("visibilitychange", function() {
|
||||
sendAsyncMessage("social-visibility", content.document.hidden ? "hidden" : "shown");
|
||||
});
|
||||
addMessageListener("socialTest-sendEvent", function(msg) {
|
||||
let data = msg.data;
|
||||
let evt = content.document.createEvent("CustomEvent");
|
||||
|
@ -30,41 +27,22 @@ function test() {
|
|||
};
|
||||
runSocialTestWithProvider(manifest, function (finishcb) {
|
||||
SocialSidebar.show();
|
||||
ensureFrameLoaded(document.getElementById("social-sidebar-browser")).then(() => {
|
||||
ensureFrameLoaded(SocialSidebar.browser, manifest.sidebarURL).then(() => {
|
||||
// disable transitions for the test
|
||||
let panel = document.getElementById("social-flyout-panel");
|
||||
registerCleanupFunction(function () {
|
||||
panel.removeAttribute("animate");
|
||||
SocialFlyout.panel.removeAttribute("animate");
|
||||
});
|
||||
panel.setAttribute("animate", "false");
|
||||
SocialFlyout.panel.setAttribute("animate", "false");
|
||||
runSocialTests(tests, undefined, undefined, finishcb);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
var tests = {
|
||||
testOpenCloseFlyout: function(next) {
|
||||
let panel = document.getElementById("social-flyout-panel");
|
||||
ensureEventFired(panel, "popupshown").then(() => {
|
||||
is(panel.firstChild.contentDocument.readyState, "complete", "panel is loaded prior to showing");
|
||||
});
|
||||
let sidebar = document.getElementById("social-sidebar-browser")
|
||||
let mm = getGroupMessageManager("social");
|
||||
mm.addMessageListener("social-visibility", function handler(msg) {
|
||||
if (msg.data == "shown") {
|
||||
sidebar.messageManager.sendAsyncMessage("socialTest-sendEvent", { name: "test-flyout-close", data: {} });
|
||||
} else if (msg.data == "hidden") {
|
||||
mm.removeMessageListener("social-visibility", handler);
|
||||
next();
|
||||
}
|
||||
});
|
||||
sidebar.messageManager.sendAsyncMessage("socialTest-sendEvent", { name: "test-flyout-open", data: {} });
|
||||
},
|
||||
|
||||
testResizeFlyout: function(next) {
|
||||
let panel = document.getElementById("social-flyout-panel");
|
||||
|
||||
ensureEventFired(panel, "popupshown").then(() => {
|
||||
BrowserTestUtils.waitForEvent(panel, "popupshown").then(() => {
|
||||
is(panel.firstChild.contentDocument.readyState, "complete", "panel is loaded prior to showing");
|
||||
// The width of the flyout should be 400px initially
|
||||
let iframe = panel.firstChild;
|
||||
|
@ -76,54 +54,49 @@ var tests = {
|
|||
is(cs.height, "400px", "should be 400px high");
|
||||
is(iframe.boxObject.height, 400, "iframe should now be 400px high");
|
||||
|
||||
ensureEventFired(iframe.contentWindow, "resize").then(() => {
|
||||
BrowserTestUtils.waitForEvent(iframe.contentWindow, "resize").then(() => {
|
||||
cs = iframe.contentWindow.getComputedStyle(body);
|
||||
|
||||
is(cs.width, "500px", "should now be 500px wide");
|
||||
is(iframe.boxObject.width, 500, "iframe should now be 500px wide");
|
||||
is(cs.height, "500px", "should now be 500px high");
|
||||
is(iframe.boxObject.height, 500, "iframe should now be 500px high");
|
||||
ensureEventFired(panel, "popuphidden").then(next);
|
||||
BrowserTestUtils.waitForEvent(panel, "popuphidden").then(next);
|
||||
panel.hidePopup();
|
||||
});
|
||||
SocialFlyout.dispatchPanelEvent("socialTest-MakeWider");
|
||||
});
|
||||
|
||||
let sidebar = document.getElementById("social-sidebar-browser");
|
||||
sidebar.messageManager.sendAsyncMessage("socialTest-sendEvent", { name: "test-flyout-open", data: {} });
|
||||
SocialSidebar.browser.messageManager.sendAsyncMessage("socialTest-sendEvent", { name: "test-flyout-open", data: {} });
|
||||
},
|
||||
|
||||
testCloseSelf: function(next) {
|
||||
let panel = document.getElementById("social-flyout-panel");
|
||||
ensureEventFired(panel, "popupshown").then(() => {
|
||||
BrowserTestUtils.waitForEvent(panel, "popupshown").then(() => {
|
||||
is(panel.firstChild.contentDocument.readyState, "complete", "panel is loaded prior to showing");
|
||||
ensureEventFired(panel, "popuphidden").then(next);
|
||||
BrowserTestUtils.waitForEvent(panel, "popuphidden").then(next);
|
||||
let mm = panel.firstChild.messageManager;
|
||||
mm.sendAsyncMessage("socialTest-CloseSelf", {});
|
||||
});
|
||||
let sidebar = document.getElementById("social-sidebar-browser");
|
||||
sidebar.messageManager.sendAsyncMessage("socialTest-sendEvent", { name: "test-flyout-open", data: {} });
|
||||
SocialSidebar.browser.messageManager.sendAsyncMessage("socialTest-sendEvent", { name: "test-flyout-open", data: {} });
|
||||
},
|
||||
|
||||
testCloseOnLinkTraversal: function(next) {
|
||||
|
||||
function onTabOpen(event) {
|
||||
gBrowser.tabContainer.removeEventListener("TabOpen", onTabOpen, true);
|
||||
waitForCondition(function() { return panel.state == "closed" }, function() {
|
||||
gBrowser.removeTab(event.target);
|
||||
next();
|
||||
}, "panel should close after tab open");
|
||||
}
|
||||
BrowserTestUtils.waitForEvent(gBrowser.tabContainer, "TabOpen", true).then(event => {
|
||||
BrowserTestUtils.waitForCondition(function() { return panel.state == "closed" },
|
||||
"panel should close after tab open").then(() => {
|
||||
BrowserTestUtils.removeTab(event.target).then(next);
|
||||
});
|
||||
});
|
||||
|
||||
let panel = document.getElementById("social-flyout-panel");
|
||||
ensureEventFired(panel, "popupshown").then(() => {
|
||||
BrowserTestUtils.waitForEvent(panel, "popupshown").then(() => {
|
||||
is(panel.firstChild.contentDocument.readyState, "complete", "panel is loaded prior to showing");
|
||||
is(panel.state, "open", "flyout should be open");
|
||||
gBrowser.tabContainer.addEventListener("TabOpen", onTabOpen, true);
|
||||
let iframe = panel.firstChild;
|
||||
iframe.contentDocument.getElementById('traversal').click();
|
||||
});
|
||||
let sidebar = document.getElementById("social-sidebar-browser");
|
||||
sidebar.messageManager.sendAsyncMessage("socialTest-sendEvent", { name: "test-flyout-open", data: {} });
|
||||
SocialSidebar.browser.messageManager.sendAsyncMessage("socialTest-sendEvent", { name: "test-flyout-open", data: {} });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,9 @@ function test() {
|
|||
let mm = getGroupMessageManager("social");
|
||||
mm.loadFrameScript(frameScript, true);
|
||||
|
||||
PopupNotifications.panel.setAttribute("animate", "false");
|
||||
registerCleanupFunction(function () {
|
||||
PopupNotifications.panel.removeAttribute("animate");
|
||||
mm.removeDelayedFrameScript(frameScript);
|
||||
});
|
||||
|
||||
|
@ -67,13 +69,13 @@ var tests = {
|
|||
// we expect the addon install dialog to appear, we need to accept the
|
||||
// install from the dialog.
|
||||
let panel = document.getElementById("servicesInstall-notification");
|
||||
ensureEventFired(PopupNotifications.panel, "popupshown").then(() => {
|
||||
BrowserTestUtils.waitForEvent(PopupNotifications.panel, "popupshown").then(() => {
|
||||
info("servicesInstall-notification panel opened");
|
||||
panel.button.click();
|
||||
});
|
||||
|
||||
let activationURL = manifest3.origin + "/browser/browser/base/content/test/social/social_activate.html"
|
||||
addTab(activationURL, function(tab) {
|
||||
BrowserTestUtils.openNewForegroundTab(gBrowser, activationURL).then(tab => {
|
||||
let doc = tab.linkedBrowser.contentDocument;
|
||||
let data = {
|
||||
origin: doc.nodePrincipal.origin,
|
||||
|
@ -90,7 +92,7 @@ var tests = {
|
|||
let widget = CustomizableUI.getWidget(id);
|
||||
ok(!widget || !widget.forWindow(window).node, "no button added to widget set");
|
||||
Social.uninstallProvider(manifest3.origin, function() {
|
||||
ensureBrowserTabClosed(tab).then(next);
|
||||
BrowserTestUtils.removeTab(tab).then(next);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -99,14 +101,14 @@ var tests = {
|
|||
|
||||
testButtonOnEnable: function(next) {
|
||||
let panel = document.getElementById("servicesInstall-notification");
|
||||
ensureEventFired(PopupNotifications.panel, "popupshown").then(() => {
|
||||
BrowserTestUtils.waitForEvent(PopupNotifications.panel, "popupshown").then(() => {
|
||||
info("servicesInstall-notification panel opened");
|
||||
panel.button.click();
|
||||
});
|
||||
|
||||
// enable the provider now
|
||||
let activationURL = manifest2.origin + "/browser/browser/base/content/test/social/social_activate.html"
|
||||
addTab(activationURL, function(tab) {
|
||||
BrowserTestUtils.openNewForegroundTab(gBrowser, activationURL).then(tab => {
|
||||
let doc = tab.linkedBrowser.contentDocument;
|
||||
let data = {
|
||||
origin: doc.nodePrincipal.origin,
|
||||
|
@ -131,7 +133,7 @@ var tests = {
|
|||
is(button.hidden, false, "mark button is visible");
|
||||
|
||||
checkSocialUI(window);
|
||||
ensureBrowserTabClosed(tab).then(next);
|
||||
BrowserTestUtils.removeTab(tab).then(next);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -147,7 +149,7 @@ var tests = {
|
|||
ok(btn, "got a mark button");
|
||||
let ourTab;
|
||||
|
||||
ensureEventFired(btn.panel, "popupshown").then(() => {
|
||||
BrowserTestUtils.waitForEvent(btn.panel, "popupshown").then(() => {
|
||||
info("marks panel shown");
|
||||
let doc = btn.contentDocument;
|
||||
let unmarkBtn = doc.getElementById("unmark");
|
||||
|
@ -155,8 +157,8 @@ var tests = {
|
|||
EventUtils.sendMouseEvent({type: "click"}, unmarkBtn, btn.contentWindow);
|
||||
});
|
||||
|
||||
ensureEventFired(btn.panel, "popuphidden").then(() => {
|
||||
ensureBrowserTabClosed(ourTab).then(() => {
|
||||
BrowserTestUtils.waitForEvent(btn.panel, "popuphidden").then(() => {
|
||||
BrowserTestUtils.removeTab(ourTab).then(() => {
|
||||
ok(btn.disabled, "button is disabled");
|
||||
next();
|
||||
});
|
||||
|
@ -165,7 +167,7 @@ var tests = {
|
|||
// verify markbutton is disabled when there is no browser url
|
||||
ok(btn.disabled, "button is disabled");
|
||||
let activationURL = manifest2.origin + "/browser/browser/base/content/test/social/social_activate.html"
|
||||
addTab(activationURL, function(tab) {
|
||||
BrowserTestUtils.openNewForegroundTab(gBrowser, activationURL).then(tab => {
|
||||
ourTab = tab;
|
||||
ok(!btn.disabled, "button is enabled");
|
||||
// first click marks the page, second click opens the page. We have to
|
||||
|
@ -173,9 +175,9 @@ var tests = {
|
|||
EventUtils.synthesizeMouseAtCenter(btn, {});
|
||||
// wait for the button to be marked, click to open panel
|
||||
is(btn.panel.state, "closed", "panel should not be visible yet");
|
||||
waitForCondition(() => btn.isMarked, function() {
|
||||
BrowserTestUtils.waitForCondition(() => btn.isMarked, "button is marked").then(() => {
|
||||
EventUtils.synthesizeMouseAtCenter(btn, {});
|
||||
}, "button is marked");
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -190,18 +192,18 @@ var tests = {
|
|||
|
||||
// verify markbutton is disabled when there is no browser url
|
||||
ok(btn.disabled, "button is disabled");
|
||||
let activationURL = manifest2.origin + "/browser/browser/base/content/test/social/social_activate.html"
|
||||
addTab(activationURL, function(tab) {
|
||||
let activationURL = manifest2.origin + "/browser/browser/base/content/test/social/social_activate.html";
|
||||
BrowserTestUtils.openNewForegroundTab(gBrowser, activationURL).then(tab => {
|
||||
ok(!btn.disabled, "button is enabled");
|
||||
goOffline().then(function() {
|
||||
info("testing offline error page");
|
||||
// wait for popupshown
|
||||
ensureEventFired(btn.panel, "popupshown").then(() => {
|
||||
BrowserTestUtils.waitForEvent(btn.panel, "popupshown").then(() => {
|
||||
info("marks panel is open");
|
||||
ensureFrameLoaded(btn.content).then(() => {
|
||||
is(btn.contentDocument.documentURI.indexOf("about:socialerror?mode=tryAgainOnly"), 0, "social error page is showing "+btn.contentDocument.documentURI);
|
||||
// cleanup after the page has been unmarked
|
||||
ensureBrowserTabClosed(tab).then(() => {
|
||||
BrowserTestUtils.removeTab(tab).then(() => {
|
||||
ok(btn.disabled, "button is disabled");
|
||||
goOnline().then(next);
|
||||
});
|
||||
|
@ -218,14 +220,13 @@ var tests = {
|
|||
ok(provider, "provider is installed");
|
||||
SocialService.disableProvider(manifest2.origin, function() {
|
||||
let id = SocialMarks._toolbarHelper.idFromOrigin(manifest2.origin);
|
||||
waitForCondition(function() {
|
||||
BrowserTestUtils.waitForCondition(() => {
|
||||
// getWidget now returns null since we've destroyed the widget
|
||||
return !CustomizableUI.getWidget(id)
|
||||
},
|
||||
function() {
|
||||
}, "button does not exist after disabling the provider").then(() => {
|
||||
checkSocialUI(window);
|
||||
Social.uninstallProvider(manifest2.origin, next);
|
||||
}, "button does not exist after disabling the provider");
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,10 @@ function makeMarkProvider(origin) {
|
|||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
PopupNotifications.panel.setAttribute("animate", "false");
|
||||
registerCleanupFunction(function () {
|
||||
PopupNotifications.panel.removeAttribute("animate");
|
||||
});
|
||||
|
||||
runSocialTests(tests, undefined, undefined, finish);
|
||||
}
|
||||
|
@ -40,7 +44,7 @@ var tests = {
|
|||
}
|
||||
info("INSTALLING " + manifest.origin);
|
||||
let panel = document.getElementById("servicesInstall-notification");
|
||||
ensureEventFired(PopupNotifications.panel, "popupshown").then(() => {
|
||||
BrowserTestUtils.waitForEvent(PopupNotifications.panel, "popupshown").then(() => {
|
||||
info("servicesInstall-notification panel opened");
|
||||
panel.button.click();
|
||||
});
|
||||
|
@ -48,7 +52,7 @@ var tests = {
|
|||
let activationURL = manifest.origin + "/browser/browser/base/content/test/social/social_activate.html"
|
||||
let id = SocialMarks._toolbarHelper.idFromOrigin(manifest.origin);
|
||||
let toolbar = document.getElementById("nav-bar");
|
||||
addTab(activationURL, function(tab) {
|
||||
BrowserTestUtils.openNewForegroundTab(gBrowser, activationURL).then(tab => {
|
||||
let doc = tab.linkedBrowser.contentDocument;
|
||||
let data = {
|
||||
origin: doc.nodePrincipal.origin,
|
||||
|
@ -60,16 +64,17 @@ var tests = {
|
|||
Social.installProvider(data, function(addonManifest) {
|
||||
// enable the provider so we know the button would have appeared
|
||||
SocialService.enableProvider(manifest.origin, function(provider) {
|
||||
waitForCondition(function() { return CustomizableUI.getWidget(id) },
|
||||
function() {
|
||||
gBrowser.removeTab(tab);
|
||||
BrowserTestUtils.waitForCondition(() => { return CustomizableUI.getWidget(id) },
|
||||
"button exists after enabling social").then(() => {
|
||||
BrowserTestUtils.removeTab(tab).then(() => {
|
||||
installed.push(manifest.origin);
|
||||
// checkSocialUI will properly check where the menus are located
|
||||
checkSocialUI(window);
|
||||
executeSoon(function() {
|
||||
addProviders(callback);
|
||||
});
|
||||
}, "button exists after enabling social");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -42,23 +42,23 @@ var tests = {
|
|||
}
|
||||
|
||||
// the menu is not populated until onpopupshowing, so wait for popupshown
|
||||
ensureEventFired(menu, "popupshown").then(()=>{
|
||||
BrowserTestUtils.waitForEvent(menu, "popupshown", true).then(()=>{
|
||||
menu.hidePopup(); // doesn't need visibility
|
||||
// first provider should already be visible in the sidebar
|
||||
is(Social.providers[0].origin, SocialSidebar.provider.origin, "selected provider in sidebar");
|
||||
checkProviderMenu(Social.providers[0]);
|
||||
|
||||
// Now activate "provider 2"
|
||||
ensureEventFired(sbrowser, "load").then(()=>{
|
||||
BrowserTestUtils.waitForEvent(sbrowser, "load", true).then(()=>{
|
||||
checkUIStateMatchesProvider(Social.providers[1]);
|
||||
|
||||
ensureEventFired(sbrowser, "load").then(()=>{
|
||||
BrowserTestUtils.waitForEvent(sbrowser, "load", true).then(()=>{
|
||||
checkUIStateMatchesProvider(Social.providers[0]);
|
||||
next();
|
||||
});
|
||||
|
||||
// show the menu again so the menu is updated with the correct commands
|
||||
ensureEventFired(menu, "popupshown").then(()=>{
|
||||
BrowserTestUtils.waitForEvent(menu, "popupshown", true).then(()=>{
|
||||
// click on the provider menuitem to switch providers
|
||||
let el = menu.getElementsByAttribute("origin", Social.providers[0].origin);
|
||||
is(el.length, 1, "selected provider menu item exists");
|
||||
|
|
|
@ -68,7 +68,7 @@ function doTest() {
|
|||
}
|
||||
}
|
||||
}
|
||||
ensureEventFired(browser, "load").then(() => {
|
||||
ensureFrameLoaded(browser).then(() => {
|
||||
// First check the the sidebar is initially visible, and loaded
|
||||
ok(!command.hidden, "toggle command should be visible");
|
||||
let mm = getGroupMessageManager("social");
|
||||
|
|
|
@ -49,7 +49,9 @@ function test() {
|
|||
let mm = getGroupMessageManager("social");
|
||||
mm.loadFrameScript(frameScript, true);
|
||||
|
||||
PopupNotifications.panel.setAttribute("animate", "false");
|
||||
registerCleanupFunction(function () {
|
||||
PopupNotifications.panel.removeAttribute("animate");
|
||||
mm.removeDelayedFrameScript(frameScript);
|
||||
});
|
||||
|
||||
|
@ -69,13 +71,13 @@ var tests = {
|
|||
// we expect the addon install dialog to appear, we need to accept the
|
||||
// install from the dialog.
|
||||
let panel = document.getElementById("servicesInstall-notification");
|
||||
ensureEventFired(PopupNotifications.panel, "popupshown").then(() => {
|
||||
BrowserTestUtils.waitForEvent(PopupNotifications.panel, "popupshown").then(() => {
|
||||
info("servicesInstall-notification panel opened");
|
||||
panel.button.click();
|
||||
})
|
||||
|
||||
let activationURL = manifest3.origin + "/browser/browser/base/content/test/social/social_activate.html"
|
||||
addTab(activationURL, function(tab) {
|
||||
BrowserTestUtils.openNewForegroundTab(gBrowser, activationURL).then(tab => {
|
||||
let doc = tab.linkedBrowser.contentDocument;
|
||||
let data = {
|
||||
origin: doc.nodePrincipal.origin,
|
||||
|
@ -91,8 +93,7 @@ var tests = {
|
|||
let widget = CustomizableUI.getWidget(id);
|
||||
ok(!widget || !widget.forWindow(window).node, "no button added to widget set");
|
||||
Social.uninstallProvider(manifest3.origin, function() {
|
||||
gBrowser.removeTab(tab);
|
||||
next();
|
||||
BrowserTestUtils.removeTab(tab).then(next);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -100,14 +101,14 @@ var tests = {
|
|||
},
|
||||
testButtonOnEnable: function(next) {
|
||||
let panel = document.getElementById("servicesInstall-notification");
|
||||
ensureEventFired(PopupNotifications.panel, "popupshown").then(() => {
|
||||
BrowserTestUtils.waitForEvent(PopupNotifications.panel, "popupshown").then(() => {
|
||||
info("servicesInstall-notification panel opened");
|
||||
panel.button.click();
|
||||
});
|
||||
|
||||
// enable the provider now
|
||||
let activationURL = manifest2.origin + "/browser/browser/base/content/test/social/social_activate.html"
|
||||
addTab(activationURL, function(tab) {
|
||||
BrowserTestUtils.openNewForegroundTab(gBrowser, activationURL).then(tab => {
|
||||
let doc = tab.linkedBrowser.contentDocument;
|
||||
let data = {
|
||||
origin: doc.nodePrincipal.origin,
|
||||
|
@ -123,8 +124,7 @@ var tests = {
|
|||
let widget = CustomizableUI.getWidget(id).forWindow(window);
|
||||
ok(widget.node, "button added to widget set");
|
||||
checkSocialUI(window);
|
||||
gBrowser.removeTab(tab);
|
||||
next();
|
||||
BrowserTestUtils.removeTab(tab).then(next);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -145,18 +145,18 @@ var tests = {
|
|||
// Disable the transition
|
||||
let panel = document.getElementById("social-notification-panel");
|
||||
panel.setAttribute("animate", "false");
|
||||
ensureEventFired(panel, "popupshown").then(() => {
|
||||
BrowserTestUtils.waitForEvent(panel, "popupshown").then(() => {
|
||||
ensureFrameLoaded(panel.firstChild).then(() => {
|
||||
let mm = panel.firstChild.messageManager;
|
||||
mm.sendAsyncMessage("socialTest-sendEvent", { name: "Social:Notification", data: icon });
|
||||
waitForCondition(function() { return btn.getAttribute("badge"); },
|
||||
function() {
|
||||
BrowserTestUtils.waitForCondition(
|
||||
() => { return btn.getAttribute("badge"); }, "button updated by notification").then(() => {
|
||||
is(btn.style.listStyleImage, "url(\"" + icon.iconURL + "\")", "notification icon updated");
|
||||
panel.hidePopup();
|
||||
}, "button updated by notification");
|
||||
});
|
||||
});
|
||||
ensureEventFired(panel, "popuphidden").then(() => {
|
||||
});
|
||||
BrowserTestUtils.waitForEvent(panel, "popuphidden").then(() => {
|
||||
panel.removeAttribute("animate");
|
||||
next();
|
||||
});
|
||||
|
@ -178,13 +178,13 @@ var tests = {
|
|||
info("testing offline error page");
|
||||
// wait for popupshown
|
||||
let panel = document.getElementById("social-notification-panel");
|
||||
ensureEventFired(panel, "popupshown").then(() => {
|
||||
BrowserTestUtils.waitForEvent(panel, "popupshown").then(() => {
|
||||
ensureFrameLoaded(frame).then(() => {
|
||||
is(frame.contentDocument.documentURI.indexOf("about:socialerror?mode=tryAgainOnly"), 0, "social error page is showing "+frame.contentDocument.documentURI);
|
||||
// We got our error page, reset to avoid test leak.
|
||||
ensureEventFired(frame, "load").then(() => {
|
||||
BrowserTestUtils.waitForEvent(frame, "load", true).then(() => {
|
||||
is(frame.contentDocument.documentURI, "about:blank", "closing error panel");
|
||||
ensureEventFired(panel, "popuphidden").then(next);
|
||||
BrowserTestUtils.waitForEvent(panel, "popuphidden").then(next);
|
||||
panel.hidePopup();
|
||||
});
|
||||
goOnline().then(() => {
|
||||
|
@ -194,7 +194,7 @@ var tests = {
|
|||
});
|
||||
});
|
||||
// reload after going offline, wait for unload to open panel
|
||||
ensureEventFired(frame, "unload").then(() => {
|
||||
BrowserTestUtils.waitForEvent(frame, "unload", true).then(() => {
|
||||
btn.click();
|
||||
});
|
||||
frame.contentDocument.location.reload();
|
||||
|
@ -207,10 +207,10 @@ var tests = {
|
|||
ok(provider, "provider is installed");
|
||||
SocialService.disableProvider(manifest2.origin, function() {
|
||||
let id = SocialStatus._toolbarHelper.idFromOrigin(manifest2.origin);
|
||||
waitForCondition(function() { return !document.getElementById(id) },
|
||||
function() {
|
||||
BrowserTestUtils.waitForCondition(() => { return !document.getElementById(id) },
|
||||
"button does not exist after disabling the provider").then(() => {
|
||||
Social.uninstallProvider(manifest2.origin, next);
|
||||
}, "button does not exist after disabling the provider");
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,8 +94,8 @@ var tests = {
|
|||
SocialService.addProvider(manifest, function() {
|
||||
SocialService.addProvider(manifest2, function (provider) {
|
||||
SocialSidebar.show();
|
||||
waitForCondition(() => SocialSidebar.opened,
|
||||
function() {
|
||||
BrowserTestUtils.waitForCondition(
|
||||
() => SocialSidebar.opened, "sidebar did not open").then(() => {
|
||||
ok(SocialSidebar.opened, "first window sidebar is open");
|
||||
openWindowAndWaitForInit(window, function(w1) {
|
||||
ok(w1.SocialSidebar.opened, "new window sidebar is open");
|
||||
|
@ -123,7 +123,7 @@ var tests = {
|
|||
});
|
||||
});
|
||||
});
|
||||
}, "sidebar did not open");
|
||||
});
|
||||
}, cbnext);
|
||||
}, cbnext);
|
||||
},
|
||||
|
@ -138,8 +138,7 @@ var tests = {
|
|||
SocialService.addProvider(manifest, function() {
|
||||
openWindowAndWaitForInit(window, function(w1) {
|
||||
w1.SocialSidebar.show();
|
||||
waitForCondition(() => w1.SocialSidebar.opened,
|
||||
function() {
|
||||
BrowserTestUtils.waitForCondition(() => w1.SocialSidebar.opened, "sidebar opened").then(() => {
|
||||
ok(Services.prefs.prefHasUserValue("social.sidebar.provider"), "global state set");
|
||||
ok(!SocialSidebar.opened, "1. main sidebar is still closed");
|
||||
ok(w1.SocialSidebar.opened, "1. window sidebar is open");
|
||||
|
|
|
@ -4,55 +4,32 @@
|
|||
|
||||
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Promise",
|
||||
"resource://gre/modules/Promise.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Task",
|
||||
"resource://gre/modules/Task.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
|
||||
"resource://gre/modules/PlacesUtils.jsm");
|
||||
|
||||
function waitForCondition(condition, nextTest, errorMsg, numTries = 30) {
|
||||
var tries = 0;
|
||||
var interval = setInterval(function() {
|
||||
if (tries >= numTries) {
|
||||
ok(false, errorMsg);
|
||||
moveOn();
|
||||
}
|
||||
var conditionPassed;
|
||||
try {
|
||||
conditionPassed = condition();
|
||||
} catch (e) {
|
||||
ok(false, e + "\n" + e.stack);
|
||||
conditionPassed = false;
|
||||
}
|
||||
if (conditionPassed) {
|
||||
moveOn();
|
||||
}
|
||||
tries++;
|
||||
}, 100);
|
||||
var moveOn = function() { clearInterval(interval); nextTest(); };
|
||||
}
|
||||
|
||||
|
||||
function promiseObserverNotified(aTopic) {
|
||||
let deferred = Promise.defer();
|
||||
return new Promise(resolve => {
|
||||
Services.obs.addObserver(function onNotification(aSubject, aTopic, aData) {
|
||||
dump("notification promised "+aTopic);
|
||||
Services.obs.removeObserver(onNotification, aTopic);
|
||||
deferred.resolve({subject: aSubject, data: aData});
|
||||
TestUtils.executeSoon(() => resolve({subject: aSubject, data: aData}));
|
||||
}, aTopic, false);
|
||||
return deferred.promise;
|
||||
});
|
||||
}
|
||||
|
||||
// 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();
|
||||
return new Promise(resolve => {
|
||||
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();
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
var gURLsNotRemembered = [];
|
||||
|
@ -154,11 +131,11 @@ function runSocialTestWithProvider(manifest, callback, finishcallback) {
|
|||
registerCleanupFunction(function () {
|
||||
finishSocialTest(true);
|
||||
});
|
||||
waitForCondition(() => provider.enabled,
|
||||
function() {
|
||||
BrowserTestUtils.waitForCondition(() => provider.enabled,
|
||||
"providers added and enabled").then(() => {
|
||||
info("provider has been enabled");
|
||||
callback(finishSocialTest);
|
||||
}, "providers added and enabled");
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -307,39 +284,6 @@ function waitForNotification(topic, cb) {
|
|||
Services.obs.addObserver(observer, topic, false);
|
||||
}
|
||||
|
||||
// blocklist testing
|
||||
function updateBlocklist(aCallback) {
|
||||
var blocklistNotifier = Cc["@mozilla.org/extensions/blocklist;1"]
|
||||
.getService(Ci.nsITimerCallback);
|
||||
var observer = function() {
|
||||
Services.obs.removeObserver(observer, "blocklist-updated");
|
||||
if (aCallback)
|
||||
executeSoon(aCallback);
|
||||
};
|
||||
Services.obs.addObserver(observer, "blocklist-updated", false);
|
||||
blocklistNotifier.notify(null);
|
||||
}
|
||||
|
||||
var _originalTestBlocklistURL = null;
|
||||
function setAndUpdateBlocklist(aURL, aCallback) {
|
||||
if (!_originalTestBlocklistURL)
|
||||
_originalTestBlocklistURL = Services.prefs.getCharPref("extensions.blocklist.url");
|
||||
Services.prefs.setCharPref("extensions.blocklist.url", aURL);
|
||||
updateBlocklist(aCallback);
|
||||
}
|
||||
|
||||
function resetBlocklist(aCallback) {
|
||||
// XXX - this has "forked" from the head.js helpers in our parent directory :(
|
||||
// But let's reuse their blockNoPlugins.xml. Later, we should arrange to
|
||||
// use their head.js helpers directly
|
||||
let noBlockedURL = "http://example.com/browser/browser/base/content/test/plugins/blockNoPlugins.xml";
|
||||
setAndUpdateBlocklist(noBlockedURL, function() {
|
||||
Services.prefs.setCharPref("extensions.blocklist.url", _originalTestBlocklistURL);
|
||||
if (aCallback)
|
||||
aCallback();
|
||||
});
|
||||
}
|
||||
|
||||
function setManifestPref(name, manifest) {
|
||||
let string = Cc["@mozilla.org/supports-string;1"].
|
||||
createInstance(Ci.nsISupportsString);
|
||||
|
@ -375,64 +319,24 @@ function resetBuiltinManifestPref(name) {
|
|||
Services.prefs.PREF_INVALID, "default manifest removed");
|
||||
}
|
||||
|
||||
function addTab(url, callback) {
|
||||
let tab = gBrowser.selectedTab = gBrowser.addTab(url, {skipAnimation: true});
|
||||
tab.linkedBrowser.addEventListener("load", function tabLoad(event) {
|
||||
tab.linkedBrowser.removeEventListener("load", tabLoad, true);
|
||||
executeSoon(function() {callback(tab)});
|
||||
}, true);
|
||||
}
|
||||
|
||||
function selectBrowserTab(tab, callback) {
|
||||
if (gBrowser.selectedTab == tab) {
|
||||
executeSoon(function() {callback(tab)});
|
||||
return;
|
||||
}
|
||||
gBrowser.tabContainer.addEventListener("TabSelect", function onTabSelect() {
|
||||
gBrowser.tabContainer.removeEventListener("TabSelect", onTabSelect, false);
|
||||
is(gBrowser.selectedTab, tab, "browser tab is selected");
|
||||
executeSoon(function() {callback(tab)});
|
||||
});
|
||||
gBrowser.selectedTab = tab;
|
||||
}
|
||||
|
||||
function ensureEventFired(elem, event) {
|
||||
let deferred = Promise.defer();
|
||||
elem.addEventListener(event, function handler() {
|
||||
elem.removeEventListener(event, handler, true);
|
||||
deferred.resolve()
|
||||
}, true);
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
function loadIntoTab(tab, url, callback) {
|
||||
tab.linkedBrowser.addEventListener("load", function tabLoad(event) {
|
||||
tab.linkedBrowser.removeEventListener("load", tabLoad, true);
|
||||
executeSoon(function() {callback(tab)});
|
||||
}, true);
|
||||
tab.linkedBrowser.loadURI(url);
|
||||
}
|
||||
|
||||
function ensureBrowserTabClosed(tab) {
|
||||
let promise = ensureEventFired(gBrowser.tabContainer, "TabClose");
|
||||
gBrowser.removeTab(tab);
|
||||
return promise;
|
||||
return BrowserTestUtils.waitForEvent(elem, event, true);
|
||||
}
|
||||
|
||||
function ensureFrameLoaded(frame, uri) {
|
||||
let deferred = Promise.defer();
|
||||
return new Promise(resolve => {
|
||||
if (frame.contentDocument && frame.contentDocument.readyState == "complete" &&
|
||||
(!uri || frame.contentDocument.location.href == uri)) {
|
||||
deferred.resolve();
|
||||
resolve();
|
||||
} else {
|
||||
frame.addEventListener("load", function handler() {
|
||||
if (uri && frame.contentDocument.location.href != uri)
|
||||
return;
|
||||
frame.removeEventListener("load", handler, true);
|
||||
deferred.resolve()
|
||||
resolve()
|
||||
}, true);
|
||||
}
|
||||
return deferred.promise;
|
||||
});
|
||||
}
|
||||
|
||||
// chat test help functions
|
||||
|
@ -630,7 +534,7 @@ function getPopupWidth() {
|
|||
}
|
||||
|
||||
function promiseNodeRemoved(aNode) {
|
||||
let deferred = Promise.defer();
|
||||
return new Promise(resolve => {
|
||||
let parent = aNode.parentNode;
|
||||
|
||||
let observer = new MutationObserver(function onMutatations(mutations) {
|
||||
|
@ -641,12 +545,12 @@ function promiseNodeRemoved(aNode) {
|
|||
continue;
|
||||
}
|
||||
observer.disconnect();
|
||||
deferred.resolve();
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
});
|
||||
observer.observe(parent, {childList: true});
|
||||
return deferred.promise;
|
||||
});
|
||||
}
|
||||
|
||||
function promiseCloseChat(chat) {
|
||||
|
@ -678,7 +582,7 @@ var origProxyType = Services.prefs.getIntPref('network.proxy.type');
|
|||
|
||||
function toggleOfflineStatus(goOffline) {
|
||||
// Bug 968887 fix. when going on/offline, wait for notification before continuing
|
||||
let deferred = Promise.defer();
|
||||
return new Promise(resolve => {
|
||||
if (!goOffline) {
|
||||
Services.prefs.setIntPref('network.proxy.type', origProxyType);
|
||||
}
|
||||
|
@ -689,18 +593,18 @@ function toggleOfflineStatus(goOffline) {
|
|||
Services.obs.removeObserver(offlineChange, "network:offline-status-changed");
|
||||
info("offline state changed to " + Services.io.offline);
|
||||
is(expect, Services.io.offline, "network:offline-status-changed successful toggle");
|
||||
deferred.resolve();
|
||||
resolve();
|
||||
}, "network:offline-status-changed", false);
|
||||
BrowserOffline.toggleOfflineStatus();
|
||||
} else {
|
||||
deferred.resolve();
|
||||
resolve();
|
||||
}
|
||||
if (goOffline) {
|
||||
Services.prefs.setIntPref('network.proxy.type', 0);
|
||||
// LOAD_FLAGS_BYPASS_CACHE isn't good enough. So clear the cache.
|
||||
Services.cache2.clear();
|
||||
}
|
||||
return deferred.promise;
|
||||
});
|
||||
}
|
||||
|
||||
function goOffline() {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Activation test</title>
|
||||
</head>
|
||||
<script>
|
||||
|
|
Загрузка…
Ссылка в новой задаче