blob: dc00ef1237a67b8905f380dcecf6a79ceb632676 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
<script>
if (window.internals)
window.internals.settings.setWebGPUEnabled(true);
function createDevice() {
navigator.gpu.requestAdapter().then(function adapterRequested(adapter) {
adapter.requestDevice().then(function deviceRequested(device) {
window.contextWebGPU = device;
});
});
}
function test()
{
let suite = InspectorTest.createAsyncSuite("Canvas.resolveContextWebGPU");
suite.addTestCase({
name: `Canvas.resolveContextWebGPU.validIdentifier`,
description: "Should return a valid object for the given canvas identifier.",
async test() {
InspectorTest.assert(!WI.canvasManager.canvases.length, "There should be no canvases.");
let [canvasAddedEvent] = await Promise.all([
WI.canvasManager.awaitEvent(WI.CanvasManager.Event.CanvasAdded),
InspectorTest.evaluateInPage(`createDevice()`),
]);
let {canvas} = canvasAddedEvent.data;
InspectorTest.assert(canvas.contextType, WI.Canvas.ContextType.WebGPU, "Added canvas should be a WebGPU device.");
const objectGroup = "test";
let {object} = await CanvasAgent.resolveContext(canvas.identifier, objectGroup)
InspectorTest.expectEqual(object.type, "object", `Payload should have type "object".`);
InspectorTest.expectEqual(object.className, "GPUDevice", `Payload should have className "GPUDevice".`);
}
});
suite.runTestCasesAndFinish();
}
</script>
</head>
<body onload="runTest()">
<p>Tests for the Canvas.resolveContext command for WebGPU devices.</p>
</body>
</html>