Diff
Modified: trunk/LayoutTests/ChangeLog (276998 => 276999)
--- trunk/LayoutTests/ChangeLog 2021-05-05 00:42:15 UTC (rev 276998)
+++ trunk/LayoutTests/ChangeLog 2021-05-05 01:23:14 UTC (rev 276999)
@@ -1,3 +1,16 @@
+2021-05-04 Kenneth Russell <[email protected]>
+
+ WebKit must treat 'webgl' and 'webgl2' as distinct context types
+ https://bugs.webkit.org/show_bug.cgi?id=222758
+
+ Reviewed by Dean Jackson.
+
+ Revised the two copies of the WebGL 2.0 context-type-test with
+ strengthened checks taken from upstream KhronosGroup/WebGL.
+
+ * webgl/2.0.0/resources/webgl_test_files/conformance2/context/context-type-test-2.html:
+ * webgl/resources/webgl_test_files/conformance2/context/context-type-test-2.html:
+
2021-05-04 Truitt Savell <[email protected]>
[Big Sur] platform/mac-bigsur/media/media-source/media-source-webm-vorbis-partial.html is consistently failing
Modified: trunk/LayoutTests/webgl/2.0.0/resources/webgl_test_files/conformance2/context/context-type-test-2.html (276998 => 276999)
--- trunk/LayoutTests/webgl/2.0.0/resources/webgl_test_files/conformance2/context/context-type-test-2.html 2021-05-05 00:42:15 UTC (rev 276998)
+++ trunk/LayoutTests/webgl/2.0.0/resources/webgl_test_files/conformance2/context/context-type-test-2.html 2021-05-05 01:23:14 UTC (rev 276999)
@@ -37,8 +37,8 @@
<body>
<div id="description"></div>
<div id="console"></div>
-<canvas id="canvas" style="width: 50px; height: 50px;"> </canvas>
-<canvas id="canvas2d" width="40" height="40"> </canvas>
+<canvas id="canvas1" style="width: 50px; height: 50px;"> </canvas>
+<canvas id="canvas2" style="width: 50px; height: 50px;"> </canvas>
<script>
"use strict";
description("This test ensures WebGL2 implementations interact correctly with the canvas tag.");
@@ -46,24 +46,53 @@
debug("");
debug("Canvas.getContext");
-assertMsg(window.WebGLRenderingContext,
- "WebGL2RenderingContext should be a member of window");
-assertMsg('WebGL2RenderingContext' in window,
- "WebGL2RenderingContext should be 'in' window");
+function runTest() {
+ assertMsg(window.WebGL2RenderingContext,
+ "WebGL2RenderingContext should be a member of window");
+ assertMsg('WebGL2RenderingContext' in window,
+ "WebGL2RenderingContext should be 'in' window");
-var wtu = WebGLTestUtils;
-var canvas = document.getElementById("canvas");
-var gl = wtu.create3DContext(canvas, null, 2);
-if (!gl) {
- testFailed("context does not exist");
-} else {
- testPassed("context exists");
+ const wtu = WebGLTestUtils;
+ let canvas2 = document.getElementById("canvas2");
+ let gl2 = wtu.create3DContext(canvas2, null, 2);
+ if (!gl2) {
+ testFailed("Could not fetch WebGL 2.0 context");
+ return;
+ }
+ testPassed("Fetched WebGL2 context successfully");
- debug("Checking context type");
- assertMsg(gl instanceof WebGL2RenderingContext,
+ debug("Checking WebGL2 context type");
+ assertMsg(gl2 instanceof WebGL2RenderingContext,
"context type should be WebGL2RenderingContext");
+
+ // WebGL1 contexts do not respond to the WebGL2 context type, and vice versa.
+ let canvas1 = document.getElementById("canvas1");
+ let gl1 = wtu.create3DContext(canvas1, null, 1);
+ if (!gl1) {
+ testFailed("Could not fetch WebGL 1.0 context");
+ return;
+ }
+
+ debug("Checking WebGL1 context type");
+ assertMsg(gl1 instanceof WebGLRenderingContext,
+ "context type should be WebGLRenderingContext");
+
+ let msg1 = "A canvas which has created a WebGL 1.0 context should not return it for a 'webgl2' context request";
+ if (canvas1.getContext("webgl2"))
+ testFailed(msg1);
+ else
+ testPassed(msg1);
+
+ let msg2 = "A canvas which has created a WebGL 2.0 context should not return it for a 'webgl' context request";
+ if (canvas2.getContext("webgl"))
+ testFailed(msg2);
+ else
+ testPassed(msg2);
}
+
+runTest();
debug("");
+
var successfullyParsed = true;
</script>
<script src=""
Modified: trunk/LayoutTests/webgl/resources/webgl_test_files/conformance2/context/context-type-test-2.html (276998 => 276999)
--- trunk/LayoutTests/webgl/resources/webgl_test_files/conformance2/context/context-type-test-2.html 2021-05-05 00:42:15 UTC (rev 276998)
+++ trunk/LayoutTests/webgl/resources/webgl_test_files/conformance2/context/context-type-test-2.html 2021-05-05 01:23:14 UTC (rev 276999)
@@ -16,8 +16,8 @@
<body>
<div id="description"></div>
<div id="console"></div>
-<canvas id="canvas" style="width: 50px; height: 50px;"> </canvas>
-<canvas id="canvas2d" width="40" height="40"> </canvas>
+<canvas id="canvas1" style="width: 50px; height: 50px;"> </canvas>
+<canvas id="canvas2" style="width: 50px; height: 50px;"> </canvas>
<script>
"use strict";
description("This test ensures WebGL2 implementations interact correctly with the canvas tag.");
@@ -25,24 +25,53 @@
debug("");
debug("Canvas.getContext");
-assertMsg(window.WebGLRenderingContext,
- "WebGL2RenderingContext should be a member of window");
-assertMsg('WebGL2RenderingContext' in window,
- "WebGL2RenderingContext should be 'in' window");
+function runTest() {
+ assertMsg(window.WebGL2RenderingContext,
+ "WebGL2RenderingContext should be a member of window");
+ assertMsg('WebGL2RenderingContext' in window,
+ "WebGL2RenderingContext should be 'in' window");
-var wtu = WebGLTestUtils;
-var canvas = document.getElementById("canvas");
-var gl = wtu.create3DContext(canvas, null, 2);
-if (!gl) {
- testFailed("context does not exist");
-} else {
- testPassed("context exists");
+ const wtu = WebGLTestUtils;
+ let canvas2 = document.getElementById("canvas2");
+ let gl2 = wtu.create3DContext(canvas2, null, 2);
+ if (!gl2) {
+ testFailed("Could not fetch WebGL 2.0 context");
+ return;
+ }
+ testPassed("Fetched WebGL2 context successfully");
- debug("Checking context type");
- assertMsg(gl instanceof WebGL2RenderingContext,
+ debug("Checking WebGL2 context type");
+ assertMsg(gl2 instanceof WebGL2RenderingContext,
"context type should be WebGL2RenderingContext");
+
+ // WebGL1 contexts do not respond to the WebGL2 context type, and vice versa.
+ let canvas1 = document.getElementById("canvas1");
+ let gl1 = wtu.create3DContext(canvas1, null, 1);
+ if (!gl1) {
+ testFailed("Could not fetch WebGL 1.0 context");
+ return;
+ }
+
+ debug("Checking WebGL1 context type");
+ assertMsg(gl1 instanceof WebGLRenderingContext,
+ "context type should be WebGLRenderingContext");
+
+ let msg1 = "A canvas which has created a WebGL 1.0 context should not return it for a 'webgl2' context request";
+ if (canvas1.getContext("webgl2"))
+ testFailed(msg1);
+ else
+ testPassed(msg1);
+
+ let msg2 = "A canvas which has created a WebGL 2.0 context should not return it for a 'webgl' context request";
+ if (canvas2.getContext("webgl"))
+ testFailed(msg2);
+ else
+ testPassed(msg2);
}
+
+runTest();
debug("");
+
var successfullyParsed = true;
</script>
<script src=""
Modified: trunk/Source/WebCore/ChangeLog (276998 => 276999)
--- trunk/Source/WebCore/ChangeLog 2021-05-05 00:42:15 UTC (rev 276998)
+++ trunk/Source/WebCore/ChangeLog 2021-05-05 01:23:14 UTC (rev 276999)
@@ -1,3 +1,19 @@
+2021-05-04 Kenneth Russell <[email protected]>
+
+ WebKit must treat 'webgl' and 'webgl2' as distinct context types
+ https://bugs.webkit.org/show_bug.cgi?id=222758
+
+ Reviewed by Dean Jackson.
+
+ Update both the regular getContext and CSS context code paths with
+ checks distinguishing WebGL 1.0 and 2.0 contexts.
+
+ Covered by existing WebGL 2.0 conformance tests.
+
+ * html/HTMLCanvasElement.cpp:
+ (WebCore::HTMLCanvasElement::getContext):
+ (WebCore::HTMLCanvasElement::getContextWebGL):
+
2021-05-04 Jer Noble <[email protected]>
[Media in GPU Process] Move AudioSessionRoutingArbitratorProxy to the GPU process
Modified: trunk/Source/WebCore/html/HTMLCanvasElement.cpp (276998 => 276999)
--- trunk/Source/WebCore/html/HTMLCanvasElement.cpp 2021-05-05 00:42:15 UTC (rev 276998)
+++ trunk/Source/WebCore/html/HTMLCanvasElement.cpp 2021-05-05 01:23:14 UTC (rev 276999)
@@ -259,6 +259,11 @@
if (m_context->isWebGL()) {
if (!isWebGLType(contextId))
return Optional<RenderingContext> { WTF::nullopt };
+ auto version = toWebGLVersion(contextId);
+ if (version == WebGLVersion::WebGL1 && !m_context->isWebGL1())
+ return Optional<RenderingContext> { WTF::nullopt };
+ if (version != WebGLVersion::WebGL1 && m_context->isWebGL1())
+ return Optional<RenderingContext> { WTF::nullopt };
if (is<WebGLRenderingContext>(*m_context))
return Optional<RenderingContext> { RefPtr<WebGLRenderingContext> { &downcast<WebGLRenderingContext>(*m_context) } };
#if ENABLE(WEBGL2)
@@ -481,9 +486,18 @@
if (!shouldEnableWebGL(document().settings()))
return nullptr;
- if (m_context && !m_context->isWebGL())
- return nullptr;
+ if (m_context) {
+ if (!m_context->isWebGL())
+ return nullptr;
+ // The phrasing of these checks avoids compile-time guards for WebGL2 support.
+ if (type == WebGLVersion::WebGL1 && !m_context->isWebGL1())
+ return nullptr;
+
+ if (type != WebGLVersion::WebGL1 && m_context->isWebGL1())
+ return nullptr;
+ }
+
if (!m_context)
return createContextWebGL(type, WTFMove(attrs));
return &downcast<WebGLRenderingContextBase>(*m_context);