Bug 1176239, test e10s tab navigation between parent and child, r=smaug

This commit is contained in:
Neil Deakin 2015-07-20 08:59:50 -04:00
parent 8e04720497
commit 47ff74eac6
2 changed files with 54 additions and 0 deletions

View File

@ -294,6 +294,7 @@ skip-if = true # browser_drag.js is disabled, as it needs to be updated for the
[browser_favicon_change.js]
[browser_favicon_change_not_in_document.js]
[browser_findbarClose.js]
[browser_focusnavigation.js]
[browser_fullscreen-window-open.js]
skip-if = buildapp == 'mulet' || e10s || os == "linux" # Bug 933103 - mochitest's EventUtils.synthesizeMouse functions not e10s friendly. Linux: Intermittent failures - bug 941575.
[browser_fxa_migrate.js]

View File

@ -0,0 +1,53 @@
/*
* This test checks that focus navigation iterates over the browser elements and content page.
*/
function doTab(expectedTarget)
{
let focusEventPromise = BrowserTestUtils.waitForEvent(expectedTarget, "focus", true);
EventUtils.synthesizeKey("VK_TAB", { });
return focusEventPromise;
}
add_task(function* () {
let testPage = "data:text/html,<html id='html1'><body id='body1'>Some Text<input id='input1'></body></html>";
yield BrowserTestUtils.openNewForegroundTab(gBrowser, testPage);
gURLBar.focus();
// Move focus to the searchbar
EventUtils.synthesizeKey("VK_TAB", { });
is(document.activeElement, document.getElementById("searchbar").textbox.inputField, "searchbar focused");
// Set the selection to a specific location, so that focus navigation would
// normally start from there.
yield ContentTask.spawn(gBrowser.selectedBrowser, { }, function* (arg) {
let selection = content.document.getSelection();
selection.modify("move", "right", "character");
});
// Move focus to the root element of the document
yield doTab(gBrowser.selectedBrowser);
is(document.activeElement, gBrowser.selectedBrowser, "browser focused");
let focusedId = yield ContentTask.spawn(gBrowser.selectedBrowser, { }, function* (arg) {
return content.document.activeElement.id;
});
is(focusedId, "html1", "html focused");
// Move focus to the button in the document
EventUtils.synthesizeKey("VK_TAB", { });
is(document.activeElement, gBrowser.selectedBrowser, "browser still focused");
focusedId = yield ContentTask.spawn(gBrowser.selectedBrowser, { }, function* (arg) {
return content.document.activeElement.id;
});
is(focusedId, "input1", "input focused");
// Move focus and loop back to the tabbar
yield doTab(document);
is(document.activeElement.localName, "tab", "tab focused");
gBrowser.removeCurrentTab();
});