| <!DOCTYPE html> |
| <script src="../resources/testharness.js"></script> |
| <script src="../resources/testharnessreport.js"></script> |
| <script src="file:///gen/layout_test_data/mojo/public/js/mojo_bindings.js"></script> |
| <script src="file:///gen/device/vr/public/mojom/vr_service.mojom.js"></script> |
| <script src="../external/wpt/resources/chromium/webxr-test.js"></script> |
| <script src="../xr/resources/xr-test-utils.js"></script> |
| <canvas id="webgl-canvas"></canvas> |
| |
| <script> |
| let testName = "Ensure a WebGL layer's framebuffer size is adjusted " |
| + "appropriately when a large canvas is requested"; |
| |
| let outputContext = getOutputContext(); |
| let outputCanvas = outputContext.canvas; |
| |
| // Make an unreasonably large magic window canvas. |
| outputCanvas.width = 18000; // 16k ought to be a large enough max for anyone. |
| outputCanvas.height = 20000; |
| |
| let outputCanvasRatio = outputCanvas.width / outputCanvas.height; |
| |
| let fakeDeviceInitParams = { supportsImmersive: true }; |
| |
| let requestSessionOptions = [{ }]; |
| |
| let testFunction = (session, t) => new Promise((resolve, reject) => { |
| console.log("Test start"); |
| let webglLayer = new XRWebGLLayer(session, gl); |
| session.updateRenderState({ |
| baseLayer: webglLayer, |
| outputContext: outputContext |
| }); |
| console.log("renderState updated"); |
| |
| // Changes to the baseLayer, and thus the baseLayer's framebuffer size, won't |
| // take effect until the next frame is processed. |
| session.requestAnimationFrame((time, xrFrame) => { |
| console.log("First rAF"); |
| t.step(() => { |
| // The layer's framebuffer should be smaller than the requested size. |
| assert_true(webglLayer.framebufferWidth < outputCanvas.width); |
| assert_true(webglLayer.framebufferHeight < outputCanvas.height); |
| |
| // The layer's dimensions should keep the same ratio as the canvas. |
| let framebufferRatio = webglLayer.framebufferWidth / webglLayer.framebufferHeight; |
| assert_approx_equals(framebufferRatio, outputCanvasRatio, 0.0001); |
| }); |
| |
| // Resize the canvas to something more reasonable. |
| outputCanvas.width = 256; |
| outputCanvas.height = 128; |
| |
| // Give the UA a chance to respond to the resize. |
| session.requestAnimationFrame((time, xrFrame) => { |
| console.log("Second rAF"); |
| // Check to ensure the framebuffer resized to match the new canvas dimensions. |
| t.step(() => { |
| assert_equals(webglLayer.framebufferWidth, outputCanvas.width); |
| assert_equals(webglLayer.framebufferHeight, outputCanvas.height); |
| }); |
| |
| resolve(); |
| }); |
| }); |
| }); |
| |
| xr_session_promise_test( |
| testFunction, fakeDeviceInitParams, requestSessionOptions, testName); |
| |
| </script> |