зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 6cc9a20bbb57 (bug 1634569) for mochitest failures on test_focus.xhtml . CLOSED TREE
This commit is contained in:
Родитель
2c0e9ee363
Коммит
96bd10ac35
|
@ -11,15 +11,13 @@ add_task(async function() {
|
|||
|
||||
let promiseTabOpened = BrowserTestUtils.waitForNewTab(
|
||||
gBrowser,
|
||||
FILE + "?open-click",
|
||||
FILE + "?opened",
|
||||
true
|
||||
);
|
||||
info("Opening second tab using a click");
|
||||
await BrowserTestUtils.synthesizeMouseAtCenter(
|
||||
"#open-click",
|
||||
{},
|
||||
firstTab.linkedBrowser
|
||||
);
|
||||
await SpecialPowers.spawn(firstTab.linkedBrowser, [""], async function() {
|
||||
content.document.querySelector("#open").click();
|
||||
});
|
||||
|
||||
info("Waiting for the second tab to be opened");
|
||||
let secondTab = await promiseTabOpened;
|
||||
|
@ -36,43 +34,6 @@ add_task(async function() {
|
|||
|
||||
is(gBrowser.selectedTab, secondTab, "Should've switched tabs");
|
||||
|
||||
await BrowserTestUtils.removeTab(firstTab);
|
||||
await BrowserTestUtils.removeTab(secondTab);
|
||||
});
|
||||
|
||||
add_task(async function() {
|
||||
info("Opening first tab: " + FILE);
|
||||
let firstTab = await BrowserTestUtils.openNewForegroundTab(gBrowser, FILE);
|
||||
|
||||
let promiseTabOpened = BrowserTestUtils.waitForNewTab(
|
||||
gBrowser,
|
||||
FILE + "?open-mousedown",
|
||||
true
|
||||
);
|
||||
info("Opening second tab using a click");
|
||||
await BrowserTestUtils.synthesizeMouseAtCenter(
|
||||
"#open-mousedown",
|
||||
{ type: "mousedown" },
|
||||
firstTab.linkedBrowser
|
||||
);
|
||||
|
||||
info("Waiting for the second tab to be opened");
|
||||
let secondTab = await promiseTabOpened;
|
||||
|
||||
is(gBrowser.selectedTab, secondTab, "Should've switched tabs");
|
||||
|
||||
info("Ensuring we don't switch back");
|
||||
await new Promise(resolve => {
|
||||
// We need to wait for something _not_ happening, so we need to use an arbitrary setTimeout.
|
||||
//
|
||||
// eslint-disable-next-line mozilla/no-arbitrary-setTimeout
|
||||
setTimeout(function() {
|
||||
is(gBrowser.selectedTab, secondTab, "Should've remained in original tab");
|
||||
resolve();
|
||||
}, 500);
|
||||
});
|
||||
|
||||
info("cleanup");
|
||||
await BrowserTestUtils.removeTab(firstTab);
|
||||
await BrowserTestUtils.removeTab(secondTab);
|
||||
BrowserTestUtils.removeTab(firstTab);
|
||||
BrowserTestUtils.removeTab(secondTab);
|
||||
});
|
||||
|
|
|
@ -1,15 +1,8 @@
|
|||
<!doctype html>
|
||||
<script>
|
||||
function openWindow(id) {
|
||||
window.childWindow = window.open(location.href + "?" + id, "", "");
|
||||
function openWindow() {
|
||||
window.childWindow = window.open(location.href + "?opened", "", "");
|
||||
}
|
||||
</script>
|
||||
<button id="open-click" onclick="openWindow('open-click')">Open window</button>
|
||||
<button id="open" onclick="openWindow()">Open window</button>
|
||||
<button id="focus" onclick="window.childWindow.focus()">Focus window</button>
|
||||
<button id="open-mousedown">Open window</button>
|
||||
<script>
|
||||
document.getElementById("open-mousedown").addEventListener("mousedown", function(e) {
|
||||
openWindow(this.id);
|
||||
e.preventDefault();
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -3260,6 +3260,30 @@ nsresult EventStateManager::PostHandleEvent(nsPresContext* aPresContext,
|
|||
// if we're here, the event handler returned false, so stop
|
||||
// any of our own processing of a drag. Workaround for bug 43258.
|
||||
StopTrackingDragGesture(true);
|
||||
|
||||
// When the event was cancelled, there is currently a chrome document
|
||||
// focused and a mousedown just occurred on a content document, ensure
|
||||
// that the window that was clicked is focused.
|
||||
EnsureDocument(mPresContext);
|
||||
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
|
||||
if (mDocument && fm) {
|
||||
nsCOMPtr<mozIDOMWindowProxy> window;
|
||||
fm->GetFocusedWindow(getter_AddRefs(window));
|
||||
auto* currentWindow = nsPIDOMWindowOuter::From(window);
|
||||
if (currentWindow && mDocument->GetWindow() &&
|
||||
currentWindow != mDocument->GetWindow() &&
|
||||
!nsContentUtils::IsChromeDoc(mDocument)) {
|
||||
nsCOMPtr<nsPIDOMWindowOuter> currentTop;
|
||||
nsCOMPtr<nsPIDOMWindowOuter> newTop;
|
||||
currentTop = currentWindow->GetInProcessTop();
|
||||
newTop = mDocument->GetWindow()->GetInProcessTop();
|
||||
nsCOMPtr<Document> currentDoc = currentWindow->GetExtantDoc();
|
||||
if (nsContentUtils::IsChromeDoc(currentDoc) ||
|
||||
(currentTop && newTop && currentTop != newTop)) {
|
||||
fm->SetFocusedWindow(mDocument->GetWindow());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
SetActiveManager(this, activeContent);
|
||||
} break;
|
||||
|
|
|
@ -9,6 +9,7 @@ support-files =
|
|||
file_clipboard_events_chrome.html
|
||||
file_DOM_element_instanceof.xhtml
|
||||
file_MozDomFullscreen.html
|
||||
file_bug799299.xhtml
|
||||
file_bug800817.xhtml
|
||||
file_bug830858.xhtml
|
||||
file_bug1224790-1_modal.xhtml
|
||||
|
@ -41,6 +42,7 @@ support-files =
|
|||
[test_DOM_element_instanceof.xhtml]
|
||||
[test_activation.xhtml]
|
||||
tags = fullscreen
|
||||
[test_bug799299.xhtml]
|
||||
[test_bug800817.xhtml]
|
||||
[test_bug830858.xhtml]
|
||||
[test_bug1224790-1.xhtml]
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
|
||||
<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=799299
|
||||
-->
|
||||
<window title="Mozilla Bug 799299"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||
<script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
|
||||
|
||||
<!-- test results are displayed in the html:body -->
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=799299"
|
||||
target="_blank">Mozilla Bug 799299</a>
|
||||
</body>
|
||||
|
||||
<!-- test code goes here -->
|
||||
<script type="application/javascript">
|
||||
<![CDATA[
|
||||
/** Test for Bug 799299 **/
|
||||
|
||||
function sendClick(win) {
|
||||
var wu = win.windowUtils;
|
||||
wu.sendMouseEventToWindow("mousedown", 10, 10, 0, 0, 0);
|
||||
wu.sendMouseEventToWindow("mouseup", 10, 10, 0, 0, 0);
|
||||
}
|
||||
|
||||
function runTests() {
|
||||
var b1 = document.getElementById("b1");
|
||||
var b2 = document.getElementById("b2");
|
||||
b1.contentWindow.focus();
|
||||
window.arguments[0].is(document.activeElement, b1,
|
||||
"Focused first iframe");
|
||||
|
||||
var didCallDummy = false;
|
||||
b2.contentWindow.addEventListener("mousedown", function(e) { didCallDummy = true; });
|
||||
sendClick(b2.contentWindow);
|
||||
window.arguments[0].ok(didCallDummy, "dummy mousedown handler should fire");
|
||||
window.arguments[0].is(document.activeElement, b2,
|
||||
"Focus shifted to second iframe");
|
||||
|
||||
b1.contentWindow.focus();
|
||||
window.arguments[0].is(document.activeElement, b1,
|
||||
"Re-focused first iframe for the first time");
|
||||
|
||||
var didCallListener = false;
|
||||
b2.contentWindow.addEventListener("mousedown", function(e) { didCallListener = true; e.preventDefault(); });
|
||||
sendClick(b2.contentWindow);
|
||||
window.arguments[0].ok(didCallListener, "mousedown handler should fire");
|
||||
window.arguments[0].is(document.activeElement, b2,
|
||||
"focus should move to the second iframe");
|
||||
|
||||
window.close();
|
||||
window.arguments[0].SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForFocus(runTests);
|
||||
]]>
|
||||
</script>
|
||||
<hbox flex="1">
|
||||
<browser id="b1" type="content" src="about:blank" flex="1" style="border: 1px solid black;"/>
|
||||
<browser id="b2" type="content" src="about:blank" flex="1" style="border: 1px solid black;"/>
|
||||
</hbox>
|
||||
</window>
|
|
@ -0,0 +1,31 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
|
||||
<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=799299
|
||||
-->
|
||||
<window title="Mozilla Bug 799299" onload="runTests()"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||
<script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
|
||||
|
||||
<!-- test results are displayed in the html:body -->
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=799299"
|
||||
target="_blank">Mozilla Bug 799299</a>
|
||||
</body>
|
||||
|
||||
<!-- test code goes here -->
|
||||
<script type="application/javascript">
|
||||
<![CDATA[
|
||||
/** Test for Bug 799299 **/
|
||||
|
||||
function runTests() {
|
||||
window.openDialog("file_bug799299.xhtml", "_blank", "chrome,width=600,height=550,noopener", window);
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
]]>
|
||||
</script>
|
||||
</window>
|
Загрузка…
Ссылка в новой задаче