Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide userAgentData model (uplift to 1.36.x) #12094

Merged
merged 1 commit into from
Feb 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions browser/farbling/brave_navigator_useragent_farbling_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
using brave_shields::ControlType;
using content::TitleWatcher;

namespace {
const char kUserAgentScript[] = "navigator.userAgent";
}

class BraveNavigatorUserAgentFarblingBrowserTest : public InProcessBrowserTest {
public:
Expand Down Expand Up @@ -231,3 +233,13 @@ IN_PROC_BROWSER_TEST_F(BraveNavigatorUserAgentFarblingBrowserTest,
auto off_ua_b2 = EvalJs(contents(), kUserAgentScript);
EXPECT_EQ(off_ua_b.ExtractString(), off_ua_b2);
}

// Tests results of farbling user agent metadata
IN_PROC_BROWSER_TEST_F(BraveNavigatorUserAgentFarblingBrowserTest,
FarbleNavigatorUserAgentModel) {
GURL url_b = https_server()->GetURL("b.com", "/navigator/useragentdata.html");
NavigateToURLUntilLoadStop(url_b);
std::u16string expected_title(u"pass");
TitleWatcher watcher(contents(), expected_title);
EXPECT_EQ(expected_title, watcher.WaitAndGetTitle());
}
8 changes: 8 additions & 0 deletions chromium_src/content/common/user_agent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,17 @@

#include "content/public/common/user_agent.h"

namespace content {
std::string BuildModelInfo() {
return std::string();
}
} // namespace content

#define BRAVE_GET_ANDROID_OS_INFO \
include_android_model = IncludeAndroidModel::Exclude;
#define BuildModelInfo BuildModelInfo_ChromiumImpl

#include "src/content/common/user_agent.cc"

#undef BuildModelInfo_ChromiumImpl
#undef BRAVE_GET_ANDROID_OS_INFO
18 changes: 18 additions & 0 deletions test/data/navigator/useragentdata.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<!-- navigator.userAgentData test -->
<html>
<head>
<title>fail</title>
<meta charset="utf-8">
</head>
<body>
<script>
navigator.userAgentData.getHighEntropyValues(
["model"]).then(ua => {
if (ua.model == "") {
document.title = "pass";
}
});
</script>
</body>
</html>