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

Fix 7956: Disable reporting observers to expose violation reports to JS #4578

Merged
merged 1 commit into from
Mar 3, 2020

Conversation

jumde
Copy link
Contributor

@jumde jumde commented Feb 10, 2020

Fix brave/brave-browser#7956

Reporting API is disabled on master because we disable background sync by default. But, the ReportingViolations can still be accessed via Reporting Observers. Disabling queuing of reports via reporting observers with this change.

Submitter Checklist:

Test Plan:

  1. Navigate to https://jumde.github.io/test/reporting_observer.html
  2. Verify Reporting Observers not available is echoed to the document.

Reviewer Checklist:

  • New files have MPL-2.0 license header.
  • Request a security/privacy review as needed.
  • Adequate test coverage exists to prevent regressions
  • Verify test plan is specified in PR before merging to source

After-merge Checklist:

  • The associated issue milestone is set to the smallest version that the
    changes has landed on.
  • All relevant documentation has been updated.

@jumde jumde requested a review from bridiver as a code owner February 10, 2020 19:47
@jumde jumde self-assigned this Feb 10, 2020
@jumde jumde requested a review from iefremov February 10, 2020 22:47
@jumde jumde force-pushed the disable_reporting_observers branch 4 times, most recently from 3916a0c to da3874d Compare February 12, 2020 00:23
@jumde jumde force-pushed the disable_reporting_observers branch from da3874d to 1621ffc Compare February 12, 2020 00:46
@@ -0,0 +1,60 @@
/* Copyright (c) 2019 The Brave Authors. All rights reserved.
Copy link
Contributor

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));
Copy link
Contributor

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";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

namespace {} for this var

Copy link
Collaborator

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

@iefremov iefremov self-requested a review February 13, 2020 09:35
content::WebContents* contents =
browser()->tab_strip_model()->GetActiveWebContents();
ASSERT_TRUE(content::WaitForLoadStop(contents));
EXPECT_EQ(url, contents->GetURL());
Copy link
Contributor

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

@jumde jumde force-pushed the disable_reporting_observers branch from 1621ffc to b633bb6 Compare February 13, 2020 17:14
callback ReportingObserverCallback = void (sequence<Report> reports, ReportingObserver observer);

[
- Constructor(ReportingObserverCallback callback, optional ReportingObserverOptions options),
Copy link
Collaborator

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?

Copy link
Collaborator

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?

Copy link
Contributor Author

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

@jumde jumde force-pushed the disable_reporting_observers branch 5 times, most recently from 37abda6 to 88baad1 Compare February 25, 2020 04:35
browser()->tab_strip_model()->GetActiveWebContents();

bool reporting_observer_blocked;
ASSERT_TRUE(ExecuteScriptAndExtractBool(
Copy link
Contributor

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_;
Copy link
Contributor

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?

@jumde jumde force-pushed the disable_reporting_observers branch 2 times, most recently from a1664a8 to 6f4369a Compare February 26, 2020 20:37
callback ReportingObserverCallback = void (sequence<Report> reports, ReportingObserver observer);

[
+ ContextEnabled=ReportingObservers,
Copy link
Collaborator

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?

Copy link
Contributor Author

@jumde jumde Mar 3, 2020

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.

@jumde jumde force-pushed the disable_reporting_observers branch 2 times, most recently from 5a89821 to 1480a43 Compare March 3, 2020 01:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Disable Reporting API
3 participants