-
Notifications
You must be signed in to change notification settings - Fork 916
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
Disable navigator.keyboard API when fingerprinting protection is on. #10935
Conversation
f4623ae
to
c56a710
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
++
Yeah I don't have any experience conditionally removing an IDL-defined API at runtime. I'm sure it's technically feasible, but this is probably sufficient. If we get webcompat reports, we can revisit. |
#include "chrome/test/base/in_process_browser_test.h" | ||
#include "chrome/test/base/ui_test_utils.h" | ||
#include "components/network_session_configurator/common/network_switches.h" | ||
#include "components/permissions/permission_request.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unused? Pls check for unused includes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed in 0dfc2a8
|
||
using brave_shields::ControlType; | ||
|
||
const char kGetLayoutMapScript[] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could be constexpr and also raw string literarls are handier
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed in 0dfc2a8. Also changed the script itself as it was failing on Windows CI with
15:11:59 ../../brave/browser/farbling/brave_navigator_keyboard_api_browsertest.cc(116): error: Expected equality of these values: 15:11:59 15:11:59 "a" 15:11:59 15:11:59 Which is: 00007FF7741DC7BD 15:11:59 15:11:59 EvalJs(contents(), kGetLayoutMapScript) 15:11:59 15:11:59 Which is: null
Assuming, because there's no physical keyboard?
void SetUpCommandLine(base::CommandLine* command_line) override { | ||
// HTTPS server only serves a valid cert for localhost, so this is needed | ||
// to load pages from other hosts without an error | ||
command_line->AppendSwitch(switches::kIgnoreCertificateErrors); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better avoid this (as per annoucement on slack)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 0dfc2a8
Fixes brave/brave-browser#3964 Have not found a convenient way to return navigator.keyboard as undefined yet, so for now making it a null. Since this API is not supported by all browsers making an assumption that web developers would check the API availability before using it in the form of `if (navigator.keyboard)...`, in which case a null should work just as well.
c56a710
to
0dfc2a8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
++ with few nits
#include "chrome/common/chrome_content_client.h" | ||
#include "chrome/test/base/in_process_browser_test.h" | ||
#include "chrome/test/base/ui_test_utils.h" | ||
#include "components/network_session_configurator/common/network_switches.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not used anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doh! Removed in 2653b6b
|
||
using brave_shields::ControlType; | ||
|
||
constexpr char kGetLayoutMapScript[] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
namespace {
} // namespace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in 2653b6b
…ting protection is on.
0dfc2a8
to
2653b6b
Compare
Fixes brave/brave-browser#3964
Have not found a convenient way to return navigator.keyboard as
undefined
yet, so for now making it a null.Since this API is not supported by all browsers making an assumption
that web developers would check the API availability before using it
in the form of
if (navigator.keyboard)...
, in which case a nullshould work just as well.
Maybe @pilgrim-brave or @bridiver have a better idea on making it
undefined
.Submitter Checklist:
QA/Yes
orQA/No
;release-notes/include
orrelease-notes/exclude
;OS/...
) to the associated issuenpm run test -- brave_browser_tests
,npm run test -- brave_unit_tests
,npm run lint
,npm run gn_check
,npm run tslint
git rebase master
(if needed)Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on
Test Plan: