Bug 1327946 - Remove conditional moz-user-focus on identity block from urlbar. r=Gijs

MozReview-Commit-ID: 9F39TeDIGUf

--HG--
extra : rebase_source : 5968118ed303ed6a49163a8d81cbe5fcb59861e3
This commit is contained in:
Johann Hofmann 2017-01-24 11:42:09 +01:00
Родитель 56b53b069d
Коммит e4748208b9
6 изменённых файлов: 83 добавлений и 6 удалений

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

@ -565,8 +565,13 @@ toolbar:not(#TabsToolbar) > #personal-bookmarks {
visibility: collapse;
}
#identity-box {
-moz-user-focus: normal;
}
#urlbar[pageproxystate="invalid"] > #identity-box {
pointer-events: none;
-moz-user-focus: ignore;
}
#identity-icon-labels {

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

@ -689,13 +689,9 @@
newlines="stripsurroundingwhitespace"
ontextentered="this.handleCommand(param);"
ontextreverted="return this.handleRevert();"
pageproxystate="invalid"
onfocus="document.getElementById('identity-box').style.MozUserFocus= 'normal'"
onblur="setTimeout(() => { document.getElementById('identity-box').style.MozUserFocus = ''; }, 0);">
pageproxystate="invalid">
<!-- Use onclick instead of normal popup= syntax since the popup
code fires onmousedown, and hence eats our favicon drag events.
We only add the identity-box button to the tab order when the location bar
has focus, otherwise pressing F6 focuses it instead of the location bar -->
code fires onmousedown, and hence eats our favicon drag events. -->
<box id="identity-box" role="button"
align="center"
aria-label="&urlbar.viewSiteInfo.label;"

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

@ -0,0 +1,7 @@
[DEFAULT]
support-files =
head.js
[browser_identityBlock_focus.js]
skip-if = os == 'mac' # Bug 1334418 (try only)
support-files = ../general/permissions.html

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

@ -0,0 +1,62 @@
/* Tests that the identity block can be reached via keyboard
* shortcuts and that it has the correct tab order.
*/
const TEST_PATH = getRootDirectory(gTestPath).replace("chrome://mochitests/content", "https://example.com");
const PERMISSIONS_PAGE = TEST_PATH + "permissions.html";
function synthesizeKeyAndWaitForFocus(element, keyCode, options) {
let focused = BrowserTestUtils.waitForEvent(element, "focus");
EventUtils.synthesizeKey(keyCode, options);
return focused;
}
// Checks that the identity block is the next element after the urlbar
// to be focused if there are no active notification anchors.
add_task(function* testWithoutNotifications() {
yield BrowserTestUtils.withNewTab("https://example.com", function*() {
yield synthesizeKeyAndWaitForFocus(gURLBar, "l", {accelKey: true})
is(document.activeElement, gURLBar.inputField, "urlbar should be focused");
yield synthesizeKeyAndWaitForFocus(gIdentityHandler._identityBox, "VK_TAB", {shiftKey: true})
is(document.activeElement, gIdentityHandler._identityBox,
"identity block should be focused");
});
});
// Checks that when there is a notification anchor, it will receive
// focus before the identity block.
add_task(function* testWithoutNotifications() {
yield BrowserTestUtils.withNewTab(PERMISSIONS_PAGE, function*(browser) {
let popupshown = BrowserTestUtils.waitForEvent(PopupNotifications.panel, "popupshown");
// Request a permission;
BrowserTestUtils.synthesizeMouseAtCenter("#geo", {}, browser);
yield popupshown;
yield synthesizeKeyAndWaitForFocus(gURLBar, "l", {accelKey: true})
is(document.activeElement, gURLBar.inputField, "urlbar should be focused");
let geoIcon = document.getElementById("geo-notification-icon");
yield synthesizeKeyAndWaitForFocus(geoIcon, "VK_TAB", {shiftKey: true})
is(document.activeElement, geoIcon, "notification anchor should be focused");
yield synthesizeKeyAndWaitForFocus(gIdentityHandler._identityBox, "VK_TAB", {shiftKey: true})
is(document.activeElement, gIdentityHandler._identityBox,
"identity block should be focused");
});
});
// Checks that with invalid pageproxystate the identity block is ignored.
add_task(function* testInvalidPageProxyState() {
yield BrowserTestUtils.withNewTab("about:blank", function*(browser) {
// Loading about:blank will automatically focus the urlbar, which, however, can
// race with the test code. So we only send the shortcut if the urlbar isn't focused yet.
if (document.activeElement != gURLBar.inputField) {
yield synthesizeKeyAndWaitForFocus(gURLBar, "l", {accelKey: true})
}
is(document.activeElement, gURLBar.inputField, "urlbar should be focused");
yield synthesizeKeyAndWaitForFocus(gBrowser.getTabForBrowser(browser), "VK_TAB", {shiftKey: true})
isnot(document.activeElement, gIdentityHandler._identityBox,
"identity block should not be focused");
// Restore focus to the url bar.
gURLBar.focus();
});
});

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

@ -0,0 +1,6 @@
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Promise",
"resource://gre/modules/Promise.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Task",
"resource://gre/modules/Task.jsm");

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

@ -22,6 +22,7 @@ BROWSER_CHROME_MANIFESTS += [
'content/test/plugins/browser.ini',
'content/test/popupNotifications/browser.ini',
'content/test/referrer/browser.ini',
'content/test/siteIdentity/browser.ini',
'content/test/social/browser.ini',
'content/test/tabcrashed/browser.ini',
'content/test/tabPrompts/browser.ini',