test_vrDisplay_onvrdisplaydeactivate_crosscontent.html (1943B)
1 <html> 2 <head> 3 <title>VRDisplay onvrdisplaydeactivate Crosscontent test</title> 4 <meta name="timeout" content="long"/> 5 <meta http-equiv="Content-type" content="text/html;charset=UTF-8"> 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 <script src="VRSimulationDriver.js"></script> 9 <script src="WebVRHelpers.js"></script> 10 <script src="requestPresent.js"></script> 11 <script src="runVRTest.js"></script> 12 </head> 13 <body> 14 <canvas id="vrCanvas"></canvas> 15 <script> 16 17 function startTest() { 18 var canvas = document.getElementById("vrCanvas"); 19 var iframe1 = document.getElementById("iframe1").contentWindow; 20 var t = async_test("vrdisplaydeactivate crosscontent test"); 21 22 window.addEventListener("vrdisplaydeactivate", () => { 23 t.step(() => { 24 assert_true(vrDisplay.isPresenting, 25 "VRDisplay should be still presenting now without being affected by the event."); 26 t.done(); 27 }); 28 }); 29 30 iframe1.addEventListener("vrdisplaydeactivate", () => { 31 t.unreached_func("vrdisplaydeactivate should not be received by other iframe."); 32 }); 33 34 promise_test((test) => { 35 return attachVRDisplay(test).then(() => { 36 return promise_test((test) => { 37 return setupVRDisplay(test).then(() => { 38 VRSimulationDriver.SetMountState(true); 39 VRSimulationDriver.UpdateVRDisplay(); 40 return WebVRHelpers.RequestPresentOnVRDisplay(vrDisplay, [{source: canvas}]); 41 }).then(() => { 42 VRSimulationDriver.SetMountState(false); 43 VRSimulationDriver.UpdateVRDisplay(); 44 }); 45 }); 46 }); 47 }); 48 } 49 50 runVRTest(startTest); 51 </script> 52 <iframe id="iframe1"></iframe> 53 </body> 54 </html>