WebGL_compatibility: disallow client-side arrays
BUG=angleproject:1523
Change-Id: Icd207b2d94c1375c6f3189af42d55eac52b99603
Reviewed-on: https://chromium-review.googlesource.com/418398
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/tests/gl_tests/WebGLCompatibilityTest.cpp b/src/tests/gl_tests/WebGLCompatibilityTest.cpp
index ebc0efc..8464111 100644
--- a/src/tests/gl_tests/WebGLCompatibilityTest.cpp
+++ b/src/tests/gl_tests/WebGLCompatibilityTest.cpp
@@ -140,6 +140,78 @@
glDeleteProgram(program);
}
+// Test that client-side array buffers are forbidden in WebGL mode
+TEST_P(WebGLCompatibilityTest, ForbidsClientSideArrayBuffer)
+{
+ const std::string &vert =
+ "attribute vec3 a_pos;\n"
+ "void main()\n"
+ "{\n"
+ " gl_Position = vec4(a_pos, 1.0);\n"
+ "}\n";
+
+ const std::string &frag =
+ "precision highp float;\n"
+ "void main()\n"
+ "{\n"
+ " gl_FragColor = vec4(1.0);\n"
+ "}\n";
+
+ ANGLE_GL_PROGRAM(program, vert, frag);
+
+ GLint posLocation = glGetAttribLocation(program.get(), "a_pos");
+ ASSERT_NE(-1, posLocation);
+ glUseProgram(program.get());
+
+ const auto &vertices = GetQuadVertices();
+ glVertexAttribPointer(posLocation, 3, GL_FLOAT, GL_FALSE, 0, vertices.data());
+ glEnableVertexAttribArray(posLocation);
+
+ ASSERT_GL_NO_ERROR();
+ glDrawArrays(GL_TRIANGLES, 0, 6);
+ EXPECT_GL_ERROR(GL_INVALID_OPERATION);
+}
+
+// Test that client-side element array buffers are forbidden in WebGL mode
+TEST_P(WebGLCompatibilityTest, ForbidsClientSideElementBuffer)
+{
+ const std::string &vert =
+ "attribute vec3 a_pos;\n"
+ "void main()\n"
+ "{\n"
+ " gl_Position = vec4(a_pos, 1.0);\n"
+ "}\n";
+
+ const std::string &frag =
+ "precision highp float;\n"
+ "void main()\n"
+ "{\n"
+ " gl_FragColor = vec4(1.0);\n"
+ "}\n";
+
+ ANGLE_GL_PROGRAM(program, vert, frag);
+
+ GLint posLocation = glGetAttribLocation(program.get(), "a_pos");
+ ASSERT_NE(-1, posLocation);
+ glUseProgram(program.get());
+
+ const auto &vertices = GetQuadVertices();
+
+ GLBuffer vertexBuffer;
+ glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer.get());
+ glBufferData(GL_ARRAY_BUFFER, sizeof(vertices[0]) * vertices.size(), vertices.data(),
+ GL_STATIC_DRAW);
+
+ glVertexAttribPointer(posLocation, 3, GL_FLOAT, GL_FALSE, 0, 0);
+ glEnableVertexAttribArray(posLocation);
+
+ const GLubyte indices[] = {0, 1, 2, 3, 4, 5};
+
+ ASSERT_GL_NO_ERROR();
+ glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, indices);
+ EXPECT_GL_ERROR(GL_INVALID_OPERATION);
+}
+
// Use this to select which configurations (e.g. which renderer, which GLES major version) these
// tests should be run against.
ANGLE_INSTANTIATE_TEST(WebGLCompatibilityTest,