diff --git a/dom/tests/mochitest/pointerlock/file_pointerlock_xorigin_iframe_not_focused.html b/dom/tests/mochitest/pointerlock/file_pointerlock_xorigin_iframe_not_focused.html index 5e499b1252d2..a6c005865727 100644 --- a/dom/tests/mochitest/pointerlock/file_pointerlock_xorigin_iframe_not_focused.html +++ b/dom/tests/mochitest/pointerlock/file_pointerlock_xorigin_iframe_not_focused.html @@ -66,13 +66,25 @@ async function exitPointerLock(aWin) { }); } -function waitForEvent(aWin, aEvent) { +function addEventListenerOnRemote(aWin, aEvent) { return SpecialPowers.spawn(aWin, [aEvent], async (aEvent) => { - info(`wait for ${aEvent} event`); - return new Promise((aResolve) => { - content.document.addEventListener(aEvent, function(e) { + info(`wait for ${aEvent} event on remote`); + content.document.addEventListener(aEvent, function(e) { + info(`get ${aEvent} event on remote`); + content.parent.postMessage(aEvent, "*"); + }); + }); +} + +function waitForMessage(aWin, aMessage) { + return new Promise((aResolve) => { + info(`wait for ${aMessage} message`); + window.addEventListener("message", function handler(e) { + info(`get ${e.data} message`); + if (e.data === aMessage) { + window.removeEventListener("message", handler); aResolve(); - }, { once: true }); + } }); }); } @@ -84,8 +96,9 @@ async function start() { let iframe = document.querySelector("iframe"); let win = iframe.contentWindow; await requestPointerLock(win); + await addEventListenerOnRemote(win, "mousemove"); - let promise = waitForEvent(win, "mousemove"); + let promise = waitForMessage(win, "mousemove"); let div = document.querySelector("div"); synthesizeMouseAtCenter(div, { type: "mousemove" }); await promise; diff --git a/dom/tests/mochitest/pointerlock/mochitest.ini b/dom/tests/mochitest/pointerlock/mochitest.ini index 3bee6fb58c6b..54106104b297 100644 --- a/dom/tests/mochitest/pointerlock/mochitest.ini +++ b/dom/tests/mochitest/pointerlock/mochitest.ini @@ -31,11 +31,6 @@ support-files = file_changeLockElement.html [test_pointerlock_focus.html] [test_pointerlock_xorigin_iframe.html] -skip-if = - os == "linux" && !(webrender && !debug) # Bug 1698698 - only passes on webrender opt - os == "win" #Bug 1698698 - os == "android" && bits == 64 #Bug 1698698 - os == "mac" && bits == 64 && webrender # Bug 1698698 support-files = file_pointerlock_xorigin_iframe.html file_pointerlock_xorigin_iframe_no_user_gesture.html diff --git a/dom/tests/mochitest/pointerlock/test_pointerlock_xorigin_iframe.html b/dom/tests/mochitest/pointerlock/test_pointerlock_xorigin_iframe.html index 6e413777448c..fb4f84470eab 100644 --- a/dom/tests/mochitest/pointerlock/test_pointerlock_xorigin_iframe.html +++ b/dom/tests/mochitest/pointerlock/test_pointerlock_xorigin_iframe.html @@ -48,6 +48,7 @@ function runNextTest() { info(`Testing ${file}`); gTestWindow = window.open(file, "", "width=500,height=500"); + info(`Test finish`); } else { SimpleTest.finish(); }