Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Canvases should reset their contents when width or height is set #3613

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion sdk/tests/conformance/canvas/canvas-test.html
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,33 @@
"gl.colorMask should not change after canvas resize");
shouldBe('getViewport()', '"0,0,300,150"');
checkCanvasContentIs(0, 0, 0, 0);
}

debug("");
debug("change the size of the canvas to the same size it already is and see that it gets cleared");
gl.colorMask(true, true, true, true);
gl.clearColor(0.25, 0.5, 0.75, 1);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
// Check it's not cleared
checkCanvasContentIs(64, 128, 192, 255);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to test that stencil and depth are cleared, too. That's of course cumbersome..


gl.canvas.width = gl.canvas.width;
err = gl.getError();
// Some implementations might lost the context when resizing
if (err != gl.CONTEXT_LOST_WEBGL) {
checkCanvasContentIs(0, 0, 0, 0);

gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
// Check it's not cleared
checkCanvasContentIs(64, 128, 192, 255);

gl.canvas.height = gl.canvas.height;
err = gl.getError();
// Some implementations might lost the context when resizing
if (err != gl.CONTEXT_LOST_WEBGL) {
checkCanvasContentIs(0, 0, 0, 0);
}
}
}

debug("");
finishTest();
Expand Down
Loading