-
Notifications
You must be signed in to change notification settings - Fork 865
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
Bypass private browsing mode detection #6622
Conversation
Windows CI |
fc610a4
to
04db2c2
Compare
04db2c2
to
e4bbb7d
Compare
e4bbb7d
to
6a7cb63
Compare
StorageEstimate* estimate = StorageEstimate::Create(); | ||
estimate->setUsage(usage_in_bytes); | ||
- estimate->setQuota(quota_in_bytes); | ||
+ estimate->setQuota(2147483648); |
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 sure if this would work, but maybe we can use chromium_src override that will redefine StorageEstimate as BraveStorageEstimate, where BraveStorageEstimate would subclass StorageEstimate and hide base's setQuota method with one that just sets the 2GB value?
So the override would look something like:
#include "third_party/blink/renderer/modules/quota/storage_estimate.h" #include "third_party/blink/renderer/bindings/modules/v8/v8_storage_estimate.h" namespace blink { class BraveStorageEstimate : public StorageEstimage { public: ... void setQuota(uint64_t quota) { quota = 2147483648; StorageEstimage::setQuota(quota); } }; } // namespace blink #define StorageEstimage BraveStorageEstimate #include "..../storage_manager.cc" #undef StorageEstimage
Or something like that...
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.
@mkarolin I just tried the below override at chromium_src/third_party/blink/renderer/modules/quota/storage_manager.cc
- it doesn't appear to be working though, I'm not getting 2GB anymore.
#include "third_party/blink/renderer/modules/quota/storage_estimate.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_storage_estimate.h"
namespace blink {
class BraveStorageEstimate : public StorageEstimate {
public:
static BraveStorageEstimate* Create() {
return MakeGarbageCollected<BraveStorageEstimate>();
}
void setQuota(uint64_t quota) {
quota = 2147483648;
StorageEstimate::setQuota(quota);
}
};
} // namespace blink
#define StorageEstimate BraveStorageEstimate
#include "../../../../../../../third_party/blink/renderer/modules/quota/storage_manager.cc"
#undef StorageEstimate
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.
It would also need
static BraveStorageEstimate* Create() { return MakeGarbageCollected<BraveStorageEstimate>(); }
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 that, didn't appear to make any difference
edit: StorageEstimage
should be StorageEstimate
😄
52b2fcb
to
606690c
Compare
606690c
to
21ab4ee
Compare
EXPECT_EQ(url, contents->GetURL()); | ||
|
||
bool getStorageEstimateIs2Gb; | ||
ASSERT_TRUE(ExecuteScriptAndExtractBool( |
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.
Nit: ExecuteScriptAndExtract* functions are semi-deprecated. EvalJS is preferred.
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.
- updated to use
EvalJs
test/BUILD.gn
Outdated
@@ -644,6 +644,7 @@ if (!is_android) { | |||
"//brave/chromium_src/third_party/blink/renderer/core/frame/reporting_observer_browsertest.cc", | |||
"//brave/chromium_src/third_party/blink/renderer/modules/battery/navigator_batterytest.cc", | |||
"//brave/chromium_src/third_party/blink/renderer/modules/bluetooth/navigator_bluetoothtest.cc", | |||
"//brave/chromium_src/third_party/blink/renderer/modules/quota/navigator_storagetest.cc", |
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.
We no longer want to add tests directly to //brave/test/BUILD.gn. They are supposed to go into BUILD.gn where the test lives and then added as a dep here. (A recent example is #6964).
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.
- moved into
//chromium_src/third_party/blink/renderer/modules/BUILD.gn
21ab4ee
to
f276a00
Compare
content_client_.reset(new ChromeContentClient); | ||
content::SetContentClient(content_client_.get()); | ||
browser_content_client_.reset(new BraveContentBrowserClient()); | ||
content::SetBrowserClientForTesting(browser_content_client_.get()); | ||
content::SetupCrossSiteRedirector(embedded_test_server()); |
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.
I am not sure if any of this is needed in all of these 3 navigator_* tests. And if not, then you won't need the dependency on //brave/browser. They seem to pass with all this removed. cc: @jumde
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.
Makes sense! Works for me as well, I updated all 3
6105dd1
to
9c02c4f
Compare
9c02c4f
to
a8c55e1
Compare
a8c55e1
to
920000b
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.
LGTM
CI failures on Windows and MacOS are known and unrelated to this change: Windows
MacOS
|
defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ] | ||
|
||
sources = [ | ||
"quota/navigator_storagetest.cc", |
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.
browser tests should be test_name_browsertest.cc - please create a follow-up to fix
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.
also this is a layering violation, you cannot have browser tests inside blink. These tests could be moved into brave, but ideally they should be converted to blink::PageTestBase
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.
Just moved them there at @mkarolin's suggestion for #6622 (comment)
Resolves brave/brave-browser#11543
Resolves brave/brave-browser#12370
Just hard-codes the response to the
navigator.storage.estimate()
API to have aquota
value of2147483648
, which is the same as what Firefox uses. See brave/brave-browser#12370 (comment) for justification.Submitter Checklist:
npm run lint
)git rebase master
(if needed).git rebase -i
to squash commits (if needed).Test Plan:
Open any webpage, open the Developer tools (Hamburger menu -> More tools -> Developer tools), select the "Console" tab, and enter the following code at the prompt:
The returned number should be
2147483648
, which corresponds to 2GB.Verify that the behavior is the same in a private window as well.
Reviewer Checklist:
After-merge Checklist:
changes has landed on.