зеркало из https://github.com/mozilla/gecko-dev.git
Bug 612035 - "Don't compare unnecessary labels during browser-chrome tests." [r=mark.finkle]
This commit is contained in:
Родитель
fdc7e33baa
Коммит
2844a8500b
|
@ -27,7 +27,10 @@ var addons = [{
|
|||
homepageURL: "http://example.com/",
|
||||
version: "1.0",
|
||||
description: "Test add-on",
|
||||
sourceURL: TESTROOT + "addons/browser_install1_1.xpi"
|
||||
sourceURL: TESTROOT + "addons/browser_install1_1.xpi",
|
||||
bootstrapped: true,
|
||||
willFail: false,
|
||||
updateIndex: 2,
|
||||
},
|
||||
{
|
||||
id: "addon2@tests.mozilla.org",
|
||||
|
@ -36,7 +39,20 @@ var addons = [{
|
|||
homepageURL: "http://example.com/",
|
||||
version: "1.0",
|
||||
description: "Test add-on 2",
|
||||
sourceURL: TESTROOT + "addons/browser_install1_2.xpi"
|
||||
sourceURL: TESTROOT + "addons/browser_install1_2.xpi",
|
||||
bootstrapped: false,
|
||||
willFail: false,
|
||||
},
|
||||
{
|
||||
id: "addon1@tests.mozilla.org",
|
||||
name : "Install Tests 3",
|
||||
iconURL: "http://example.com/icon.png",
|
||||
homepageURL: "http://example.com/",
|
||||
version: "1.0",
|
||||
description: "Test add-on 3",
|
||||
sourceURL: TESTROOT + "addons/browser_install1_3.xpi",
|
||||
bootstrapped: false,
|
||||
willFail: false,
|
||||
}];
|
||||
|
||||
|
||||
|
@ -60,13 +76,12 @@ function test() {
|
|||
}
|
||||
|
||||
function end_test() {
|
||||
close_manager(function() {
|
||||
close_manager();
|
||||
Services.prefs.clearUserPref(PREF_GETADDONS_GETRECOMMENDED);
|
||||
Services.prefs.clearUserPref(PREF_GETADDONS_BROWSERECOMMENDED);
|
||||
Services.prefs.clearUserPref(PREF_GETADDONS_GETSEARCHRESULTS);
|
||||
Services.prefs.clearUserPref(PREF_GETADDONS_BROWSESEARCHRESULTS);
|
||||
finish();
|
||||
});
|
||||
}
|
||||
|
||||
function add_test(test) {
|
||||
|
@ -108,22 +123,31 @@ function installExtension(elt, aListener) {
|
|||
ExtensionsView.installFromRepo(elt);
|
||||
}
|
||||
|
||||
function isRestartShown(aShown, isUpdate) {
|
||||
function isRestartShown(aShown, isUpdate, aCallback) {
|
||||
let msg = document.getElementById("addons-messages");
|
||||
ok(!!msg, "Have message box");
|
||||
let notification = msg.getNotificationWithValue("restart-app");
|
||||
is(!!notification, aShown, "Restart exists = " + aShown);
|
||||
|
||||
if(notification) {
|
||||
let label = "";
|
||||
dump("Label: " + notification.label + "\n");
|
||||
if(isUpdate)
|
||||
label = "Add-ons updated. Restart to complete changes."
|
||||
else
|
||||
label = "Restart to complete changes.";
|
||||
is(notification.label, label, "Restart shows correct message");
|
||||
let done = function(aNotification) {
|
||||
is(!!aNotification, aShown, "Restart exists = " + aShown);
|
||||
if (aShown && aNotification) {
|
||||
let showsUpdate = aNotification.label.match(/update/i) != null;
|
||||
// this test regularly fails due to race conditions here
|
||||
is(showsUpdate, isUpdate, "Restart shows correct message");
|
||||
}
|
||||
msg.removeAllNotifications(true);
|
||||
aCallback();
|
||||
}
|
||||
|
||||
let notification = msg.getNotificationWithValue("restart-app");
|
||||
if (!notification && aShown) {
|
||||
window.addEventListener("AlertActive", function() {
|
||||
window.removeEventListener("AlertActive", arguments.callee, true);
|
||||
notification = msg.getNotificationWithValue("restart-app");
|
||||
done(notification);
|
||||
}, true);
|
||||
} else {
|
||||
done(notification);
|
||||
}
|
||||
msg.removeAllNotifications(true)
|
||||
}
|
||||
|
||||
function checkAddonListing(aAddon, elt) {
|
||||
|
@ -139,103 +163,79 @@ function checkAddonListing(aAddon, elt) {
|
|||
checkAttribute(elt, "sourceURL", aAddon.sourceURL);
|
||||
ok(elt.install, "Extension has install property");
|
||||
}
|
||||
function checkUpdate(aAddon, aSettings) {
|
||||
function checkUpdate(aSettings) {
|
||||
let os = Services.obs;
|
||||
let ul = new updateListener(aSettings);
|
||||
os.addObserver(ul, "addon-update-ended", false);
|
||||
|
||||
ExtensionsView.updateAll();
|
||||
//aAddon.findUpdates(new updateListener(aSettings), AddonManager.UPDATE_WHEN_USER_REQUESTED, "4.0", "4.0");
|
||||
}
|
||||
|
||||
function get_addon_element(aId) {
|
||||
|
||||
var node = document.getElementById("addons-list").firstChild;
|
||||
while (node) {
|
||||
if (("urn:mozilla:item:" + aId) == node.id)
|
||||
return node;
|
||||
node = node.nextSibling;
|
||||
}
|
||||
return null;
|
||||
|
||||
return document.getElementById("urn:mozilla:item:" + aId);
|
||||
}
|
||||
|
||||
function open_manager(aView, aCallback) {
|
||||
var panelButton = document.getElementById("tool-panel-open")
|
||||
panelButton.click();
|
||||
var addonsButton = document.getElementById("tool-addons");
|
||||
addonsButton.click();
|
||||
BrowserUI.showPanel("addons-container");
|
||||
|
||||
ExtensionsView.init();
|
||||
ExtensionsView._delayedInit();
|
||||
|
||||
if (!ExtensionsView._list) {
|
||||
window.addEventListener("ViewChanged", function() {
|
||||
window.removeEventListener("ViewChanged", arguments.callee, true);
|
||||
aCallback();
|
||||
}, true);
|
||||
|
||||
ExtensionsView.init();
|
||||
ExtensionsView._delayedInit();
|
||||
} else {
|
||||
aCallback();
|
||||
}
|
||||
}
|
||||
|
||||
function close_manager(aCallback) {
|
||||
function close_manager() {
|
||||
var prefsButton = document.getElementById("tool-preferences");
|
||||
prefsButton.click();
|
||||
|
||||
ExtensionsView.clearSection();
|
||||
ExtensionsView.clearSection("local");
|
||||
ExtensionsView._list = null;
|
||||
ExtensionsView._restartCount = 0;
|
||||
BrowserUI.hidePanel();
|
||||
aCallback();
|
||||
}
|
||||
// Installs a bootstrapped (restartless) addon first, and then
|
||||
// updates it to a non-bootstrapped addon. Checks to make sure
|
||||
|
||||
// Installs an addon from the addons pref pane, and then
|
||||
// updates it if requested. Checks to make sure
|
||||
// restart notifications are shown at the right time
|
||||
|
||||
// We currently don't handle bootstrapped addons very well, i.e.
|
||||
// they aren't moved from the browse area into the main area
|
||||
add_test(function() {
|
||||
function installFromAddonsPage(aAddon, aDoUpdate) {
|
||||
return function() {
|
||||
open_manager(null, function() {
|
||||
var elt = get_addon_element("addon1@tests.mozilla.org");
|
||||
checkAddonListing(addons[0], elt);
|
||||
var elt = get_addon_element(aAddon.id);
|
||||
checkAddonListing(aAddon, elt);
|
||||
installExtension(elt, new installListener({
|
||||
showRestart: false,
|
||||
willFail: false,
|
||||
onComplete: function(aAddon) {
|
||||
checkUpdate(aAddon, {
|
||||
showRestart: true,
|
||||
willFail: false,
|
||||
addon: addons[0],
|
||||
onComplete: function(aAddon) {
|
||||
close_manager(run_next_test);
|
||||
addon: aAddon,
|
||||
onComplete: function() {
|
||||
if (aDoUpdate) {
|
||||
checkUpdate({
|
||||
addon: addons[aAddon.updateIndex],
|
||||
onComplete: function() {
|
||||
close_manager();
|
||||
run_next_test();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
close_manager();
|
||||
run_next_test();
|
||||
}
|
||||
}
|
||||
}));
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Installs a non-bootstrapped addon and checks to make sure
|
||||
// the correct restart notifications are shown
|
||||
add_test(function() {
|
||||
open_manager(null, function() {
|
||||
var elt = get_addon_element("addon2@tests.mozilla.org");
|
||||
checkAddonListing(addons[1], elt);
|
||||
installExtension(elt, new installListener({
|
||||
showRestart: true,
|
||||
willFail: false,
|
||||
onComplete: run_next_test,
|
||||
}));
|
||||
});
|
||||
})
|
||||
add_test(installFromAddonsPage(addons[0], true));
|
||||
add_test(installFromAddonsPage(addons[1], false));
|
||||
|
||||
function installListener(aSettings) {
|
||||
this.willFail = aSettings.willFail;
|
||||
this.onComplete = aSettings.onComplete;
|
||||
this.showRestart = aSettings.showRestart;
|
||||
this.addon = aSettings.addon;
|
||||
}
|
||||
|
||||
installListener.prototype = {
|
||||
|
||||
onNewInstall : function(install) { },
|
||||
onDownloadStarted : function(install) {
|
||||
info("download started");
|
||||
|
@ -250,7 +250,7 @@ installListener.prototype = {
|
|||
info("download cancelled");
|
||||
},
|
||||
onDownloadFailed : function(install) {
|
||||
if(this.willFail)
|
||||
if(this.addon.willFail)
|
||||
ok(false, "Install failed");
|
||||
info("download failed");
|
||||
},
|
||||
|
@ -258,14 +258,12 @@ installListener.prototype = {
|
|||
info("Install started");
|
||||
},
|
||||
onInstallEnded : function(install, addon) {
|
||||
// this needs to fire after the extension manager's install ended
|
||||
let self = this;
|
||||
setTimeout(function() {
|
||||
info("Install ended");
|
||||
isRestartShown(self.showRestart, false);
|
||||
let self = this;
|
||||
isRestartShown(!this.addon.bootstrapped, false, function() {
|
||||
if(self.onComplete)
|
||||
self.onComplete(addon);
|
||||
}, 0);
|
||||
self.onComplete();
|
||||
});
|
||||
},
|
||||
onInstallCancelled : function(install) {
|
||||
info("Install cancelled");
|
||||
|
@ -279,9 +277,7 @@ installListener.prototype = {
|
|||
};
|
||||
|
||||
function updateListener(aSettings) {
|
||||
this.willFail = aSettings.willFail;
|
||||
this.onComplete = aSettings.onComplete;
|
||||
this.showRestart = aSettings.showRestart;
|
||||
this.addon = aSettings.addon;
|
||||
}
|
||||
|
||||
|
@ -289,25 +285,20 @@ updateListener.prototype = {
|
|||
observe: function (aSubject, aTopic, aData) {
|
||||
switch(aTopic) {
|
||||
case "addon-update-ended" :
|
||||
info("Update ended");
|
||||
// this needs to fire after the extension manager's install ended
|
||||
let self = this;
|
||||
|
||||
let json = aSubject.QueryInterface(Ci.nsISupportsString).data;
|
||||
let update = JSON.parse(json);
|
||||
if(update.id == this.addon.id) {
|
||||
let os = Services.obs;
|
||||
os.removeObserver(this, "addon-update-ended", false);
|
||||
|
||||
let element = get_addon_element(update.id);
|
||||
ok(!!element, "Have element for upgrade");
|
||||
|
||||
let addon = element.addon;
|
||||
|
||||
setTimeout(function() {
|
||||
isRestartShown(self.showRestart, true);
|
||||
let self = this;
|
||||
isRestartShown(!this.addon.bootstrapped, true, function() {
|
||||
if(self.onComplete)
|
||||
self.onComplete(addon);
|
||||
}, 100);
|
||||
let os = Services.obs;
|
||||
os.removeObserver(this, "addon-update-ended", false);
|
||||
self.onComplete();
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -3,19 +3,19 @@
|
|||
var gTests = [];
|
||||
var gCurrentTest = null;
|
||||
var expected = {
|
||||
"aboutButton": {"label": "Go to Page", "tagName": "button", "value": "About Fennec", "element_id": "prefs-about-button"},
|
||||
"homepage": {"element_id": "prefs-homepage", "value": "Start page", "label": "Fennec Start",
|
||||
"home_page": "prefs-homepage-default", "home_page_label": "Fennec Start",
|
||||
"blank_page": "prefs-homepage-none", "blank_page_label": "Blank Page",
|
||||
"current_page": "prefs-homepage-currentpage", "current_page_label": "Use Current Page"},
|
||||
"doneButton": {"label": "Done", "tagName": "button"},
|
||||
"contentRegion": {"element_id": "prefs-content", "label": "Content"},
|
||||
"imageRegion": {"pref": "permissions.default.image", "value": "Show images", "anonid": "input", "localName": "checkbox"},
|
||||
"jsRegion": {"pref": "javascript.enabled", "value": "Enable JavaScript", "anonid": "input", "localName": "checkbox"},
|
||||
"privacyRegion": {"element_id": "prefs-privacy", "label": "Privacy & Security"},
|
||||
"cookiesRegion": {"pref": "network.cookie.cookieBehavior", "value": "Allow cookies", "anonid": "input", "localName": "checkbox"},
|
||||
"passwordsRegion": {"pref": "signon.rememberSignons", "value": "Remember passwords", "anonid": "input", "localName": "checkbox"},
|
||||
"clearDataButton": {"value": "Clear private data", "element_id": "prefs-clear-data", "label": "Clear", "tagName": "button"}
|
||||
"aboutButton": {"tagName": "button", "element_id": "prefs-about-button"},
|
||||
"homepage": {"element_id": "prefs-homepage",
|
||||
"home_page": "prefs-homepage-default",
|
||||
"blank_page": "prefs-homepage-none",
|
||||
"current_page": "prefs-homepage-currentpage"},
|
||||
"doneButton": {"tagName": "button"},
|
||||
"contentRegion": {"element_id": "prefs-content"},
|
||||
"imageRegion": {"pref": "permissions.default.image", "anonid": "input", "localName": "checkbox"},
|
||||
"jsRegion": {"pref": "javascript.enabled", "anonid": "input", "localName": "checkbox"},
|
||||
"privacyRegion": {"element_id": "prefs-privacy" },
|
||||
"cookiesRegion": {"pref": "network.cookie.cookieBehavior", "anonid": "input", "localName": "checkbox"},
|
||||
"passwordsRegion": {"pref": "signon.rememberSignons", "anonid": "input", "localName": "checkbox"},
|
||||
"clearDataButton": {"element_id": "prefs-clear-data", "tagName": "button"}
|
||||
};
|
||||
|
||||
function getPreferencesElements() {
|
||||
|
@ -76,44 +76,27 @@ gTests.push({
|
|||
// Check for *About page*
|
||||
let about = expected.aboutButton;
|
||||
var aboutRegion = document.getAnonymousElementByAttribute(prefsList, "title", "About Fennec");
|
||||
var aboutLabel = document.getAnonymousElementByAttribute(aboutRegion, "class", "preftitle");
|
||||
is(aboutLabel.value, about.value, "Label Text for About Fennec");
|
||||
var aboutButton = document.getElementById(about.element_id);
|
||||
is(aboutButton.label, about.label, "Text for about button is Go to Page");
|
||||
is(aboutButton.tagName, about.tagName, "The About Fennec input must be a button");
|
||||
|
||||
// Check for *Startpage*
|
||||
let homepage = expected.homepage;
|
||||
var homepageRegion = document.getElementById(homepage.element_id);
|
||||
var homepageLabel = document.getAnonymousElementByAttribute(homepageRegion, "class", "preftitle");
|
||||
is(homepageLabel.value, homepage.value, "Label Text for Start Page");
|
||||
is(prefs.homeButton.label, homepage.label, "The text on the homepage label must be Fennec Start");
|
||||
prefs.homeButton.click();
|
||||
|
||||
is(prefs.selectContainer.hidden, false, "Homepage select dialog must be visible");
|
||||
is(document.getElementById(homepage.home_page).label,
|
||||
homepage.home_page_label, " First option is Fennec Start");
|
||||
is(document.getElementById(homepage.blank_page).label,
|
||||
homepage.blank_page_label, " Second option is Blank page");
|
||||
is(document.getElementById(homepage.current_page).label,
|
||||
homepage.current_page_label, " First option is Custom page");
|
||||
|
||||
let doneButton = expected.doneButton;
|
||||
is(prefs.doneButton.label, doneButton.label, "The text for the Done button");
|
||||
is(prefs.doneButton.tagName, doneButton.tagName, "The type of the Done input is button");
|
||||
prefs.doneButton.click();
|
||||
is(prefs.selectContainer.hidden, true, "Homepage select dialog must be closed");
|
||||
|
||||
|
||||
let content = expected.contentRegion;
|
||||
var contentRegion = document.getElementById(content.element_id);
|
||||
todo_is(contentRegion.label, content.label, "The Content region");
|
||||
|
||||
// Check for *Show images*
|
||||
var images = expected.imageRegion;
|
||||
var imageRegion = document.getAnonymousElementByAttribute(contentRegion, "pref", images.pref);
|
||||
var imageLabel = document.getAnonymousElementByAttribute(imageRegion, "class", "preftitle");
|
||||
is(imageLabel.value, images.value, "Show images label");
|
||||
var imageButton = document.getAnonymousElementByAttribute(imageRegion, "anonid", images.anonid);
|
||||
is(imageButton.localName, images.localName, "Show images checkbox check");
|
||||
// Checkbox or radiobutton?
|
||||
|
@ -121,21 +104,16 @@ gTests.push({
|
|||
// Check for *Enable javascript*
|
||||
let js = expected.jsRegion;
|
||||
var jsRegion = document.getAnonymousElementByAttribute(contentRegion, "pref", js.pref);
|
||||
var jsLabel = document.getAnonymousElementByAttribute(jsRegion, "class", "preftitle");
|
||||
is(jsLabel.value, js.value, "Enable JavaScript Label");
|
||||
var jsButton = document.getAnonymousElementByAttribute(jsRegion, "anonid", js.anonid);
|
||||
is(jsButton.localName, js.localName, "Enable JavaScript checkbox check");
|
||||
// Checkbox or radiobutton?
|
||||
|
||||
let privacyRegion = expected.privacyRegion;
|
||||
var prefsPrivacy = document.getElementById(privacyRegion.element_id);
|
||||
todo_is(prefsPrivacy.label, privacyRegion.label, "The privacy and security region");
|
||||
|
||||
// Check for *Allow cookies*
|
||||
let cookies = expected.cookiesRegion;
|
||||
var cookiesRegion = document.getAnonymousElementByAttribute(prefsPrivacy, "pref", cookies.pref);
|
||||
var cookiesLabel = document.getAnonymousElementByAttribute(cookiesRegion, "class", "preftitle");
|
||||
is(cookiesLabel.value, cookies.value, "Allow cookies label");
|
||||
var cookiesButton = document.getAnonymousElementByAttribute(cookiesRegion, "anonid", cookies.anonid);
|
||||
is(cookiesButton.localName, cookies.localName, "Allow cookies checkbox check");
|
||||
// Checkbox or radiobutton?
|
||||
|
@ -143,8 +121,6 @@ gTests.push({
|
|||
// Check for *Remember password*
|
||||
let passwords = expected.passwordsRegion;
|
||||
var passwordsRegion = document.getAnonymousElementByAttribute(prefsPrivacy, "pref", passwords.pref);
|
||||
var passwordLabel = document.getAnonymousElementByAttribute(passwordsRegion, "class", "preftitle");
|
||||
is(passwordLabel.value, passwords.value, "Remember Passwords Label");
|
||||
var passwordsButton = document.getAnonymousElementByAttribute(passwordsRegion, "anonid", passwords.anonid);
|
||||
is(passwordsButton.localName, passwords.localName, "Allow cookies checkbox check");
|
||||
// Checkbox or radiobutton?
|
||||
|
@ -152,10 +128,7 @@ gTests.push({
|
|||
// Check for *Clear Private Data*
|
||||
let clearData = expected.clearDataButton;
|
||||
var clearDataRegion = prefsPrivacy.lastChild;
|
||||
var clearDataLabel = document.getAnonymousElementByAttribute(clearDataRegion, "class", "preftitle");
|
||||
is(clearDataLabel.value, clearData.value, "Clear Private Data Label");
|
||||
var clearDataButton = document.getElementById(clearData.element_id);
|
||||
is(clearDataButton.label, clearData.label, "Label for Clear Private Data button");
|
||||
is(clearDataButton.tagName, clearData.tagName, "Check for Clear Private Data button type");
|
||||
|
||||
// 3. Verify content & privacy and security reasons are gray and of same height
|
||||
|
|
Загрузка…
Ссылка в новой задаче