зеркало из https://github.com/mozilla/gecko-dev.git
Bug 596600 - Start generating window-level mouse out events at the root EventStateManager. r=smaug
--HG-- rename : widget/tests/test_native_mouse_mac.xul => widget/tests/test_bug596600.xul
This commit is contained in:
Родитель
46d9307293
Коммит
02b4fd3198
|
@ -6722,10 +6722,15 @@ PresShell::HandleEvent(nsIView *aView,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PRBool isWindowLevelMouseExit = (aEvent->message == NS_MOUSE_EXIT) &&
|
||||||
|
(static_cast<nsMouseEvent*>(aEvent)->exit == nsMouseEvent::eTopLevel);
|
||||||
|
|
||||||
// Get the frame at the event point. However, don't do this if we're
|
// Get the frame at the event point. However, don't do this if we're
|
||||||
// capturing and retargeting the event because the captured frame will
|
// capturing and retargeting the event because the captured frame will
|
||||||
// be used instead below.
|
// be used instead below. Also keep using the root frame if we're dealing
|
||||||
if (!captureRetarget) {
|
// with a window-level mouse exit event since we want to start sending
|
||||||
|
// mouse out events at the root EventStateManager.
|
||||||
|
if (!captureRetarget && !isWindowLevelMouseExit) {
|
||||||
nsPoint eventPoint
|
nsPoint eventPoint
|
||||||
= nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, frame);
|
= nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, frame);
|
||||||
{
|
{
|
||||||
|
|
|
@ -108,6 +108,8 @@ _CHROME_FILES += native_menus_window.xul \
|
||||||
test_bug586713.xul \
|
test_bug586713.xul \
|
||||||
bug586713_window.xul \
|
bug586713_window.xul \
|
||||||
test_key_event_counts.xul \
|
test_key_event_counts.xul \
|
||||||
|
test_bug596600.xul \
|
||||||
|
window_bug596600.xul \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,153 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||||
|
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
|
||||||
|
type="text/css"?>
|
||||||
|
<window title="Native mouse event tests"
|
||||||
|
xmlns:html="http://www.w3.org/1999/xhtml"
|
||||||
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||||
|
|
||||||
|
<title>Test for bug 596600</title>
|
||||||
|
<script type="application/javascript"
|
||||||
|
src="chrome://mochikit/content/MochiKit/packed.js"></script>
|
||||||
|
<script type="application/javascript"
|
||||||
|
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
|
||||||
|
|
||||||
|
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<p id="display"></p>
|
||||||
|
<div id="content" style="display: none">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<pre id="test">
|
||||||
|
</pre>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
<script class="testbody" type="application/javascript">
|
||||||
|
<![CDATA[
|
||||||
|
|
||||||
|
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
||||||
|
const NSMouseMoved = 5;
|
||||||
|
|
||||||
|
var gLeftWindow, gRightWindow, gIFrame;
|
||||||
|
var gExpectedEvents = [];
|
||||||
|
|
||||||
|
function moveMouseTo(x, y, andThen) {
|
||||||
|
var utils = gLeftWindow.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
|
||||||
|
getInterface(Components.interfaces.nsIDOMWindowUtils);
|
||||||
|
utils.sendNativeMouseEvent(x, y, NSMouseMoved, 0, gLeftWindow.documentElement);
|
||||||
|
SimpleTest.executeSoon(andThen);
|
||||||
|
}
|
||||||
|
|
||||||
|
function openWindows() {
|
||||||
|
gLeftWindow = open('window_bug596600.xul', '_blank', 'chrome,screenX=50,screenY=50,width=200,height=200');
|
||||||
|
SimpleTest.waitForFocus(function () {
|
||||||
|
gRightWindow = open('window_bug596600.xul', '', 'chrome,screenX=300,screenY=50,width=200,height=200');
|
||||||
|
SimpleTest.waitForFocus(attachIFrameToRightWindow, gRightWindow);
|
||||||
|
}, gLeftWindow);
|
||||||
|
}
|
||||||
|
|
||||||
|
function attachIFrameToRightWindow() {
|
||||||
|
gIFrame = gLeftWindow.document.createElementNS(XUL_NS, "iframe");
|
||||||
|
gIFrame.setAttribute("type", "content");
|
||||||
|
gIFrame.setAttribute("clickthrough", "never");
|
||||||
|
gIFrame.setAttribute("src", "data:text/html,<!DOCTYPE html>Content page");
|
||||||
|
gIFrame.style.width = "100px";
|
||||||
|
gIFrame.style.height = "100px";
|
||||||
|
gIFrame.style.margin = "50px";
|
||||||
|
gLeftWindow.document.documentElement.appendChild(gIFrame);
|
||||||
|
gIFrame.contentWindow.addEventListener("load", function (e) {
|
||||||
|
gIFrame.removeEventListener("load", arguments.callee, false);
|
||||||
|
test1();
|
||||||
|
}, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
function test1() {
|
||||||
|
// gRightWindow is active, gLeftWindow is inactive.
|
||||||
|
moveMouseTo(0, 0, function () {
|
||||||
|
var expectMouseOver = false, expectMouseOut = false;
|
||||||
|
function mouseOverListener(e) {
|
||||||
|
ok(expectMouseOver, "Got expected mouseover at " + e.screenX + ", " + e.screenY);
|
||||||
|
expectMouseOver = false;
|
||||||
|
}
|
||||||
|
function mouseOutListener(e) {
|
||||||
|
ok(expectMouseOut, "Got expected mouseout at " + e.screenX + ", " + e.screenY);
|
||||||
|
expectMouseOut = false;
|
||||||
|
}
|
||||||
|
gLeftWindow.addEventListener("mouseover", mouseOverListener, false);
|
||||||
|
gLeftWindow.addEventListener("mouseout", mouseOutListener, false);
|
||||||
|
|
||||||
|
// Move into the left window
|
||||||
|
expectMouseOver = true;
|
||||||
|
moveMouseTo(80, 80, function () {
|
||||||
|
ok(!expectMouseOver, "Should have got mouseover event");
|
||||||
|
|
||||||
|
// Move over the iframe, which has clickthrough="never".
|
||||||
|
expectMouseOut = true;
|
||||||
|
moveMouseTo(150, 150, function () {
|
||||||
|
ok (!expectMouseOut, "Should have got mouseout event");
|
||||||
|
gLeftWindow.removeEventListener("mouseover", mouseOverListener, false);
|
||||||
|
gLeftWindow.removeEventListener("mouseout", mouseOutListener, false);
|
||||||
|
test2();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function test2() {
|
||||||
|
// Make the iframe cover the whole window.
|
||||||
|
gIFrame.style.margin = "0";
|
||||||
|
gIFrame.style.width = gIFrame.style.height = "200px";
|
||||||
|
|
||||||
|
// Add a box to the iframe at the left edge.
|
||||||
|
var doc = gIFrame.contentDocument;
|
||||||
|
var box = doc.createElement("div");
|
||||||
|
box.setAttribute("id", "box");
|
||||||
|
box.style.position = "absolute";
|
||||||
|
box.style.left = "0";
|
||||||
|
box.style.top = "50px";
|
||||||
|
box.style.width = "100px";
|
||||||
|
box.style.height = "100px";
|
||||||
|
box.style.backgroundColor = "green";
|
||||||
|
doc.body.appendChild(box);
|
||||||
|
|
||||||
|
ok(!box.mozMatchesSelector(":hover"), "Box shouldn't be hovered (since the mouse isn't over it and since it's in a non-clickthrough iframe in a background window)");
|
||||||
|
|
||||||
|
// Move the mouse over the box.
|
||||||
|
moveMouseTo(100, 150, function () {
|
||||||
|
ok(!box.mozMatchesSelector(":hover"), "Box shouldn't be hovered (since it's in a non-clickthrough iframe in a background window)");
|
||||||
|
// Activate the left window.
|
||||||
|
SimpleTest.waitForFocus(function () {
|
||||||
|
ok(gIFrame.mozMatchesSelector(":hover"), "iframe should be hovered");
|
||||||
|
ok(box.mozMatchesSelector(":hover"), "Box should be hovered");
|
||||||
|
// De-activate the window (by activating the right window).
|
||||||
|
SimpleTest.waitForFocus(function () {
|
||||||
|
ok(!gIFrame.mozMatchesSelector(":hover"), "iframe shouldn't be hovered");
|
||||||
|
ok(!box.mozMatchesSelector(":hover"), "Box shouldn't be hovered");
|
||||||
|
// Re-activate it.
|
||||||
|
SimpleTest.waitForFocus(function () {
|
||||||
|
ok(gIFrame.mozMatchesSelector(":hover"), "iframe should be hovered");
|
||||||
|
ok(box.mozMatchesSelector(":hover"), "Box should be hovered");
|
||||||
|
// Unhover box and iframe by moving the mouse outside the window.
|
||||||
|
moveMouseTo(0, 150, function () {
|
||||||
|
ok(!gIFrame.mozMatchesSelector(":hover"), "iframe shouldn't be hovered");
|
||||||
|
ok(!box.mozMatchesSelector(":hover"), "box shouldn't be hovered");
|
||||||
|
finalize();
|
||||||
|
});
|
||||||
|
}, gLeftWindow);
|
||||||
|
}, gRightWindow);
|
||||||
|
}, gLeftWindow);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function finalize() {
|
||||||
|
gRightWindow.close();
|
||||||
|
gLeftWindow.close();
|
||||||
|
SimpleTest.finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
SimpleTest.waitForExplicitFinish();
|
||||||
|
SimpleTest.waitForFocus(openWindows);
|
||||||
|
|
||||||
|
]]>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</window>
|
|
@ -0,0 +1,4 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||||
|
<window title="Window for Test for Mozilla Bug 596600"
|
||||||
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"/>
|
Загрузка…
Ссылка в новой задаче