-
Notifications
You must be signed in to change notification settings - Fork 900
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
Fix 7956: Disable reporting observers to expose violation reports to JS #4578
Conversation
3916a0c
to
da3874d
Compare
da3874d
to
1621ffc
Compare
@@ -0,0 +1,60 @@ | |||
/* Copyright (c) 2019 The Brave Authors. All rights reserved. |
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.
2020 :)
ui_test_utils::NavigateToURL(browser(), url); | ||
content::WebContents* contents = | ||
browser()->tab_strip_model()->GetActiveWebContents(); | ||
ASSERT_TRUE(content::WaitForLoadStop(contents)); |
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.
you don't need to do this, NavigateToURL
is a blocking call
#include "chrome/test/base/ui_test_utils.h" | ||
#include "content/public/test/browser_test_utils.h" | ||
|
||
const char kReportingObserver[] = "/reporting_observer.html"; |
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 {}
for this var
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.
the whole thing is in an anonymous namespace which seems odd
content::WebContents* contents = | ||
browser()->tab_strip_model()->GetActiveWebContents(); | ||
ASSERT_TRUE(content::WaitForLoadStop(contents)); | ||
EXPECT_EQ(url, contents->GetURL()); |
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.
btw, this check is also not that useful - even if the page is not found, this would be a correct assertion
1621ffc
to
b633bb6
Compare
callback ReportingObserverCallback = void (sequence<Report> reports, ReportingObserver observer); | ||
|
||
[ | ||
- Constructor(ReportingObserverCallback callback, optional ReportingObserverOptions options), |
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'm not sure if this needs to happen here, can't we block this in the network stack?
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.
does this actually make a callback directly in the renderer without going back to the browser process? I think there was browser process code for this?
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.
@bridiver - The network calls are blocked by disabling background sync
. The callback exposes the ViolationReports
to the javascript. Callbacks are handled in the renderer here: https://cs.chromium.org/chromium/src/third_party/blink/renderer/core/frame/reporting_observer.cc?l=38
37abda6
to
88baad1
Compare
browser()->tab_strip_model()->GetActiveWebContents(); | ||
|
||
bool reporting_observer_blocked; | ||
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.
btw, this can be replaced by EvalJs
|
||
private: | ||
std::unique_ptr<ChromeContentClient> content_client_; | ||
std::unique_ptr<BraveContentBrowserClient> browser_content_client_; |
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.
wondering if we really need to instantiate these clients?
a1664a8
to
6f4369a
Compare
callback ReportingObserverCallback = void (sequence<Report> reports, ReportingObserver observer); | ||
|
||
[ | ||
+ ContextEnabled=ReportingObservers, |
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.
for reference what exactly does this do?
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.
@bridiver = With ContextEnabled
we'll be able to use --enable-blink-features=ReportingObservers"
at runtime to enable ReportingObservers
. Default behavior is disabled.
5a89821
to
1480a43
Compare
1480a43
to
a95f17f
Compare
Fix brave/brave-browser#7956
Reporting API is disabled on master because we disable
background sync
by default. But, theReportingViolations
can still be accessed via Reporting Observers. Disabling queuing of reports via reporting observers with this change.Submitter Checklist:
npm run lint
)git rebase master
(if needed).git rebase -i
to squash commits (if needed).Test Plan:
Reporting Observers not available
is echoed to the document.Reviewer Checklist:
After-merge Checklist:
changes has landed on.