After bug 1691346, LayoutUtils is a thin wrapper over a few methods on windowUtils. I think we can get rid of it and just call these methods directly now. Differential Revision: https://phabricator.services.mozilla.com/D288661
54 lines
1.5 KiB
JavaScript
54 lines
1.5 KiB
JavaScript
/* Any copyright is dedicated to the Public Domain.
|
|
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
add_task(async function () {
|
|
await SpecialPowers.pushPrefEnv({
|
|
set: [["test.wait300msAfterTabSwitch", true]],
|
|
});
|
|
});
|
|
|
|
add_task(async function test_toTopLevelWidgetRect() {
|
|
const tab = await BrowserTestUtils.openNewForegroundTab(
|
|
gBrowser,
|
|
"data:text/html;charset=utf-8,test"
|
|
);
|
|
|
|
// Convert (12, 34) in a content document coordinates into this browser window
|
|
// coordinates.
|
|
const positionInBrowser = await SpecialPowers.spawn(
|
|
tab.linkedBrowser,
|
|
[],
|
|
() => {
|
|
return content.window.windowUtils.toTopLevelWidgetRect(12, 34, 0, 0);
|
|
}
|
|
);
|
|
|
|
// Dispatch a mousedown event on the browser window coordinates position to
|
|
// see whether it's fired on the correct position in the content document.
|
|
const mouseDownPromise = BrowserTestUtils.waitForContentEvent(
|
|
tab.linkedBrowser,
|
|
"mousedown",
|
|
false,
|
|
event => {
|
|
dump(`mousedown on (${event.clientX}, ${event.clientY})`);
|
|
return event.clientX == 12 && event.clientY == 34;
|
|
}
|
|
);
|
|
|
|
// A workaround for bug 1743857.
|
|
await SpecialPowers.spawn(tab.linkedBrowser, [], async () => {
|
|
await Promise.resolve();
|
|
});
|
|
|
|
EventUtils.synthesizeMouseAtPoint(
|
|
positionInBrowser.x / window.devicePixelRatio,
|
|
positionInBrowser.y / window.devicePixelRatio,
|
|
{ type: "mousedown", button: 1 }
|
|
);
|
|
await mouseDownPromise;
|
|
|
|
Assert.ok(true, "windowUtils.toTopLevelWidgetRect() works as expected");
|
|
|
|
BrowserTestUtils.removeTab(tab);
|
|
});
|