forked from mirrors/gecko-dev
This patch makes the mininmum and the important elements and images visible in the high-constrast mode, including - making button have border (using the given default grey border in the high-constrast mode) - making the upper-left overlay button's fox image visible - making the images of the X close buttons on the notification bar and on the overlay visible - making that the navigation item of the current tour on the overlay's right side would have outline - making the hovered navigation item on the overlay's right side would have outline - making sure using <button> element for buttons for a better semantic - changing #onboarding-overlay-icon to #onboarding-overlay-button for a better semantic MozReview-Commit-ID: Aj6wndb4to9 --HG-- extra : rebase_source : 927658d278dc2ecec762cf856a10020329a95a50
88 lines
2.7 KiB
JavaScript
88 lines
2.7 KiB
JavaScript
/* Any copyright is dedicated to the Public Domain.
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
/*
|
|
* 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");
|
|
|
|
// 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.
|
|
await setLinks("0,1,2,3,4,5,6,7,8");
|
|
setPinnedLinks("");
|
|
|
|
if (onbardingEnabled) {
|
|
await promiseNoMuteNotificationOnFirstSession();
|
|
}
|
|
let tab = await addNewTabPageTab();
|
|
if (onbardingEnabled) {
|
|
FOCUS_COUNT += 3;
|
|
await promiseTourNotificationOpened(tab.linkedBrowser);
|
|
}
|
|
gURLBar.focus();
|
|
// Count the focus with the enabled page.
|
|
countFocus(FOCUS_COUNT);
|
|
// Disable page and count the focus with the disabled page.
|
|
NewTabUtils.allPages.enabled = false;
|
|
|
|
let expectedCount = 4;
|
|
if (onbardingEnabled) {
|
|
expectedCount += 3;
|
|
}
|
|
countFocus(expectedCount);
|
|
|
|
NewTabUtils.allPages.enabled = true;
|
|
});
|
|
|
|
/**
|
|
* Focus the urlbar and count how many focus stops to return again to the urlbar.
|
|
*/
|
|
function countFocus(aExpectedCount) {
|
|
let focusCount = 0;
|
|
do {
|
|
EventUtils.synthesizeKey("VK_TAB", {});
|
|
if (document.activeElement == gBrowser.selectedBrowser) {
|
|
focusCount++;
|
|
}
|
|
} while (document.activeElement != gURLBar.inputField);
|
|
ok(focusCount == aExpectedCount || focusCount == (aExpectedCount + 1),
|
|
"Validate focus count in the new tab page.");
|
|
}
|
|
|
|
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);
|
|
});
|
|
})
|
|
};
|
|
return BrowserTestUtils.waitForCondition(
|
|
condition,
|
|
"Should open tour notification",
|
|
100,
|
|
30
|
|
);
|
|
}
|