Bug 1386226 - Perma failure when 56 merges to beta in browser/base/content/test/newtab/browser_newtab_focus.js, r?mossop
This commit
- Fixes the focus count failure. The
bug 1375793 turned on the onboarding on all channels but this test still checks `AppConstants.NIGHTLY_BUILD`. Hence although the onboarding is enabled on Beta, this test thought it is disabled and missed counting the onboarding elements. The solution is to remove `AppConstants.NIGHTLY_BUILD` condition.
- Updates the `promiseTourNotificationOpened` function the same as the
bug 1383070 btw
MozReview-Commit-ID: 2TVyqDxMGS6
--- a/browser/base/content/test/newtab/browser_newtab_focus.js
+++ b/browser/base/content/test/newtab/browser_newtab_focus.js
@@ -4,17 +4,17 @@
/*
* These tests make sure that focusing the 'New Tab Page' works as expected.
*/
add_task(async function() {
await pushPrefs(["accessibility.tabfocus", 7]);
// When the onboarding component is enabled, it would inject extra tour notification into
// the newtab page so there would be 3 more overlay button, notification close button and action button
- let onbardingEnabled = AppConstants.NIGHTLY_BUILD && Services.prefs.getBoolPref("browser.onboarding.enabled");
+ let onbardingEnabled = Services.prefs.getBoolPref("browser.onboarding.enabled");
// Focus count in new tab page.
// 30 = 9 * 3 + 3 = 9 sites, each with link, pin and remove buttons; search
// bar; search button; and toggle button. Additionaly there may or may not be
// a scroll bar caused by fix to 1180387, which will eat an extra focus
let FOCUS_COUNT = 30;
// Create a new tab page.
@@ -62,27 +62,32 @@ function countFocus(aExpectedCount) {
function promiseNoMuteNotificationOnFirstSession() {
return SpecialPowers.pushPrefEnv({set: [["browser.onboarding.notification.mute-duration-on-first-session-ms", 0]]});
}
/**
* Wait for the onboarding tour notification opens
*/
function promiseTourNotificationOpened(browser) {
- let condition = () => {
- return ContentTask.spawn(browser, {}, function() {
- return new Promise(resolve => {
- let bar = content.document.querySelector("#onboarding-notification-bar");
- if (bar && bar.classList.contains("onboarding-opened")) {
- resolve(true);
- return;
- }
- resolve(false);
+ function isOpened() {
+ let doc = content && content.document;
+ let notification = doc.querySelector("#onboarding-notification-bar");
+ if (notification && notification.classList.contains("onboarding-opened")) {
+ ok(true, "Should open tour notification");
+ return Promise.resolve();
+ }
+ return new Promise(resolve => {
+ let observer = new content.MutationObserver(mutations => {
+ mutations.forEach(mutation => {
+ let bar = Array.from(mutation.addedNodes)
+ .find(node => node.id == "onboarding-notification-bar");
+ if (bar && bar.classList.contains("onboarding-opened")) {
+ observer.disconnect();
+ ok(true, "Should open tour notification");
+ resolve();
+ }
+ });
});
- })
- };
- return BrowserTestUtils.waitForCondition(
- condition,
- "Should open tour notification",
- 100,
- 30
- );
+ observer.observe(doc.body, { childList: true });
+ });
+ }
+ return ContentTask.spawn(browser, {}, isOpened);
}