staleViewsTests.js (1166B)
1 'use strict'; 2 3 const staleViewsTestFunction = function(session, controller, t, sessionObjects) { 4 const isCpuOptimized = session.depthUsage === 'cpu-optimized'; 5 let done = false; 6 7 const staleViews = new Set(); 8 9 return session.requestReferenceSpace('viewer').then((viewerSpace) => { 10 const glBinding = new XRWebGLBinding(session, sessionObjects.gl); 11 12 const secondRafCb = function(time, frame) { 13 for(const view of staleViews) { 14 t.step(() => { 15 assert_throws_dom("InvalidStateError", 16 () => isCpuOptimized ? frame.getDepthInformation(view) 17 : glBinding.getDepthInformation(view), 18 "getDepthInformation() should throw when run with stale XRView"); 19 }); 20 } 21 22 done = true; 23 }; 24 25 const firstRafCb = function(time, frame) { 26 const pose = frame.getViewerPose(viewerSpace); 27 for(const view of pose.views) { 28 staleViews.add(view); 29 } 30 31 session.requestAnimationFrame(secondRafCb); 32 }; 33 34 session.requestAnimationFrame(firstRafCb); 35 36 return t.step_wait(() => done); 37 }); 38 };