helper_mousemove_optimization.html (3207B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <meta name="viewport" content="width=device-width,initial-scale=1"> 6 <title>Test to make sure mousemove events across document/process boundaries work</title> 7 <script src="/tests/SimpleTest/paint_listener.js"></script> 8 <script src="apz_test_utils.js"></script> 9 <script src="apz_test_native_event_utils.js"></script> 10 </head> 11 <style> 12 body { 13 margin: 0; 14 } 15 iframe { 16 width: 100vw; 17 height: 100px; 18 border: none; 19 } 20 </style> 21 <body> 22 <div style="height: 100px;"></div> 23 <iframe></iframe> 24 <script> 25 26 // This test runs twice, with a same origin iframe first then with a cross 27 // origin iframe second. 28 async function test(targetOrigin) { 29 const iframe = document.querySelector("iframe"); 30 const targetURL = 31 SimpleTest.getTestFileURL("helper_empty.html") 32 .replace(window.location.origin, targetOrigin); 33 const iframeLoadPromise = promiseOneEvent(iframe, "load"); 34 iframe.src = targetURL; 35 await iframeLoadPromise; 36 37 await SpecialPowers.spawn(iframe, [], async () => { 38 await SpecialPowers.contentTransformsReceived(content); 39 }); 40 await promiseApzFlushedRepaints(); 41 42 const mousemoveEventPromise = new Promise(resolve => { 43 window.addEventListener("mousemove", event => { 44 resolve({ 45 type: event.type, 46 clientX: event.clientX, 47 clientY: event.clientY 48 }); 49 }, { once: true }); 50 }); 51 52 // Send a mousemove event on this document. 53 await synthesizeNativeMouseEventWithAPZ({ 54 type: "mousemove", 55 target: document.documentElement, 56 offsetX: 100, 57 offsetY: 50, 58 }); 59 let result = await mousemoveEventPromise; 60 SimpleTest.isDeeply(result, { type: "mousemove", clientX: 100, clientY: 50 }); 61 62 const mousemoveEventPromiseOnIframe = SpecialPowers.spawn(iframe, [], () => { 63 return new Promise(resolve => { 64 content.window.addEventListener("mousemove", event => { 65 resolve({ 66 type: event.type, 67 clientX: event.clientX, 68 clientY: event.clientY 69 }); 70 }, { once: true }); 71 }); 72 }); 73 74 // Await a new SpecialPowers.spawn to flush the above queued task to the content process. 75 await SpecialPowers.spawn(iframe, [], async () => { 76 await new Promise(resolve => resolve()); 77 }); 78 79 // Send a mousemove event on the iframe document. 80 await synthesizeNativeMouseEventWithAPZ({ 81 type: "mousemove", 82 target: iframe, 83 offsetX: 100, 84 offsetY: 50, 85 }); 86 result = await mousemoveEventPromiseOnIframe; 87 SimpleTest.isDeeply(result, { type: "mousemove", clientX: 100, clientY: 50 }); 88 } 89 90 window.onload = async () => { 91 const windowProtocol = await getWindowProtocol(); 92 if (getPlatform() == "linux" && windowProtocol == "wayland") { 93 // Even on wayland this test works with --headless, but unfortunately 94 // SpecialPowers.isHeadless is broken on Linux (bug 1889039). 95 ok(true, "Skipping test because this test isn't supposed to work on wayland because of bug 1857059"); 96 subtestDone(); 97 } else { 98 waitUntilApzStable() 99 .then(async () => test(window.location.origin)) 100 .then(async () => test(`${location.protocol}://example.com/`)) 101 .then(subtestDone, subtestFailed); 102 } 103 }; 104 105 </script> 106 </body> 107 </html>