Skip to content
This repository has been archived by the owner on Feb 29, 2020. It is now read-only.

Commit

Permalink
Fix Bug 1410828 - Add a test to verify that the next top site in queu…
Browse files Browse the repository at this point in the history
…e replaces a dismissed top site
  • Loading branch information
icrisan authored and piatra committed Apr 16, 2018
1 parent d6edded commit ead5539
Showing 1 changed file with 30 additions and 4 deletions.
Expand Up @@ -4,12 +4,9 @@

"use strict";

/**
* Test verifies the menu options for a default top site.
*/

test_newtab({
before: setDefaultTopSites,
// Test verifies the menu options for a default top site.
test: async function defaultTopSites_menuOptions() {
await ContentTaskUtils.waitForCondition(() => content.document.querySelector(".top-site-icon"),
"Topsite tippytop icon not found");
Expand All @@ -25,3 +22,32 @@ test_newtab({
}
}
});

test_newtab({
before: setDefaultTopSites,
// Test verifies that the next top site in queue replaces a dismissed top site.
test: async function defaultTopSites_dismiss() {
await ContentTaskUtils.waitForCondition(() => content.document.querySelector(".top-site-icon"),
"Topsite tippytop icon not found");

let defaultTopSitesNumber = content.document.querySelector(".top-sites-list").querySelectorAll("[class=\"top-site-outer\"]").length;
Assert.equal(defaultTopSitesNumber, 6, "6 top sites are loaded by default");

let secondTopSite = content.document.querySelector(".top-sites-list li:nth-child(2) a").getAttribute("href");

let contextMenuItems = content.openContextMenuAndGetOptions(".top-sites-list li:first-child");
Assert.equal(contextMenuItems[4].textContent, "Dismiss", "'Dismiss' is the 5th item in the context menu list");

contextMenuItems[4].querySelector("a").click();

// Need to wait for dismiss action.
await ContentTaskUtils.waitForCondition(() => content.document.querySelector(".top-sites-list li:first-child a").getAttribute("href") === secondTopSite,
"First topsite was dismissed");

defaultTopSitesNumber = content.document.querySelector(".top-sites-list").querySelectorAll("[class=\"top-site-outer\"]").length;
Assert.equal(defaultTopSitesNumber, 5, "5 top sites are displayed after one of them is dismissed");
},
async after() {
await new Promise(resolve => NewTabUtils.undoAll(resolve));
}
});

0 comments on commit ead5539

Please sign in to comment.