gecko-dev/widget/tests/test_bug596600.xhtml

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

194 строки
7.0 KiB
HTML
Исходник Обычный вид История

<?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="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" />
<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";
var gLeftWindow, gRightWindow, gBrowserElement;
function openWindows() {
gLeftWindow = window.browsingContext.topChromeWindow
Bug 1596327, rename .xul test files in widget/ to .xhtml r=jmathies Differential Revision: https://phabricator.services.mozilla.com/D53047 --HG-- rename : widget/cocoa/crashtests/444260-1.xul => widget/cocoa/crashtests/444260-1.xhtml rename : widget/tests/bug586713_window.xul => widget/tests/bug586713_window.xhtml rename : widget/tests/chrome_context_menus_win.xul => widget/tests/chrome_context_menus_win.xhtml rename : widget/tests/empty_window.xul => widget/tests/empty_window.xhtml rename : widget/tests/native_menus_window.xul => widget/tests/native_menus_window.xhtml rename : widget/tests/native_mouse_mac_window.xul => widget/tests/native_mouse_mac_window.xhtml rename : widget/tests/standalone_native_menu_window.xul => widget/tests/standalone_native_menu_window.xhtml rename : widget/tests/system_font_changes.xul => widget/tests/system_font_changes.xhtml rename : widget/tests/taskbar_previews.xul => widget/tests/taskbar_previews.xhtml rename : widget/tests/test_bug1123480.xul => widget/tests/test_bug1123480.xhtml rename : widget/tests/test_bug343416.xul => widget/tests/test_bug343416.xhtml rename : widget/tests/test_bug428405.xul => widget/tests/test_bug428405.xhtml rename : widget/tests/test_bug429954.xul => widget/tests/test_bug429954.xhtml rename : widget/tests/test_bug444800.xul => widget/tests/test_bug444800.xhtml rename : widget/tests/test_bug466599.xul => widget/tests/test_bug466599.xhtml rename : widget/tests/test_bug478536.xul => widget/tests/test_bug478536.xhtml rename : widget/tests/test_bug485118.xul => widget/tests/test_bug485118.xhtml rename : widget/tests/test_bug517396.xul => widget/tests/test_bug517396.xhtml rename : widget/tests/test_bug522217.xul => widget/tests/test_bug522217.xhtml rename : widget/tests/test_bug538242.xul => widget/tests/test_bug538242.xhtml rename : widget/tests/test_bug586713.xul => widget/tests/test_bug586713.xhtml rename : widget/tests/test_bug593307.xul => widget/tests/test_bug593307.xhtml rename : widget/tests/test_bug596600.xul => widget/tests/test_bug596600.xhtml rename : widget/tests/test_bug673301.xul => widget/tests/test_bug673301.xhtml rename : widget/tests/test_bug760802.xul => widget/tests/test_bug760802.xhtml rename : widget/tests/test_chrome_context_menus_win.xul => widget/tests/test_chrome_context_menus_win.xhtml rename : widget/tests/test_clipboard.xul => widget/tests/test_clipboard.xhtml rename : widget/tests/test_composition_text_querycontent.xul => widget/tests/test_composition_text_querycontent.xhtml rename : widget/tests/test_input_events_on_deactive_window.xul => widget/tests/test_input_events_on_deactive_window.xhtml rename : widget/tests/test_key_event_counts.xul => widget/tests/test_key_event_counts.xhtml rename : widget/tests/test_keycodes.xul => widget/tests/test_keycodes.xhtml rename : widget/tests/test_mouse_scroll.xul => widget/tests/test_mouse_scroll.xhtml rename : widget/tests/test_native_menus.xul => widget/tests/test_native_menus.xhtml rename : widget/tests/test_native_mouse_mac.xul => widget/tests/test_native_mouse_mac.xhtml rename : widget/tests/test_panel_mouse_coords.xul => widget/tests/test_panel_mouse_coords.xhtml rename : widget/tests/test_platform_colors.xul => widget/tests/test_platform_colors.xhtml rename : widget/tests/test_position_on_resize.xul => widget/tests/test_position_on_resize.xhtml rename : widget/tests/test_sizemode_events.xul => widget/tests/test_sizemode_events.xhtml rename : widget/tests/test_standalone_native_menu.xul => widget/tests/test_standalone_native_menu.xhtml rename : widget/tests/test_system_font_changes.xul => widget/tests/test_system_font_changes.xhtml rename : widget/tests/test_system_status_bar.xul => widget/tests/test_system_status_bar.xhtml rename : widget/tests/test_taskbar_progress.xul => widget/tests/test_taskbar_progress.xhtml rename : widget/tests/test_transferable_overflow.xul => widget/tests/test_transferable_overflow.xhtml rename : widget/tests/test_wheeltransaction.xul => widget/tests/test_wheeltransaction.xhtml rename : widget/tests/window_bug429954.xul => widget/tests/window_bug429954.xhtml rename : widget/tests/window_bug478536.xul => widget/tests/window_bug478536.xhtml rename : widget/tests/window_bug522217.xul => widget/tests/window_bug522217.xhtml rename : widget/tests/window_bug538242.xul => widget/tests/window_bug538242.xhtml rename : widget/tests/window_bug593307_centerscreen.xul => widget/tests/window_bug593307_centerscreen.xhtml rename : widget/tests/window_bug593307_offscreen.xul => widget/tests/window_bug593307_offscreen.xhtml rename : widget/tests/window_composition_text_querycontent.xul => widget/tests/window_composition_text_querycontent.xhtml rename : widget/tests/window_state_windows.xul => widget/tests/window_state_windows.xhtml rename : widget/tests/window_wheeltransaction.xul => widget/tests/window_wheeltransaction.xhtml extra : moz-landing-system : lando
2019-11-20 22:05:30 +03:00
.open('empty_window.xhtml', '_blank', 'chrome,screenX=50,screenY=50,width=200,height=200');
SimpleTest.waitForFocus(function () {
gRightWindow = window.browsingContext.topChromeWindow
Bug 1596327, rename .xul test files in widget/ to .xhtml r=jmathies Differential Revision: https://phabricator.services.mozilla.com/D53047 --HG-- rename : widget/cocoa/crashtests/444260-1.xul => widget/cocoa/crashtests/444260-1.xhtml rename : widget/tests/bug586713_window.xul => widget/tests/bug586713_window.xhtml rename : widget/tests/chrome_context_menus_win.xul => widget/tests/chrome_context_menus_win.xhtml rename : widget/tests/empty_window.xul => widget/tests/empty_window.xhtml rename : widget/tests/native_menus_window.xul => widget/tests/native_menus_window.xhtml rename : widget/tests/native_mouse_mac_window.xul => widget/tests/native_mouse_mac_window.xhtml rename : widget/tests/standalone_native_menu_window.xul => widget/tests/standalone_native_menu_window.xhtml rename : widget/tests/system_font_changes.xul => widget/tests/system_font_changes.xhtml rename : widget/tests/taskbar_previews.xul => widget/tests/taskbar_previews.xhtml rename : widget/tests/test_bug1123480.xul => widget/tests/test_bug1123480.xhtml rename : widget/tests/test_bug343416.xul => widget/tests/test_bug343416.xhtml rename : widget/tests/test_bug428405.xul => widget/tests/test_bug428405.xhtml rename : widget/tests/test_bug429954.xul => widget/tests/test_bug429954.xhtml rename : widget/tests/test_bug444800.xul => widget/tests/test_bug444800.xhtml rename : widget/tests/test_bug466599.xul => widget/tests/test_bug466599.xhtml rename : widget/tests/test_bug478536.xul => widget/tests/test_bug478536.xhtml rename : widget/tests/test_bug485118.xul => widget/tests/test_bug485118.xhtml rename : widget/tests/test_bug517396.xul => widget/tests/test_bug517396.xhtml rename : widget/tests/test_bug522217.xul => widget/tests/test_bug522217.xhtml rename : widget/tests/test_bug538242.xul => widget/tests/test_bug538242.xhtml rename : widget/tests/test_bug586713.xul => widget/tests/test_bug586713.xhtml rename : widget/tests/test_bug593307.xul => widget/tests/test_bug593307.xhtml rename : widget/tests/test_bug596600.xul => widget/tests/test_bug596600.xhtml rename : widget/tests/test_bug673301.xul => widget/tests/test_bug673301.xhtml rename : widget/tests/test_bug760802.xul => widget/tests/test_bug760802.xhtml rename : widget/tests/test_chrome_context_menus_win.xul => widget/tests/test_chrome_context_menus_win.xhtml rename : widget/tests/test_clipboard.xul => widget/tests/test_clipboard.xhtml rename : widget/tests/test_composition_text_querycontent.xul => widget/tests/test_composition_text_querycontent.xhtml rename : widget/tests/test_input_events_on_deactive_window.xul => widget/tests/test_input_events_on_deactive_window.xhtml rename : widget/tests/test_key_event_counts.xul => widget/tests/test_key_event_counts.xhtml rename : widget/tests/test_keycodes.xul => widget/tests/test_keycodes.xhtml rename : widget/tests/test_mouse_scroll.xul => widget/tests/test_mouse_scroll.xhtml rename : widget/tests/test_native_menus.xul => widget/tests/test_native_menus.xhtml rename : widget/tests/test_native_mouse_mac.xul => widget/tests/test_native_mouse_mac.xhtml rename : widget/tests/test_panel_mouse_coords.xul => widget/tests/test_panel_mouse_coords.xhtml rename : widget/tests/test_platform_colors.xul => widget/tests/test_platform_colors.xhtml rename : widget/tests/test_position_on_resize.xul => widget/tests/test_position_on_resize.xhtml rename : widget/tests/test_sizemode_events.xul => widget/tests/test_sizemode_events.xhtml rename : widget/tests/test_standalone_native_menu.xul => widget/tests/test_standalone_native_menu.xhtml rename : widget/tests/test_system_font_changes.xul => widget/tests/test_system_font_changes.xhtml rename : widget/tests/test_system_status_bar.xul => widget/tests/test_system_status_bar.xhtml rename : widget/tests/test_taskbar_progress.xul => widget/tests/test_taskbar_progress.xhtml rename : widget/tests/test_transferable_overflow.xul => widget/tests/test_transferable_overflow.xhtml rename : widget/tests/test_wheeltransaction.xul => widget/tests/test_wheeltransaction.xhtml rename : widget/tests/window_bug429954.xul => widget/tests/window_bug429954.xhtml rename : widget/tests/window_bug478536.xul => widget/tests/window_bug478536.xhtml rename : widget/tests/window_bug522217.xul => widget/tests/window_bug522217.xhtml rename : widget/tests/window_bug538242.xul => widget/tests/window_bug538242.xhtml rename : widget/tests/window_bug593307_centerscreen.xul => widget/tests/window_bug593307_centerscreen.xhtml rename : widget/tests/window_bug593307_offscreen.xul => widget/tests/window_bug593307_offscreen.xhtml rename : widget/tests/window_composition_text_querycontent.xul => widget/tests/window_composition_text_querycontent.xhtml rename : widget/tests/window_state_windows.xul => widget/tests/window_state_windows.xhtml rename : widget/tests/window_wheeltransaction.xul => widget/tests/window_wheeltransaction.xhtml extra : moz-landing-system : lando
2019-11-20 22:05:30 +03:00
.open('empty_window.xhtml', '', 'chrome,screenX=300,screenY=50,width=200,height=200');
SimpleTest.waitForFocus(attachBrowserToLeftWindow, gRightWindow);
}, gLeftWindow);
}
function attachBrowserToLeftWindow() {
gBrowserElement = gLeftWindow.document.createXULElement("browser");
gBrowserElement.setAttribute("type", "content");
gBrowserElement.setAttribute("src", "file_bug596600.html");
gBrowserElement.style.width = "100px";
gBrowserElement.style.height = "100px";
gBrowserElement.style.margin = "50px";
gLeftWindow.document.documentElement.appendChild(gBrowserElement);
gBrowserElement.addEventListener("load", async () => {
await test1();
await test2();
gRightWindow.close();
gLeftWindow.close();
SimpleTest.finish();
}, { capture: true, once: true });
}
async function test1() {
// gRightWindow is active, gLeftWindow is inactive.
info(`Synthesizing native "mousemove" event at top-left of the screen...`);
await promiseNativeMouseEvent({
type: "mousemove",
screenX: 0,
screenY: 0,
scale: "inScreenPixels",
});
await new Promise(resolve => SimpleTest.executeSoon(resolve));
// Move into the left window
info(`Synthesizing native "mousemove" event in the left window (but outside the content)...`);
await promiseNativeMouseEventAndWaitForEvent({
type: "mousemove",
target: gBrowserElement,
offsetX: -20,
offsetY: -20,
win: gLeftWindow,
scale: "screenPixelsPerCSSPixelNoOverride",
eventTypeToWait: "mouseover",
eventTargetToListen: gLeftWindow,
});
ok(true, `"mouseover" event is fired on the left window when cursor is moved into it`);
// Move over the browser
info(`Synthesizing native "mousemove" event on the content in the left window...`);
await promiseNativeMouseEventAndWaitForEvent({
type: "mousemove",
target: gBrowserElement,
atCenter: true,
win: gLeftWindow,
scale: "screenPixelsPerCSSPixelNoOverride",
eventTypeToWait: "mouseout",
eventTargetToListen: gLeftWindow,
});
ok(true, `"mouseout" event is fired on the left window when cursor is moved into its child browser`);
}
async function test2() {
// Make the browser cover the whole window.
gBrowserElement.style.margin = "0";
gBrowserElement.style.width = gBrowserElement.style.height = "200px";
// Add a box to the browser at the left edge.
var doc = gBrowserElement.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.matches(":hover"), "Box shouldn't be hovered (since the mouse isn't over it and since it's in a non-clickthrough browser in a background window)");
// A function to waitForFocus and then wait for synthetic mouse
// events to happen. Note that those happen off the refresh driver,
// and happen after animation frame requests.
function changeFocusAndAwaitSyntheticMouse(winToFocus,
elementToWatchForMouseEventOn) {
return Promise.all([
new Promise(resolve => {
function mouseWatcher() {
elementToWatchForMouseEventOn.removeEventListener("mouseover",
mouseWatcher);
elementToWatchForMouseEventOn.removeEventListener("mouseout",
mouseWatcher);
SimpleTest.executeSoon(resolve);
}
elementToWatchForMouseEventOn.addEventListener("mouseover",
mouseWatcher);
elementToWatchForMouseEventOn.addEventListener("mouseout",
mouseWatcher);
}),
new Promise(resolve => SimpleTest.waitForFocus(resolve, winToFocus)),
]);
}
// Move the mouse over the box.
info(`Synthesizing native "mousemove" event into the box...`);
await promiseNativeMouseEvent({
type: "mousemove",
target: box,
atCenter: true,
win: gLeftWindow,
scale: "screenPixelsPerCSSPixelNoOverride",
});
await new Promise(resolve =>
requestAnimationFrame(() => SimpleTest.executeSoon(resolve))
);
// XXX We cannot guarantee that the native mousemouse have already handled here.
ok(!box.matches(":hover"), "Box shouldn't be hovered (since it's in a non-clickthrough browser in a background window)");
// Activate the left window.
info("Waiting the left window activated...");
await changeFocusAndAwaitSyntheticMouse(gLeftWindow, box);
ok(gBrowserElement.matches(":hover"), "browser should be hovered");
ok(box.matches(":hover"), "Box should be hovered");
// De-activate the window (by activating the right window).
info("Waiting the right window activated...");
await changeFocusAndAwaitSyntheticMouse(gRightWindow, box);
ok(!gBrowserElement.matches(":hover"), "browser shouldn't be hovered");
ok(!box.matches(":hover"), "Box shouldn't be hovered");
// Re-activate it.
info("Waiting the left window activated again...");
await changeFocusAndAwaitSyntheticMouse(gLeftWindow, box);
ok(gBrowserElement.matches(":hover"), "browser should be hovered");
ok(box.matches(":hover"), "Box should be hovered");
// Unhover the box and the left window.
info(`Synthesizing native "mousemove" event outside the box and the left window...`);
await promiseNativeMouseEventAndWaitForEvent({
type: "mousemove",
screenX: 0,
screenY: 0,
scale: "inScreenPixels",
win: gLeftWindow,
eventTargetToListen: box,
eventTypeToWait: "mouseout",
});
await new Promise(resolve =>
requestAnimationFrame(() => SimpleTest.executeSoon(resolve))
);
ok(!gBrowserElement.matches(":hover"), "browser shouldn't be hovered");
ok(!box.matches(":hover"), "box shouldn't be hovered");
}
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(openWindows);
]]>
</script>
</window>