From 10969b352ee9c85ef16229acda77767e18c864a3 Mon Sep 17 00:00:00 2001 From: brave-builds <45370463+brave-builds@users.noreply.github.com> Date: Tue, 2 Jul 2024 23:47:34 +0200 Subject: [PATCH] Fix patch for getAttachedShaders (uplift to 1.68.x) (#24451) Uplift of #24446 (squashed) to beta --- .../brave_webgl_farbling_browsertest.cc | 12 +++++++ ...ebgl-webgl_rendering_context_base.cc.patch | 2 +- test/data/webgl/getAttachedShaders.html | 31 +++++++++++++++++++ test/data/webgl/getExtension.html | 2 -- 4 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 test/data/webgl/getAttachedShaders.html diff --git a/browser/farbling/brave_webgl_farbling_browsertest.cc b/browser/farbling/brave_webgl_farbling_browsertest.cc index 74375e1fee81..0253a58b3214 100644 --- a/browser/farbling/brave_webgl_farbling_browsertest.cc +++ b/browser/farbling/brave_webgl_farbling_browsertest.cc @@ -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]"); +} diff --git a/patches/third_party-blink-renderer-modules-webgl-webgl_rendering_context_base.cc.patch b/patches/third_party-blink-renderer-modules-webgl-webgl_rendering_context_base.cc.patch index 5fa1c3a82614..be6f26b1d672 100644 --- a/patches/third_party-blink-renderer-modules-webgl-webgl_rendering_context_base.cc.patch +++ b/patches/third_party-blink-renderer-modules-webgl-webgl_rendering_context_base.cc.patch @@ -22,8 +22,8 @@ index 118c8a892272124c4a74aab5615e6e1fea5f0deb..31472339015963b14a5fbe582dd74d19 std::optional>> WebGLRenderingContextBase::getAttachedShaders(WebGLProgram* program) { if (!ValidateWebGLProgramOrShader("getAttachedShaders", program)) -+ BRAVE_WEBGL_RENDERING_CONTEXT_BASE_NULLOPT return std::nullopt; ++ BRAVE_WEBGL_RENDERING_CONTEXT_BASE_NULLOPT HeapVector> shader_objects; @@ -3284,6 +3287,7 @@ GLint WebGLRenderingContextBase::getAttribLocation(WebGLProgram* program, diff --git a/test/data/webgl/getAttachedShaders.html b/test/data/webgl/getAttachedShaders.html new file mode 100644 index 000000000000..2f4122c3f803 --- /dev/null +++ b/test/data/webgl/getAttachedShaders.html @@ -0,0 +1,31 @@ + + + + WebGL getAttachedShaders() test + + + + + + + diff --git a/test/data/webgl/getExtension.html b/test/data/webgl/getExtension.html index 67bb76b9740e..3f8019f4e9f8 100644 --- a/test/data/webgl/getExtension.html +++ b/test/data/webgl/getExtension.html @@ -17,5 +17,3 @@ - - }