Commit 412b99ac authored by Charlie Hu's avatar Charlie Hu Committed by Commit Bot

[Document Policy] Move test content to main frame for image policy tests

Image policies used to be feature poilcy and the only way to
specify feature policy is by specifying 'allow' attribute on iframe.

The tests were set up with subframes holding the test content while
the main frame specifies the policy.

With image policies migrated to document policy which uses HTTP header
to specify policy, there is no reason to split the test content to
subframe right now.

This CL moves test content to main frame for image policy tests.

Change-Id: Idf95c84d27fafbdb5fa926fefacfbcf1b913b7c6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2414561
Commit-Queue: Charlie Hu <chenleihu@google.com>
Reviewed-by: default avatarJason Chase <chasej@chromium.org>
Cr-Commit-Position: refs/heads/master@{#812502}
parent 28324ae4
<!DOCTYPE html>
<script>
function loaded() {
if (window.testRunner) {
testRunner.waitUntilDone();
testRunner.updateAllLifecyclePhasesAndCompositeThen(() => testRunner.notifyDone());
}
}
</script>
<iframe src="resources/frame-with-oversized-images-forced-layout.php"
frameborder="0" onload=loaded()>
</iframe>
<?php
header("Document-Policy: oversized-images=2.0");
?>
<!DOCTYPE html>
<head>
<script>
function loaded() {
if (window.testRunner) {
testRunner.waitUntilDone();
testRunner.updateAllLifecyclePhasesAndCompositeThen(() => testRunner.notifyDone());
}
}
</script>
<style>
body {
margin: 0;
}
</style>
</head>
<body onload=loaded()>
<img src="resources/green-256x256.jpg" width="100" height="100">
<img src="resources/green-256x256.jpg" style="width: 100px; height: 100px">
<script>
document.body.offsetTop;
</script>
</body>
\ No newline at end of file
<?php
header("Document-Policy: oversized-images=2.0");
?>
<!DOCTYPE html>
<script>
function loaded() {
......@@ -7,7 +10,9 @@
}
}
</script>
<body>
<iframe id="simple" src="resources/frame-with-oversized-images-responsive-images.php" width="600" height="500" onload="loaded()">
</iframe>
<body onload=loaded()>
<img srcset="resources/green-256x256.jpg 256w" sizes="100px" width="127" height="127">
<img srcset="resources/green-256x256.jpg 256w" sizes="100px" width="128" height="128">
<img srcset="resources/green-256x256.jpg 256w" sizes="100px" width="129" height="129">
</body>
<!DOCTYPE html>
<script>
if (window.testRunner)
testRunner.waitUntilDone();
function compositeAndEnd() {
if (window.testRunner)
testRunner.updateAllLifecyclePhasesAndCompositeThen(() => testRunner.notifyDone())
}
</script>
<body>
<iframe id="simple" src="resources/frame-with-oversized-images-styles.php"
width="600" height="500" onload="compositeAndEnd()">
</iframe>
</body>
<?php
header("Document-Policy: oversized-images=2.0");
?>
<!DOCTYPE html>
<head>
<script>
function loaded() {
if (window.testRunner) {
testRunner.waitUntilDone();
testRunner.updateAllLifecyclePhasesAndCompositeThen(() => testRunner.notifyDone());
}
}
</script>
</head>
<body onload=loaded()>
<!-- Should not trigger violation message. -->
<img src="resources/green-256x256.jpg" width="128" height="128" style="border: 10px solid red;">
<!-- Should generate a violation message each and get replaced with placeholder image. -->
<img src="resources/green-256x256.jpg" width="120" height="120" style="border: 10px solid red;">
<img src="resources/green-256x256.jpg" width="120" height="120" style="padding: 10px;">
<img src="resources/green-256x256.jpg" width="120" height="120" style="border: 10px solid red; padding: 5px;">
</body>
<!DOCTYPE html>
<script>
if (window.testRunner)
testRunner.waitUntilDone();
function compositeAndEnd() {
if (window.testRunner)
testRunner.updateAllLifecyclePhasesAndCompositeThen(() => testRunner.notifyDone())
}
</script>
<body>
<iframe id="simple" src="resources/frame-with-oversized-images-edge-cases.php"
width="600" height="500" onload="compositeAndEnd()">
</iframe>
</body>
<?php
header("Document-Policy: oversized-images=2.0");
?>
<!DOCTYPE html>
<!--
Images should be replaced by placeholders if they are considered
oversized, i.e. having
image_size / (container_size * pixel_ratio) > threshold.
Threshold is set by the document policy header(2.0 in this test).
-->
<head>
<script>
function loaded() {
if (window.testRunner) {
testRunner.waitUntilDone();
testRunner.updateAllLifecyclePhasesAndCompositeThen(() => testRunner.notifyDone());
}
}
</script>
</head>
<body onload=loaded()>
<div style="display: inline-block;">
<p style="width: 100%;">
Following cases are for device pixel ratio = 1.0.<br>
Image with size < 128 should all be replaced with placeholders.
</p>
<table>
<tr>
<th>size</th>
<th>127</th>
<th>128</th>
<th>129</th>
</tr>
<tr>
<td></td>
<td><img src="resources/green-256x256.jpg" width="127" height="127"></td>
<td><img src="resources/green-256x256.jpg" width="128" height="128"></td>
<td><img src="resources/green-256x256.jpg" width="129" height="129"></td>
</tr>
</table>
</div>
<div style="display: inline-block;">
<p style="width: 100%;">
Following cases are for device pixel ratio = 2.0.<br>
Image with size < 64 should all be replaced with placeholders.
</p>
<table>
<tr>
<th>size</th>
<th>63</th>
<th>64</th>
<th>65</th>
</tr>
<tr>
<td></td>
<td><img src="resources/green-256x256.jpg" width="63" height="63"></td>
<td><img src="resources/green-256x256.jpg" width="64" height="64"></td>
<td><img src="resources/green-256x256.jpg" width="65" height="65"></td>
</tr>
</table>
</div>
</body>
<?php
header("Document-Policy: oversized-images=2.0");
?>
<!DOCTYPE html>
<!--
Images should be replaced by placeholders if there are considered
oversized, i.e. having
image_size / (container_size * pixel_ratio) > threshold.
Threshold is set by the document policy header(2.0 in this test).
-->
<body>
<img src="green-256x256.jpg">
<!-- Following cases are for device pixel ratio = 1.0 -->
<!-- Image with size < 128 should all be replaced with placeholders -->
<img src="green-256x256.jpg" width="128" height="128">
<img src="green-256x256.jpg" width="127" height="127">
<img src="green-256x256.jpg" width="129" height="129">
<!-- Following cases are for device pixel ratio = 2.0 -->
<!-- Image with size < 64 should all be replaced with placeholders -->
<img src="green-256x256.jpg" width="64" height="64">
<img src="green-256x256.jpg" width="63" height="63">
<img src="green-256x256.jpg" width="65" height="65">
</body>
\ No newline at end of file
<?php
header("Document-Policy: oversized-images=2.0");
?>
<!DOCTYPE html>
<style>body { margin: 0; }</style>
<img src="green-256x256.jpg" width="100" height="100">
<img src="green-256x256.jpg" style="width: 100px; height: 100px">
<script>
document.body.offsetTop;
</script>
<?php
header("Document-Policy: oversized-images=2.0");
?>
<!DOCTYPE html>
<body>
<img srcset="green-256x256.jpg 256w" sizes="100px" width="127" height="127">
<img srcset="green-256x256.jpg 256w" sizes="100px" width="128" height="128">
<img srcset="green-256x256.jpg 256w" sizes="100px" width="129" height="129">
</body>
<?php
header("Document-Policy: oversized-images=2.0");
?>
<!DOCTYPE html>
<body>
<img src="green-256x256.jpg" width="128" height="128" style="border: 10px solid red;">
<img src="green-256x256.jpg" width="120" height="120" style="border: 10px solid red;">
<img src="green-256x256.jpg" width="120" height="120" style="padding: 10px;">
<img src="green-256x256.jpg" width="120" height="120" style="border: 10px solid red; padding: 5px;">
</body>
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