mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 08:15:31 +00:00
Bug 1635496 - [remote] Fixed dispatchMouseEvent to not await undefined promises. r=remote-protocol-reviewers,whimboo
The "this" state is not persistent across spawn-calls, using "this" in "function" also does not make a whole lot of sense. In order to persist the Promise across spawn-calls, the value is stored in "content" instead. Since one cannot reliably return an Event from SpecialPowers.spawn (due to serialization issues), we are awaiting them instead of returning. Differential Revision: https://phabricator.services.mozilla.com/D73913
This commit is contained in:
parent
cfa05dc693
commit
da5b77f74b
@ -10,13 +10,13 @@ add_task(async function testDispatchMouseEvent({ client }) {
|
||||
|
||||
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], function() {
|
||||
const div = content.document.querySelector("div");
|
||||
this.mouseDownPromise = new Promise(resolve => {
|
||||
content.mouseDownPromise = new Promise(resolve => {
|
||||
div.addEventListener("mousedown", resolve, { once: true });
|
||||
});
|
||||
this.mouseUpPromise = new Promise(resolve => {
|
||||
content.mouseUpPromise = new Promise(resolve => {
|
||||
div.addEventListener("mouseup", resolve, { once: true });
|
||||
});
|
||||
this.clickPromise = new Promise(resolve => {
|
||||
content.clickPromise = new Promise(resolve => {
|
||||
div.addEventListener("click", resolve, { once: true });
|
||||
});
|
||||
});
|
||||
@ -36,8 +36,8 @@ add_task(async function testDispatchMouseEvent({ client }) {
|
||||
});
|
||||
|
||||
info("Waiting for DOM mousedown event on the div");
|
||||
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], function() {
|
||||
return this.mouseDownPromise;
|
||||
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function() {
|
||||
await content.mouseDownPromise;
|
||||
});
|
||||
|
||||
await Input.dispatchMouseEvent({
|
||||
@ -47,13 +47,13 @@ add_task(async function testDispatchMouseEvent({ client }) {
|
||||
});
|
||||
|
||||
info("Waiting for DOM mouseup event on the div");
|
||||
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], function() {
|
||||
return this.mouseUpPromise;
|
||||
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function() {
|
||||
await content.mouseUpPromise;
|
||||
});
|
||||
|
||||
info("Waiting for DOM click event on the div");
|
||||
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], function() {
|
||||
return this.clickPromise;
|
||||
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function() {
|
||||
await content.clickPromise;
|
||||
});
|
||||
|
||||
ok(true, "All events detected");
|
||||
|
Loading…
Reference in New Issue
Block a user