blob: 6b03d5ec7e59d026687c6b7f0db2806e163aeccf [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
<script>
if (window.internals)
window.internals.settings.setWebGL2Enabled(true);
function load() {
window.contextWebGL2 = document.createElement("canvas").getContext("webgl2");
window.contextWebGL2.clearColor(0, 0, 1, 0.5); // Half-transparent blue
window.contextWebGL2.clear(window.contextWebGL2.COLOR_BUFFER_BIT);
runTest();
}
function test() {
let suite = InspectorTest.createAsyncSuite("Canvas.requestContentWebGL2");
suite.addTestCase({
name: "Canvas.requestContentWebGL2.validCanvasId",
description: "Get the base64 encoded data for the WebGL2 canvas on the page.",
test(resolve, reject) {
let canvas = WI.canvasManager.canvases.find((canvas) => canvas.contextType === WI.Canvas.ContextType.WebGL2);
if (!canvas) {
reject(`Missing Canvas.`);
return;
}
CanvasAgent.requestContent(canvas.identifier)
.then(({content}) => InspectorTest.expectGreaterThan(content.length, "data:image/png;base64,".length, "Content should not be empty."))
.then(resolve, reject);
}
});
suite.runTestCasesAndFinish();
}
</script>
</head>
<body onload="load()">
<p>Test that CanvasAgent.requestContent can retrieve a dataURL with the current content of the WebGL2 canvas.</p>
</body>
</html>