Skip to content

Commit

Permalink
Fix patch for getAttachedShaders (uplift to 1.68.x) (#24451)
Browse files Browse the repository at this point in the history
Uplift of #24446 (squashed) to beta
  • Loading branch information
brave-builds authored Jul 2, 2024
1 parent 862c426 commit 10969b3
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 3 deletions.
12 changes: 12 additions & 0 deletions browser/farbling/brave_webgl_farbling_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,15 @@ IN_PROC_BROWSER_TEST_F(BraveWebGLFarblingBrowserTest, GetExtension) {
ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), url));
EXPECT_EQ(EvalJs(contents(), kTitleScript).ExtractString(), actual);
}

IN_PROC_BROWSER_TEST_F(BraveWebGLFarblingBrowserTest, GetAttachedShaders) {
std::string domain = "a.com";
GURL url = embedded_test_server()->GetURL(domain, "/getAttachedShaders.html");
// In default fingerprinting mode...
SetFingerprintingDefault(domain);
ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), url));
//... getAttachedShaders() should not be null:
// https://github.com/brave/brave-browser/issues/37044
EXPECT_EQ(EvalJs(contents(), kTitleScript).ExtractString(),
"[object WebGLShader]");
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ index 118c8a892272124c4a74aab5615e6e1fea5f0deb..31472339015963b14a5fbe582dd74d19
std::optional<HeapVector<Member<WebGLShader>>>
WebGLRenderingContextBase::getAttachedShaders(WebGLProgram* program) {
if (!ValidateWebGLProgramOrShader("getAttachedShaders", program))
+ BRAVE_WEBGL_RENDERING_CONTEXT_BASE_NULLOPT
return std::nullopt;
+ BRAVE_WEBGL_RENDERING_CONTEXT_BASE_NULLOPT

HeapVector<Member<WebGLShader>> shader_objects;
@@ -3284,6 +3287,7 @@ GLint WebGLRenderingContextBase::getAttribLocation(WebGLProgram* program,
Expand Down
31 changes: 31 additions & 0 deletions test/data/webgl/getAttachedShaders.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!DOCTYPE html>
<html>
<head>
<title>WebGL getAttachedShaders() test</title>
<meta charset="utf-8">
</head>
<body>
<canvas id="test" width="8" height="8"></canvas>
<script>
const canvas = document.getElementById("test");
const gl = canvas.getContext("webgl");
const vsSource = `
attribute vec4 aVertexPosition;
void main(void) {
gl_Position = aVertexPosition;
}
`;
// Create a vertex shader
const vertexShader = gl.createShader(gl.VERTEX_SHADER);
gl.shaderSource(vertexShader, vsSource);
gl.compileShader(vertexShader);
const shaderProgram = gl.createProgram();
gl.attachShader(shaderProgram, vertexShader);
// Link the shader program
gl.linkProgram(shaderProgram);
// Get the attached shaders
const attachedShaders = gl.getAttachedShaders(shaderProgram);
document.title = attachedShaders;
</script>
</body>
</html>
2 changes: 0 additions & 2 deletions test/data/webgl/getExtension.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,3 @@
</script>
</body>
</html>

}

0 comments on commit 10969b3

Please sign in to comment.