Bug 1110677 - Add automated test for 'Change newtab page appearance'. r=ttaubert

This commit is contained in:
Cosmin Malutan 2015-01-12 03:36:00 -05:00
Родитель d0025a424f
Коммит edf33ecf63
2 изменённых файлов: 37 добавлений и 3 удалений

Просмотреть файл

@ -37,8 +37,8 @@ function runTests() {
yield setLinks("-1");
// Test with enhanced = false
NewTabUtils.allPages.enhanced = false;
yield addNewTabPageTab();
yield customizeNewTabPage("classic");
let {type, enhanced, title} = getData(0);
is(type, "organic", "directory link is organic");
isnot(enhanced, "", "directory link has enhanced image");
@ -47,8 +47,8 @@ function runTests() {
is(getData(1), null, "history link pushed out by directory link");
// Test with enhanced = true
NewTabUtils.allPages.enhanced = true;
yield addNewTabPageTab();
yield customizeNewTabPage("enhanced");
({type, enhanced, title} = getData(0));
is(type, "organic", "directory link is still organic");
isnot(enhanced, "", "directory link still has enhanced image");
@ -67,12 +67,15 @@ function runTests() {
is(getData(1), null, "directory link pushed out by pinned history link");
// Test pinned link with enhanced = false
NewTabUtils.allPages.enhanced = false;
yield addNewTabPageTab();
yield customizeNewTabPage("classic");
({type, enhanced, title} = getData(0));
isnot(type, "enhanced", "history link is not enhanced");
is(enhanced, "", "history link has no enhanced image");
is(title, "site#-1");
is(getData(1), null, "directory link still pushed out by pinned history link");
ok(getContentDocument().getElementById("newtab-intro-what"),
"'What is this page?' link exists");
}

Просмотреть файл

@ -684,3 +684,34 @@ function whenSearchInitDone() {
});
return deferred.promise;
}
/**
* Changes the newtab customization option and waits for the panel to open and close
*
* @param {string} aTheme
* Can be any of("blank"|"classic"|"enhanced")
*/
function customizeNewTabPage(aTheme) {
let document = getContentDocument();
let panel = document.getElementById("newtab-customize-panel");
let customizeButton = document.getElementById("newtab-customize-button");
// Attache onShown the listener on panel
panel.addEventListener("popupshown", function onShown() {
panel.removeEventListener("popupshown", onShown);
// Get the element for the specific option and click on it,
// then trigger an escape to close the panel
document.getElementById("newtab-customize-" + aTheme).click();
executeSoon(() => { panel.hidePopup(); });
});
// Attache the listener for panel closing, this will resolve the promise
panel.addEventListener("popuphidden", function onHidden() {
panel.removeEventListener("popuphidden", onHidden);
executeSoon(TestRunner.next);
});
// Click on the customize button to display the panel
customizeButton.click();
}