Commit edeaf612 authored by Charlie Hu's avatar Charlie Hu Committed by Commit Bot

Fix flaky test document-policy-oversized-images-resize.html

Previous fix to the failing test was to add a setTimeout on
resize javascript so that the initial frame can be rendered
before the resize.
(https://chromium-review.googlesource.com/c/chromium/src/+/2090457)

It turns out setTimeout is not a reliable way to force
layout. This CL uses |runAfterLayoutAndPaint| to force
multiple layouts happening instead of only once at the end
by default for pixel tests.

Bug: 1061539, 1060776

Change-Id: If068a63655eaacf1300b963e60e441a04fc59784
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2124888
Commit-Queue: Charlie Hu <chenleihu@google.com>
Reviewed-by: default avatarIan Clelland <iclelland@chromium.org>
Cr-Commit-Position: refs/heads/master@{#754633}
parent b74ae50e
...@@ -6659,8 +6659,6 @@ crbug.com/1061226 [ Fuchsia ] external/wpt/mediacapture-streams/MediaStream-idl. ...@@ -6659,8 +6659,6 @@ crbug.com/1061226 [ Fuchsia ] external/wpt/mediacapture-streams/MediaStream-idl.
crbug.com/1061159 [ Fuchsia ] fast/inspector-support/cssURLQuotes.html [ Pass Failure ] crbug.com/1061159 [ Fuchsia ] fast/inspector-support/cssURLQuotes.html [ Pass Failure ]
crbug.com/1061043 fast/plugins/keypress-event.html [ Pass Failure ] crbug.com/1061043 fast/plugins/keypress-event.html [ Pass Failure ]
crbug.com/1061097 http/tests/security/promise-access-control-allow.htm [ Pass Failure ] crbug.com/1061097 http/tests/security/promise-access-control-allow.htm [ Pass Failure ]
crbug.com/1061539 [ Mac ] http/tests/images/document-policy-oversized-images-resize.html [ Pass Failure ]
crbug.com/1061539 [ Linux ] http/tests/images/document-policy-oversized-images-resize.html [ Pass Failure ]
crbug.com/1061131 [ Mac ] virtual/threaded-prefer-compositing/fast/scrolling/middle-click-autoscroll-latching-clicked-node.html [ Pass Timeout ] crbug.com/1061131 [ Mac ] virtual/threaded-prefer-compositing/fast/scrolling/middle-click-autoscroll-latching-clicked-node.html [ Pass Timeout ]
crbug.com/1061131 [ Win ] fast/canvas/toBlob-in-detached-document.html [ Pass Crash ] crbug.com/1061131 [ Win ] fast/canvas/toBlob-in-detached-document.html [ Pass Crash ]
crbug.com/1061131 [ Mac ] fast/canvas/toBlob-in-detached-document.html [ Pass Crash ] crbug.com/1061131 [ Mac ] fast/canvas/toBlob-in-detached-document.html [ Pass Crash ]
......
<!DOCTYPE html>
<body>
<iframe id="simple" src="resources/frame-with-oversized-images-resize.php"
width="600" height="500">
</iframe>
</body>
<?php
header("Document-Policy: oversized-images;scale=2.0");
?>
<!DOCTYPE html>
<head>
<script src='/resources/run-after-layout-and-paint.js'></script>
</head>
<body>
<!--
Tests that document policy violation on oversized-images is not triggered,
after images are resized to proper size.
The initial sizes setting for images all trigger document policy violation.
It is expected that 4 violation report and corresponding console messages
generated. (content in -expected.txt)
After the resize, there should not be any violations triggered.
It is expected that non of images on page are replaced by placeholders
after resize. (content in -expected.png)
-->
<img src="resources/green-256x256.jpg" width="100" height="128">
<img src="resources/green-256x256.jpg" style="height: 100px; width: 128px">
<img src="resources/green-256x256.jpg" width="100" height="100">
<img src="resources/green-256x256.jpg" style="height: 100px; width: 100px">
<script>
runAfterLayoutAndPaint(function() {
var images = document.getElementsByTagName('img');
for (var i = 0; i < images.length; i++) {
var image = images[i];
if (image.hasAttribute('width') || image.hasAttribute('height')) {
image.width = "150";
image.height = "150";
} else {
image.style.width = "150px";
image.style.height = "150px";
}
}
}, true);
</script>
</body>
</html>
\ No newline at end of file
<?php
header("Document-Policy: oversized-images;scale=2.0");
?>
<!DOCTYPE html>
<body>
<img src="green-256x256.jpg" width="100" height="256">
<img src="green-256x256.jpg" style="height: 100px; width: 256px">
<img src="green-256x256.jpg" width="50" height="50">
<img src="green-256x256.jpg" style="height: 50px; weight: 50px">
<script>
window.addEventListener('load', function() {
setTimeout(() => {
var images = document.getElementsByTagName('img');
for (var i = 0; i < images.length; i++) {
var image = images[i];
if (image.hasAttribute('width') || image.hasAttribute('height')) {
image.width = "150";
image.height = "150";
} else {
image.style.width = "150px";
image.style.height = "150px";
}
}
}, 5);
});
</script>
</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