Web Inspector: Canvas: add support for showing WebGPU contexts
[WebKit-https.git] / LayoutTests / inspector / canvas / resolveCanvasContext-webgpu.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../http/tests/inspector/resources/inspector-test.js"></script>
5 <script>
6 if (window.internals)
7     window.internals.settings.setWebGPUEnabled(true);
8
9 function load() {
10     window.contextWebGPU = document.body.appendChild(document.createElement("canvas")).getContext("gpu");
11
12     runTest();
13 }
14
15 function test()
16 {
17     let suite = InspectorTest.createAsyncSuite("Canvas.resolveCanvasContextWebGPU");
18
19     suite.addTestCase({
20         name: `Canvas.resolveCanvasContextWebGPU.validIdentifier`,
21         description: "Should return a valid object for the given canvas identifier.",
22         test(resolve, reject) {
23             let canvas = WI.canvasManager.canvases.find((canvas) => canvas.contextType === WI.Canvas.ContextType.WebGPU);
24             if (!canvas) {
25                 reject(`Missing Canvas.`);
26                 return;
27             }
28
29             const objectGroup = "test";
30             CanvasAgent.resolveCanvasContext(canvas.identifier, objectGroup)
31             .then(({object}) => {
32                 InspectorTest.expectEqual(object.type, "object", `Payload should have type "object".`);
33                 InspectorTest.expectEqual(object.className, "GPUCanvasContext", `Payload should have className "GPUCanvasContext".`);
34             })
35             .then(resolve, reject);
36         }
37     });
38
39     suite.runTestCasesAndFinish();
40 }
41 </script>
42 </head>
43 <body onload="load()">
44     <p>Tests for the Canvas.resolveCanvasContext command for WebGPU contexts.</p>
45 </body>
46 </html>