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

--HG--
extra : rebase_source : f6d0488f06d9fda42ba01e78e70ea64d389b0294
This commit is contained in:
Fischer.json 2017-08-02 15:57:33 +08:00
Родитель ff029dbbbe
Коммит cd05af9091
1 изменённых файлов: 23 добавлений и 18 удалений

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

@ -9,7 +9,7 @@ add_task(async function() {
// 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
@ -67,22 +67,27 @@ function promiseNoMuteNotificationOnFirstSession() {
* 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);
}