Update web-platform-tests to revision 687b6cba3385c4c2ca85f44fe072961e651621b5

This commit is contained in:
WPT Sync Bot 2019-04-08 21:47:49 -04:00
parent cd579f6746
commit 1a4444a557
45 changed files with 594 additions and 259 deletions

View file

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Test oversized-images policy with threshold 'inf'</title>
</head>
<body>
<!-- The sample image has an intrinsic image size of 200x200px -->
<img src="resources/sample-1.png" width="200" height="200">
<img src="resources/sample-1.png" width="100" height="200">
<img src="resources/sample-1.png" width="50" height="200">
<br>
<img src="resources/sample-1.png" width="200" height="100">
<img src="resources/sample-1.png" width="100" height="100">
<img src="resources/sample-1.png" width="50" height="100">
<br>
<img src="resources/sample-1.png" width="200" height="50">
<img src="resources/sample-1.png" width="100" height="50">
<img src="resources/sample-1.png" width="50" height="50">
</body>
</html>

View file

@ -0,0 +1 @@
Feature-Policy: oversized-images (inf)

View file

@ -0,0 +1,44 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/feature-policy/resources/featurepolicy.js"></script>
<title>Test oversized-images policy with threshold 1.5</title>
</head>
<body>
<iframe scrolling="no" name="a" style="overflow:hidden" width="380" height="220"></iframe>
<iframe scrolling="no" name="b" style="overflow:hidden" width="380" height="220"></iframe>
<iframe scrolling="no" name="c" style="overflow:hidden" width="380" height="220"></iframe>
<iframe scrolling="no" name="d" style="overflow:hidden" width="380" height="220"></iframe>
<iframe scrolling="no" name="e" style="overflow:hidden" width="380" height="220"></iframe>
<script>
const frame_to_test_map = {};
window.addEventListener('message', ev => {
if (ev.data.type == "finished") {
if (frame_to_test_map.hasOwnProperty(ev.data.name)) {
frame_to_test_map[ev.data.name].done();
}
}
});
const config = {
a: {threshold: 0.0, blocked: 3},
b: {threshold: 1.0, blocked: 2},
c: {threshold: 2.5, blocked: 1},
d: {threshold: 4.0, blocked: 0},
e: {threshold: "inf", blocked: 0}
};
const iframes = document.querySelectorAll('iframe');
const total_iframes = iframes.length;
iframes.forEach(iframe => {
const frame_config = config[iframe.name]
async_test(t => {
frame_to_test_map[iframe.name] = t;
iframe.src = "resources/feature-parameters-frame.html?name="+iframe.name+"&n="+frame_config.blocked+"&pipe=header(Feature-Policy,oversized-images%20("+frame_config.threshold+"\\);)";
}, "Test frame with threshold " + frame_config.threshold + " should block " + frame_config.blocked + " images.");
});
</script>
</body>
</html>

View file

@ -0,0 +1,28 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/feature-policy/resources/featurepolicy.js"></script>
<title>Test oversized-images policy with threshold 1.5</title>
</head>
<body>
<!-- The sample image has an intrinsic image size of 200x200px -->
<img src="resources/sample-1.png" width="200" height="200">
<img src="resources/sample-1.png" width="100" height="200">
<img src="resources/sample-1.png" width="50" height="200">
<br>
<img src="resources/sample-1.png" width="200" height="100">
<img src="resources/sample-1.png" width="100" height="100">
<img src="resources/sample-1.png" width="50" height="100">
<br>
<img src="resources/sample-1.png" width="200" height="50">
<img src="resources/sample-1.png" width="100" height="50">
<img src="resources/sample-1.png" width="50" height="50">
<script>
expect_reports(8, "oversized-images", "8 images should be blocked by policy");
</script>
</body>
</html>

View file

@ -0,0 +1 @@
Feature-Policy: oversized-images (1.5)

View file

@ -0,0 +1,50 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/feature-policy/resources/featurepolicy.js"></script>
<title>Test oversized-images policy in subframe</title>
</head>
<body>
<!-- The sample image has an intrinsic image size of 200x200px -->
<img width="200" height="200">
<img width="100" height="200">
<img width="50" height="200">
<script>
const policy_name = "oversized-images";
const params = new URLSearchParams(document.location.search);
const frame_name = params.get('name');
const expected_report_count = +params.get('n');
var num_received_reports = 0;
const images = document.querySelectorAll('img');
const total_images = images.length;
var images_loaded = 0;
const notifyIfDone = () => {
if (num_received_reports >= expected_report_count &&
images_loaded == total_images) {
parent.postMessage({
"type": "finished",
"name": frame_name
},"*");
}
};
images.forEach(image => {
image.addEventListener('load', () => { images_loaded++; notifyIfDone(); });
image.src = "sample-1.png";
});
new ReportingObserver((reports, observer) => {
const relevant_reports = reports.filter(r => (r.body.featureId === policy_name));
num_received_reports += relevant_reports.length;
notifyIfDone();
}, {types: ['feature-policy-violation'], buffered: true}).observe();
</script>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 428 B