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 Feature Policy report output #14154

Merged
merged 1 commit into from
Nov 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions feature-policy/experimental-features/resources/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ window.reporting_observer_instance = new ReportingObserver((reports, observer) =
if (window.reporting_observer_callback) {
reports.forEach(window.reporting_observer_callback);
}
}, {types: ["feature-policy"]});
}, {types: ["feature-policy-violation"]});
window.reporting_observer_instance.observe();
window.reporting_observer_callback = null;

Expand All @@ -79,7 +79,7 @@ function wait_for_violation_in_file(feature, file_name) {
return new Promise( (resolve) => {
assert_equals(null, window.reporting_observer_callback);
window.reporting_observer_callback = (report) => {
var feature_match = (feature === report.body.feature);
var feature_match = (feature === report.body.featureId);
var file_name_match =
!file_name ||
(report.body.sourceFile.indexOf(file_name) !== -1);
Expand Down
6 changes: 3 additions & 3 deletions feature-policy/reporting/camera-report-only.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
<script>
var check_report_format = ([reports, observer]) => {
let report = reports[0];
assert_equals(report.type, "feature-policy");
assert_equals(report.body.feature, "camera");
assert_equals(report.type, "feature-policy-violation");
assert_equals(report.body.featureId, "camera");
assert_equals(report.body.disposition, "report");
};

promise_test(async t => {
const report = new Promise(resolve => {
new ReportingObserver((reports, observer) => resolve([reports, observer]),
{types: ['feature-policy']}).observe();
{types: ['feature-policy-violation']}).observe();
});
await test_driver.bless('Activate document for user media');
await navigator.mediaDevices.getUserMedia({video: true});
Expand Down
1 change: 0 additions & 1 deletion feature-policy/reporting/camera-reporting.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
assert_equals(report.type, "feature-policy-violation");
assert_equals(report.url, document.location.href);
assert_equals(report.body.featureId, "camera");
assert_equals(report.body.disposition, "enforce");
assert_equals(report.body.sourceFile, document.location.href);
assert_equals(typeof report.body.lineNumber, "number");
assert_equals(typeof report.body.columnNumber, "number");
Expand Down
6 changes: 3 additions & 3 deletions feature-policy/reporting/document-write-report-only.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
<script>
var check_report_format = ([reports, observer]) => {
let report = reports[0];
assert_equals(report.type, "feature-policy");
assert_equals(report.body.feature, "document-write");
assert_equals(report.type, "feature-policy-violation");
assert_equals(report.body.featureId, "document-write");
assert_equals(report.body.disposition, "report");
};

promise_test(async t => {
const report = new Promise(resolve => {
new ReportingObserver((reports, observer) => resolve([reports, observer]),
{types: ['feature-policy']}).observe();
{types: ['feature-policy-violation']}).observe();
});
document.write("This should be written into the document");
check_report_format(await report);
Expand Down
1 change: 0 additions & 1 deletion feature-policy/reporting/document-write-reporting.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
assert_equals(report.type, "feature-policy-violation");
assert_equals(report.url, document.location.href);
assert_equals(report.body.featureId, "document-write");
assert_equals(report.body.disposition, "enforce");
assert_equals(report.body.sourceFile, document.location.href);
assert_equals(typeof report.body.lineNumber, "number");
assert_equals(typeof report.body.columnNumber, "number");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
<script>
var check_report_format = ([reports, observer]) => {
let report = reports[0];
assert_equals(report.type, "feature-policy");
assert_equals(report.body.feature, "encrypted-media");
assert_equals(report.type, "feature-policy-violation");
assert_equals(report.body.featureId, "encrypted-media");
assert_equals(report.body.disposition, "report");
};

promise_test(async t => {
const report = new Promise(resolve => {
new ReportingObserver((reports, observer) => resolve([reports, observer]),
{types: ['feature-policy']}).observe();
{types: ['feature-policy-violation']}).observe();
});
await navigator.requestMediaKeySystemAccess("org.w3.clearkey",
[{
Expand Down
7 changes: 3 additions & 4 deletions feature-policy/reporting/encrypted-media-reporting.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,19 @@
<script>
var check_report_format = (reports, observer) => {
let report = reports[0];
assert_equals(report.type, "feature-policy");
assert_equals(report.type, "feature-policy-violation");
assert_equals(report.url, document.location.href);
assert_equals(report.body.feature, "encrypted-media");
assert_equals(report.body.featureId, "encrypted-media");
assert_equals(report.body.disposition, "enforce");
assert_equals(report.body.sourceFile, document.location.href);
assert_equals(typeof report.body.message, "string");
assert_equals(typeof report.body.lineNumber, "number");
assert_equals(typeof report.body.columnNumber, "number");
};

promise_test(async t => {
const report = new Promise(resolve => {
new ReportingObserver((reports, observer) => resolve([reports, observer]),
{types: ['feature-policy']}).observe();
{types: ['feature-policy-violation']}).observe();
});
await promise_rejects(t, "SecurityError",
navigator.requestMediaKeySystemAccess("org.w3.clearkey",
Expand Down
6 changes: 3 additions & 3 deletions feature-policy/reporting/fullscreen-report-only.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
<script>
var check_report_format = ([reports, observer]) => {
let report = reports[0];
assert_equals(report.type, "feature-policy");
assert_equals(report.body.feature, "fullscreen");
assert_equals(report.type, "feature-policy-violation");
assert_equals(report.body.featureId, "fullscreen");
assert_equals(report.body.disposition, "report");
};

promise_test(async t => {
const report = new Promise(resolve => {
new ReportingObserver((reports, observer) => resolve([reports, observer]),
{types: ['feature-policy']}).observe();
{types: ['feature-policy-violation']}).observe();
});
await test_driver.bless('Activate document for fullscreen');
await document.getElementById('fs').requestFullscreen();
Expand Down
1 change: 0 additions & 1 deletion feature-policy/reporting/fullscreen-reporting.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
assert_equals(report.type, "feature-policy-violation");
assert_equals(report.url, document.location.href);
assert_equals(report.body.featureId, "fullscreen");
assert_equals(report.body.disposition, "enforce");
assert_equals(report.body.sourceFile, document.location.href);
assert_equals(typeof report.body.lineNumber, "number");
assert_equals(typeof report.body.columnNumber, "number");
Expand Down
13 changes: 6 additions & 7 deletions feature-policy/reporting/generic-sensor-report-only.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,18 @@

// Validate that the reported feature is one of the sensor features, and that
// we have not seen a report for this feature before.
assert_true(sensor_features_verified.hasOwnProperty(report.body.feature));
assert_false(sensor_features_verified[report.body.feature]);
assert_true(sensor_features_verified.hasOwnProperty(report.body.featureId));
assert_false(sensor_features_verified[report.body.featureId]);

// Validate the remainder of the report
assert_equals(report.type, "feature-policy");
assert_equals(report.type, "feature-policy-violation");
assert_equals(report.url, document.location.href);
assert_equals(report.body.disposition, "report");
assert_equals(report.body.sourceFile, document.location.href);
assert_equals(typeof report.body.message, "string");
assert_equals(typeof report.body.lineNumber, "number");
assert_equals(typeof report.body.columnNumber, "number");
assert_equals(report.body.disposition, "report");

sensor_features_verified[report.body.feature] = true;
sensor_features_verified[report.body.featureId] = true;
}

// Test is only done when reports for all features have been seen
Expand All @@ -45,7 +44,7 @@

async_test(t => {
new ReportingObserver(t.step_func(check_report_format),
{types: ['feature-policy']}).observe();
{types: ['feature-policy-violation']}).observe();
new Accelerometer();
new AmbientLightSensor();
new Gyroscope();
Expand Down
13 changes: 6 additions & 7 deletions feature-policy/reporting/generic-sensor-reporting.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,18 @@

// Validate that the reported feature is one of the sensor features, and that
// we have not seen a report for this feature before.
assert_true(sensor_features_verified.hasOwnProperty(report.body.feature));
assert_false(sensor_features_verified[report.body.feature]);
assert_true(sensor_features_verified.hasOwnProperty(report.body.featureId));
assert_false(sensor_features_verified[report.body.featureId]);

// Validate the remainder of the report
assert_equals(report.type, "feature-policy");
assert_equals(report.type, "feature-policy-violation");
assert_equals(report.url, document.location.href);
assert_equals(report.body.disposition, "enforce");
assert_equals(report.body.sourceFile, document.location.href);
assert_equals(typeof report.body.message, "string");
assert_equals(typeof report.body.lineNumber, "number");
assert_equals(typeof report.body.columnNumber, "number");
assert_equals(report.body.disposition, "enforce");

sensor_features_verified[report.body.feature] = true;
sensor_features_verified[report.body.featureId] = true;
}

// Test is only done when reports for all features have been seen
Expand All @@ -45,7 +44,7 @@

async_test(t => {
new ReportingObserver(t.step_func(check_report_format),
{types: ['feature-policy']}).observe();
{types: ['feature-policy-violation']}).observe();
assert_throws("SecurityError", () => new Accelerometer(), "Constructing sensors should be blocked by policy");
assert_throws("SecurityError", () => new AmbientLightSensor(), "Constructing sensors should be blocked by policy");
assert_throws("SecurityError", () => new Gyroscope(), "Constructing sensors should be blocked by policy");
Expand Down
6 changes: 3 additions & 3 deletions feature-policy/reporting/geolocation-report-only.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
<script>
var check_report_format = ([reports, observer]) => {
let report = reports[0];
assert_equals(report.type, "feature-policy");
assert_equals(report.body.feature, "geolocation");
assert_equals(report.type, "feature-policy-violation");
assert_equals(report.body.featureId, "geolocation");
assert_equals(report.body.disposition, "report");
};

promise_test(async t => {
const report = new Promise(resolve => {
new ReportingObserver((reports, observer) => resolve([reports, observer]),
{types: ['feature-policy']}).observe();
{types: ['feature-policy-violation']}).observe();
});
try {
await new Promise((resolve, reject) => {
Expand Down
2 changes: 0 additions & 2 deletions feature-policy/reporting/geolocation-reporting.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
assert_equals(report.type, "feature-policy-violation");
assert_equals(report.url, document.location.href);
assert_equals(report.body.featureId, "geolocation");
assert_equals(report.body.disposition, "enforce");
assert_equals(report.body.sourceFile, document.location.href);
assert_equals(typeof report.body.message, "string");
assert_equals(typeof report.body.lineNumber, "number");
assert_equals(typeof report.body.columnNumber, "number");
assert_equals(report.body.disposition, "enforce");
Expand Down
6 changes: 3 additions & 3 deletions feature-policy/reporting/microphone-report-only.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
<script>
var check_report_format = ([reports, observer]) => {
let report = reports[0];
assert_equals(report.type, "feature-policy");
assert_equals(report.body.feature, "microphone");
assert_equals(report.type, "feature-policy-violation");
assert_equals(report.body.featureId, "microphone");
assert_equals(report.body.disposition, "report");
};

promise_test(async t => {
const report = new Promise(resolve => {
new ReportingObserver((reports, observer) => resolve([reports, observer]),
{types: ['feature-policy']}).observe();
{types: ['feature-policy-violation']}).observe();
});
await test_driver.bless('Activate document for user media');
await navigator.mediaDevices.getUserMedia({audio: true});
Expand Down
1 change: 0 additions & 1 deletion feature-policy/reporting/microphone-reporting.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
assert_equals(report.type, "feature-policy-violation");
assert_equals(report.url, document.location.href);
assert_equals(report.body.featureId, "microphone");
assert_equals(report.body.disposition, "enforce");
assert_equals(report.body.sourceFile, document.location.href);
assert_equals(typeof report.body.lineNumber, "number");
assert_equals(typeof report.body.columnNumber, "number");
Expand Down
6 changes: 3 additions & 3 deletions feature-policy/reporting/midi-report-only.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
<script>
var check_report_format = ([reports, observer]) => {
let report = reports[0];
assert_equals(report.type, "feature-policy");
assert_equals(report.body.feature, "midi");
assert_equals(report.type, "feature-policy-violation");
assert_equals(report.body.featureId, "midi");
assert_equals(report.body.disposition, "report");
};

promise_test(async t => {
const report = new Promise(resolve => {
new ReportingObserver((reports, observer) => resolve([reports, observer]),
{types: ['feature-policy']}).observe();
{types: ['feature-policy-violation']}).observe();
});
try {
await navigator.requestMIDIAccess();
Expand Down
1 change: 0 additions & 1 deletion feature-policy/reporting/midi-reporting.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
assert_equals(report.type, "feature-policy-violation");
assert_equals(report.url, document.location.href);
assert_equals(report.body.featureId, "midi");
assert_equals(report.body.disposition, "enforce");
assert_equals(report.body.sourceFile, document.location.href);
assert_equals(typeof report.body.lineNumber, "number");
assert_equals(typeof report.body.columnNumber, "number");
Expand Down
6 changes: 3 additions & 3 deletions feature-policy/reporting/payment-report-only.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
<script>
var check_report_format = ([reports, observer]) => {
let report = reports[0];
assert_equals(report.type, "feature-policy");
assert_equals(report.body.feature, "payment");
assert_equals(report.type, "feature-policy-violation");
assert_equals(report.body.featureId, "payment");
assert_equals(report.body.disposition, "report");
};

promise_test(async t => {
const report = new Promise(resolve => {
new ReportingObserver((reports, observer) => resolve([reports, observer]),
{types: ['feature-policy']}).observe();
{types: ['feature-policy-violation']}).observe();
});
try {
const request = new PaymentRequest(
Expand Down
1 change: 0 additions & 1 deletion feature-policy/reporting/payment-reporting.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
assert_equals(report.type, "feature-policy-violation");
assert_equals(report.url, document.location.href);
assert_equals(report.body.featureId, "payment");
assert_equals(report.body.disposition, "enforce");
assert_equals(report.body.sourceFile, document.location.href);
assert_equals(typeof report.body.lineNumber, "number");
assert_equals(typeof report.body.columnNumber, "number");
Expand Down
6 changes: 3 additions & 3 deletions feature-policy/reporting/picture-in-picture-report-only.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<script>
const check_report_format = ([reports, observer]) => {
const report = reports[0];
assert_equals(report.type, "feature-policy");
assert_equals(report.body.feature, "picture-in-picture");
assert_equals(report.type, "feature-policy-violation");
assert_equals(report.body.featureId, "picture-in-picture");
assert_equals(report.body.disposition, "report");
};

Expand All @@ -28,7 +28,7 @@
promise_pip_test(async (t) => {
const report = new Promise(resolve => {
new ReportingObserver((reports, observer) => resolve([reports, observer]),
{types: ['feature-policy']}).observe();
{types: ['feature-policy-violation']}).observe();
});
const videoElement = await loadVideo();
await test_driver.bless('picture-in-picture');
Expand Down
9 changes: 4 additions & 5 deletions feature-policy/reporting/picture-in-picture-reporting.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@
<script>
const check_report_format = (reports, observer) => {
const report = reports[0];
assert_equals(report.type, "feature-policy");
assert_equals(report.type, "feature-policy-violation");
assert_equals(report.url, document.location.href);
assert_equals(report.body.feature, "picture-in-picture");
assert_equals(report.body.disposition, "enforce");
assert_equals(report.body.featureId, "picture-in-picture");
assert_equals(report.body.sourceFile, document.location.href);
assert_equals(typeof report.body.message, "string");
assert_equals(typeof report.body.lineNumber, "number");
assert_equals(typeof report.body.columnNumber, "number");
assert_equals(report.body.disposition, "enforce");
};

const loadVideo = () => new Promise(resolve => {
Expand All @@ -33,7 +32,7 @@
promise_pip_test(async (t) => {
const report = new Promise(resolve => {
new ReportingObserver((reports, observer) => resolve([reports, observer]),
{types: ['feature-policy']}).observe();
{types: ['feature-policy-violation']}).observe();
});
const videoElement = await loadVideo();
await test_driver.bless('picture-in-picture');
Expand Down
6 changes: 3 additions & 3 deletions feature-policy/reporting/sync-xhr-report-only.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
<script>
const check_report_format = ([reports, observer]) => {
const report = reports[0];
assert_equals(report.type, "feature-policy");
assert_equals(report.body.feature, "sync-xhr");
assert_equals(report.type, "feature-policy-violation");
assert_equals(report.body.featureId, "sync-xhr");
assert_equals(report.body.disposition, "report");
};

promise_test(async t => {
const report = new Promise(resolve => {
new ReportingObserver((reports, observer) => resolve([reports, observer]),
{types: ['feature-policy']}).observe();
{types: ['feature-policy-violation']}).observe();
});
const xhr = new XMLHttpRequest();
xhr.open("GET", document.location.href, false);
Expand Down
1 change: 0 additions & 1 deletion feature-policy/reporting/sync-xhr-reporting.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
assert_equals(report.type, "feature-policy-violation");
assert_equals(report.url, document.location.href);
assert_equals(report.body.featureId, "sync-xhr");
assert_equals(report.body.disposition, "enforce");
assert_equals(report.body.sourceFile, document.location.href);
assert_equals(typeof report.body.lineNumber, "number");
assert_equals(typeof report.body.columnNumber, "number");
Expand Down
Loading