Bug 1556673 [wpt PR 17160] - Adjust for device pixel ratio, a=testonly

Automatic update from web-platform-tests
Adjust for device pixel ratio (#17160)

The test assumes device pixel ratio of 1 but there are platforms where 2
is used, adjust the test for that.
--

wp5At-commits: b0fefa679fc09c6ee4d976ee27c1b11222e05e12
wpt-pr: 17160
This commit is contained in:
Rob Buis 2019-06-13 15:31:56 +00:00 коммит произвёл James Graham
Родитель 65ae21d987
Коммит 16525d0b37
1 изменённых файлов: 26 добавлений и 20 удалений

Просмотреть файл

@ -9,33 +9,39 @@
setup({explicit_done: true}); setup({explicit_done: true});
var iterations = 0; var iterations = 0;
var expectation = new Array(10).fill(0);
if (window.devicePixelRatio < 1.5) {
expectation[0] = expectation[5] = expectation[8] = 1;
} else if (window.devicePixelRatio >= 1.5) {
expectation[1] = expectation[6] = expectation[9] = 1;
}
function check_finished() { function check_finished() {
if (numberOfResourceTimingEntries('resources/square.png?from-header&1x') == 1 && if (numberOfResourceTimingEntries('resources/square.png?from-header&1x') == expectation[0] &&
numberOfResourceTimingEntries('resources/square.png?from-header&2x') == 0 && numberOfResourceTimingEntries('resources/square.png?from-header&2x') == expectation[1] &&
numberOfResourceTimingEntries('resources/square.png?from-header&3x') == 0 && numberOfResourceTimingEntries('resources/square.png?from-header&3x') == expectation[2] &&
numberOfResourceTimingEntries('resources/square.png?from-header&base') == 0 && numberOfResourceTimingEntries('resources/square.png?from-header&base') == expectation[3] &&
numberOfResourceTimingEntries('resources/square.png?from-header&200') == 0 && numberOfResourceTimingEntries('resources/square.png?from-header&200') == expectation[4] &&
numberOfResourceTimingEntries('resources/square.png?from-header&400') == 1 && numberOfResourceTimingEntries('resources/square.png?from-header&400') == expectation[5] &&
numberOfResourceTimingEntries('resources/square.png?from-header&800') == 0 && numberOfResourceTimingEntries('resources/square.png?from-header&800') == expectation[6] &&
numberOfResourceTimingEntries('resources/square.png?from-header&150') == 0 && numberOfResourceTimingEntries('resources/square.png?from-header&150') == expectation[7] &&
numberOfResourceTimingEntries('resources/square.png?from-header&300') == 1 && numberOfResourceTimingEntries('resources/square.png?from-header&300') == expectation[8] &&
numberOfResourceTimingEntries('resources/square.png?from-header&600') == 0) { numberOfResourceTimingEntries('resources/square.png?from-header&600') == expectation[9]) {
done(); done();
} }
iterations++; iterations++;
if (iterations == 10) { if (iterations == 10) {
// At least one is expected to fail, but this should give details to the exact failure(s). // At least one is expected to fail, but this should give details to the exact failure(s).
verifyNumberOfResourceTimingEntries('resources/square.png?from-header&1x', 1); verifyNumberOfResourceTimingEntries('resources/square.png?from-header&1x', expectation[0]);
verifyNumberOfResourceTimingEntries('resources/square.png?from-header&2x', 0); verifyNumberOfResourceTimingEntries('resources/square.png?from-header&2x', expectation[1]);
verifyNumberOfResourceTimingEntries('resources/square.png?from-header&3x', 0); verifyNumberOfResourceTimingEntries('resources/square.png?from-header&3x', expectation[2]);
verifyNumberOfResourceTimingEntries('resources/square.png?from-header&base', 0); verifyNumberOfResourceTimingEntries('resources/square.png?from-header&base', expectation[3]);
verifyNumberOfResourceTimingEntries('resources/square.png?from-header&200', 0); verifyNumberOfResourceTimingEntries('resources/square.png?from-header&200', expectation[4]);
verifyNumberOfResourceTimingEntries('resources/square.png?from-header&400', 1); verifyNumberOfResourceTimingEntries('resources/square.png?from-header&400', expectation[5]);
verifyNumberOfResourceTimingEntries('resources/square.png?from-header&800', 0); verifyNumberOfResourceTimingEntries('resources/square.png?from-header&800', expectation[6]);
verifyNumberOfResourceTimingEntries('resources/square.png?from-header&150', 0); verifyNumberOfResourceTimingEntries('resources/square.png?from-header&150', expectation[7]);
verifyNumberOfResourceTimingEntries('resources/square.png?from-header&300', 1); verifyNumberOfResourceTimingEntries('resources/square.png?from-header&300', expectation[8]);
verifyNumberOfResourceTimingEntries('resources/square.png?from-header&600', 0); verifyNumberOfResourceTimingEntries('resources/square.png?from-header&600', expectation[9]);
done(); done();
} else { } else {
step_timeout(check_finished, 500); step_timeout(check_finished, 500);