test_vrDisplay_exitPresent.html (1991B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>VRDisplay ExitPresent</title> 5 <meta name="timeout" content="long"/> 6 <meta http-equiv="Content-type" content="text/html;charset=UTF-8"> 7 <script src="/resources/testharness.js"></script> 8 <script src="/resources/testharnessreport.js"></script> 9 <script src="VRSimulationDriver.js"></script> 10 <script src="runVRTest.js"></script> 11 </head> 12 <body> 13 <script> 14 function testExitPresentOnOtherIframe(content) { 15 return content.navigator.getVRDisplays().then((displays) => { 16 content.vrDisplay = displays[0]; 17 return content.vrDisplay.exitPresent(); 18 }); 19 } 20 var initVRPresentation = function(content) { 21 return VRSimulationDriver.AttachWebVRDisplay().then(() => { 22 return content.navigator.getVRDisplays().then((displays) => { 23 content.vrDisplay = displays[0]; 24 content.canvas = content.document.createElement("canvas"); 25 content.canvas.id = "vrCanvas"; 26 return content.vrDisplay.requestPresent([{source:content.canvas}]); 27 }); 28 }); 29 } 30 function startTest() { 31 var ifr1 = document.getElementById("iframe1"); 32 var ifr2 = document.getElementById("iframe2"); 33 var frame1 = ifr1.contentWindow; 34 var frame2 = ifr2.contentWindow; 35 promise_test((test) => { 36 return VRSimulationDriver.AttachWebVRDisplay().then(() => { 37 return initVRPresentation(frame1).then(() => { 38 promise_test((test) => { 39 return promise_rejects(test, null, testExitPresentOnOtherIframe(frame2)); 40 }, "We cannot exit VR presentation established by another content, this promise is expected to be rejected.") 41 }); 42 }); 43 }, "Finish running WebVR exitPresent test."); 44 } 45 runVRTest(startTest); 46 </script> 47 48 <iframe id="iframe1"></iframe> 49 <iframe id="iframe2"></iframe> 50 </body> 51 </html>