Add a PlatformBrowserTest to verify the DynamicsCompressor fingerprint.
This gives us coverage on Android (32-bit and 64-bit builds, on multiple
OS versions and devices, including Nexus 5, Nexus 5X, Pixel 1 and Pixel
2) Windows 10, and Linux. For some reason, this test doesn't seem to run
on Mac on trybots, but perhaps it does on waterfall?
This test uses an original fingerprinting script. To validate the
effectiveness of this script, I ran this change without the
anti-fingerprinting mitigations in a trybot run on crrev.com/c/2653828
-- each OS / device yielded a different fingerprint in that un-mitigated
run:
Nexus 5 32 bit build: 13.130921687808495
Nexus 5X 64 bit build: 13.130464374060011
Ubuntu Linux 16.04: 13.130925446395167
Win 10: 13.13092414679113
Pixel 1 64 bit build: 13.130463080802201
Bug: 1145192
Change-Id: I1c1cbc6bd615f300e080ca476af0f47f613f1730
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2579484
Commit-Queue: Caleb Raitto <[email protected]>
Reviewed-by: Raymond Toy <[email protected]>
Reviewed-by: Yaron Friedman <[email protected]>
Cr-Commit-Position: refs/heads/master@{#849293}
diff --git a/chrome/browser/webaudio/webaudio_browsertest.cc b/chrome/browser/webaudio/webaudio_browsertest.cc
new file mode 100644
index 0000000..8eb835c
--- /dev/null
+++ b/chrome/browser/webaudio/webaudio_browsertest.cc
@@ -0,0 +1,55 @@
+// Copyright 2021 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "build/build_config.h"
+#include "chrome/test/base/chrome_test_utils.h"
+#include "content/public/test/browser_test.h"
+#include "content/public/test/browser_test_utils.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+#if defined(OS_ANDROID)
+#include "chrome/test/base/android/android_browser_test.h"
+#else
+#include "chrome/test/base/in_process_browser_test.h"
+#endif
+
+namespace {
+
+// This test runs on Android as well as desktop platforms.
+class WebAudioBrowserTest : public PlatformBrowserTest {
+ public:
+ content::WebContents* web_contents() {
+ return chrome_test_utils::GetActiveWebContents(this);
+ }
+};
+
+IN_PROC_BROWSER_TEST_F(WebAudioBrowserTest,
+ VerifyDynamicsCompressorFingerprint) {
+ ASSERT_TRUE(embedded_test_server()->Start());
+ content::DOMMessageQueue messages;
+ base::RunLoop run_loop;
+
+ ASSERT_TRUE(content::NavigateToURL(
+ web_contents(),
+ embedded_test_server()->GetURL(
+ "/webaudio/calls_dynamics_compressor_fingerprint.html")));
+
+ // The document computes the DynamicsCompressor fingerprint and sends a
+ // message back to the test. Receipt of the message indicates that the script
+ // successfully completed.
+ std::string fingerprint;
+ ASSERT_TRUE(messages.WaitForMessage(&fingerprint));
+
+ // NOTE: Changes to Web Audio code that alter the below fingerprints are
+ // fine, and are cause for updating these expectations -- the issue is if
+ // different devices return different fingerprints.
+#if defined(OS_ANDROID) && defined(ARCH_CPU_ARM64)
+ // TODO(crbug.com/1156752): Investigate why this fingerprint is different.
+ EXPECT_EQ("13.13046550525678", fingerprint);
+#else
+ EXPECT_EQ("13.130926895706125", fingerprint);
+#endif // defined(OS_ANDROID) && defined(ARCH_CPU_ARM64)
+}
+
+} // namespace