Bug 1270117 - Modify browser_focus_steal_from_chrome_during_mousedown to run on e10s, r=enndeakin

This commit is contained in:
Michael Layzell 2016-05-03 11:59:14 -04:00
Родитель 7ed351b002
Коммит 3082b353b8
2 изменённых файлов: 30 добавлений и 45 удалений

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

@ -30,7 +30,6 @@ skip-if= buildapp == 'mulet'
[browser_bug396843.js]
[browser_focus_steal_from_chrome.js]
[browser_focus_steal_from_chrome_during_mousedown.js]
skip-if = e10s
[browser_frame_elements.js]
[browser_localStorage_privatestorageevent.js]
[browser_test_new_window_from_content.js]

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

@ -1,6 +1,4 @@
function test() {
waitForExplicitFinish();
add_task(function* test() {
const kTestURI =
"data:text/html," +
"<script type=\"text/javascript\">" +
@ -10,50 +8,38 @@ function test() {
" }" +
"</script>" +
"<body id=\"body\">" +
"<button id=\"eventTarget\" onmousedown=\"onMouseDown(event);\">click here</button>" +
"<button onmousedown=\"onMouseDown(event);\" style=\"width: 100px; height: 100px;\">click here</button>" +
"<input id=\"willBeFocused\"></body>";
let tab = gBrowser.addTab();
gBrowser.selectedTab = tab;
let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, kTestURI);
// Set the focus to the contents.
tab.linkedBrowser.focus();
// Load on the tab
tab.linkedBrowser.addEventListener("load", onLoadTab, true);
tab.linkedBrowser.loadURI(kTestURI);
let fm = Components.classes["@mozilla.org/focus-manager;1"].
getService(Components.interfaces.nsIFocusManager);
function onLoadTab() {
tab.linkedBrowser.removeEventListener("load", onLoadTab, true);
setTimeout(doTest, 0);
for (var button = 0; button < 3; button++) {
// Set focus to a chrome element before synthesizing a mouse down event.
document.getElementById("urlbar").focus();
is(fm.focusedElement, document.getElementById("urlbar").inputField,
"Failed to move focus to search bar: button=" + button);
// Synthesize mouse down event on browser object over the button, such that
// the event propagates through both processes.
EventUtils.synthesizeMouse(tab.linkedBrowser, 20, 20, { "button": button }, null);
isnot(fm.focusedElement, document.getElementById("urlbar").inputField,
"Failed to move focus away from search bar: button=" + button);
yield ContentTask.spawn(tab.linkedBrowser, button, function (button) {
let fm = Components.classes["@mozilla.org/focus-manager;1"].
getService(Components.interfaces.nsIFocusManager);
Assert.equal(content.document.activeElement.id, "willBeFocused",
"The input element isn't active element: button=" + button);
Assert.equal(fm.focusedElement, content.document.activeElement,
"The active element isn't focused element in App level: button=" + button);
});
}
function doTest() {
let fm = Components.classes["@mozilla.org/focus-manager;1"].
getService(Components.interfaces.nsIFocusManager);
let eventTarget =
tab.linkedBrowser.contentDocument.getElementById("eventTarget");
for (var button = 0; button < 3; button++) {
// Set focus to a chrome element before synthesizing a mouse down event.
document.getElementById("urlbar").focus();
is(fm.focusedElement, document.getElementById("urlbar").inputField,
"Failed to move focus to search bar: button=" +
button);
EventUtils.synthesizeMouse(eventTarget, 10, 10, { "button": button },
tab.linkedBrowser.contentWindow);
let e = tab.linkedBrowser.contentDocument.activeElement;
is(e.id, "willBeFocused",
"The input element isn't active element: button=" + button);
is(fm.focusedElement, e,
"The active element isn't focused element in App level: button=" +
button);
}
gBrowser.removeTab(tab);
finish();
}
}
gBrowser.removeTab(tab);
});