Commit e5df6cff authored by Paul Meyer's avatar Paul Meyer Committed by Commit Bot

Route |id| and |anticipatedRemoval| fields in deprecation reports to

Reporting API.

A previous patch
(https://chromium-review.googlesource.com/c/chromium/src/+/772999) added
these new fields. This patch routes them to the Reporting API, and
updates the associated test.

Bug: 731810
Change-Id: I3a9a3ac71d894f784f18d5fb51898184541e6216
Reviewed-on: https://chromium-review.googlesource.com/775154
Commit-Queue: Paul Meyer <paulmeyer@chromium.org>
Reviewed-by: default avatarKen Buchanan <kenrb@chromium.org>
Reviewed-by: default avatarRick Byers <rbyers@chromium.org>
Reviewed-by: default avatarJulia Tuttle <juliatuttle@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521546}
parent bfc2241d
......@@ -47,11 +47,16 @@ class ReportingServiceProxyImpl : public blink::mojom::ReportingServiceProxy {
}
void QueueDeprecationReport(const GURL& url,
const std::string& id,
base::Time anticipatedRemoval,
const std::string& message,
const std::string& source_file,
int line_number,
int column_number) override {
auto body = std::make_unique<base::DictionaryValue>();
body->SetString("id", id);
if (anticipatedRemoval.is_null())
body->SetDouble("anticipatedRemoval", anticipatedRemoval.ToDoubleT());
body->SetString("message", message);
body->SetString("sourceFile", source_file);
body->SetInteger("lineNumber", line_number);
......
......@@ -29,8 +29,8 @@ class MockReportingServiceProxy {
}
// Interface implementation.
async queueDeprecationReport(url, message, sourceFile, lineNumber, columnNumber) {
this.resolve([url, message, sourceFile, lineNumber, columnNumber]);
async queueDeprecationReport(url, id, anticipatedRemoval, message, sourceFile, lineNumber, columnNumber) {
this.resolve([url, id, anticipatedRemoval, message, sourceFile, lineNumber, columnNumber]);
this.resetPromise();
}
......@@ -54,8 +54,10 @@ promise_test(async () => {
// Ensure the deprecation report is generated and routed to the reporting mojo
// interface.
let [url, message, sourceFile, lineNumber, columnNumber] = await promise;
let [url, id, anticipatedRemoval, message, sourceFile, lineNumber, columnNumber] = await promise;
assert_true(url.url.endsWith("reporting-observer/reporting-api.html"));
assert_equals(typeof id, "string");
assert_equals(typeof anticipatedRemoval, "object");
assert_equals(typeof message, "string");
assert_true(sourceFile.endsWith("reporting-observer/reporting-api.html"));
assert_equals(typeof lineNumber, "number");
......
......@@ -783,9 +783,9 @@ void Deprecation::GenerateReport(const LocalFrame* frame, WebFeature feature) {
Document* document = frame->GetDocument();
// Construct the deprecation report.
DeprecationReport* body =
new DeprecationReport(info.id, milestoneDate(info.anticipatedRemoval),
info.message, SourceLocation::Capture());
double removalDate = milestoneDate(info.anticipatedRemoval);
DeprecationReport* body = new DeprecationReport(
info.id, removalDate, info.message, SourceLocation::Capture());
Report* report = new Report("deprecation", document->Url().GetString(), body);
// Send the deprecation report to any ReportingObservers.
......@@ -796,9 +796,10 @@ void Deprecation::GenerateReport(const LocalFrame* frame, WebFeature feature) {
// Send the deprecation report to the Reporting API.
mojom::blink::ReportingServiceProxyPtr service;
frame->Client()->GetInterfaceProvider()->GetInterface(&service);
service->QueueDeprecationReport(document->Url(), info.message,
body->sourceFile(), body->lineNumber(),
body->columnNumber());
service->QueueDeprecationReport(document->Url(), info.id,
WTF::Time::FromDoubleT(removalDate),
info.message, body->sourceFile(),
body->lineNumber(), body->columnNumber());
}
// static
......
......@@ -21,26 +21,28 @@ class ReportingServiceProxyPtrHolder {
~ReportingServiceProxyPtrHolder() {}
void QueueInterventionReport(const KURL& url,
const String& body,
const String& message,
const String& source_file,
int line_number,
int column_number) {
if (reporting_service_proxy) {
reporting_service_proxy->QueueInterventionReport(
url, body ? body : "", source_file ? source_file : "", line_number,
column_number);
url, message ? message : "", source_file ? source_file : "",
line_number, column_number);
}
}
void QueueDeprecationReport(const KURL& url,
const String& body,
const String& id,
WTF::Time anticipatedRemoval,
const String& message,
const String& source_file,
int line_number,
int column_number) {
if (reporting_service_proxy) {
reporting_service_proxy->QueueDeprecationReport(
url, body ? body : "", source_file ? source_file : "", line_number,
column_number);
url, id, anticipatedRemoval, message ? message : "",
source_file ? source_file : "", line_number, column_number);
}
}
......
......@@ -4,6 +4,7 @@
module blink.mojom;
import "mojo/common/time.mojom";
import "url/mojo/url.mojom";
interface ReportingServiceProxy {
......@@ -20,12 +21,14 @@ interface ReportingServiceProxy {
//
// (See //third_party/WebKit/Source/core/frame/DeprecationReport.h.)
QueueDeprecationReport(url.mojom.Url url,
string id,
mojo.common.mojom.Time anticipatedRemoval,
string message,
string source_file,
int32 line_number,
int32 column_number);
// Attempts to queue a Deprecation report using the Reporting API.
// Attempts to queue a CSP Violation report using the Reporting API.
//
// (See //third_party/WebKit/Source/core/events/SecurityPolicyViolationEvent.h.)
QueueCspViolationReport(url.mojom.Url url,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment