Skip to content

Commit

Permalink
css-grid: Wait for documents.font.ready() for tests with Ahem font (#…
Browse files Browse the repository at this point in the history
…22347)

web-fonts may not be ready when the window.onload signal is triggered,
so to avoid flakiness or unexpected failures on the css-grid tests that
use the Ahem font we should wait for the fonts to be ready before
starting the test.

However, that is not enough, we should also waiting for window.load
before starting the tests because some tests depend on the document
images to load (which may happen before or after the fonts are ready)

So this patch changes the tests using Ahem to start after the load
event has fired and after the fonts are ready.

The tests now need to use "explicit_done: true" to avoid race conditions,
so this commit also sets this tests to be explicit about when they finish.
  • Loading branch information
clopez committed Mar 24, 2020
1 parent a1e3c1e commit ea0533f
Show file tree
Hide file tree
Showing 236 changed files with 844 additions and 247 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<script type="text/javascript">
setup({ explicit_done: true });
</script>

<body onload="checkLayout('.grid')">
<body onload="document.fonts.ready.then(() => { checkLayout('.grid'); })">

<div id="log"></div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,10 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<body onload="checkLayout('.grid')">
<script type="text/javascript">
setup({ explicit_done: true });
</script>
<body onload="document.fonts.ready.then(() => { checkLayout('.grid'); })">

<div id="log"></div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<body onload="checkLayout('.container')">
<script type="text/javascript">
setup({ explicit_done: true });
</script>
<body onload="document.fonts.ready.then(() => { checkLayout('.container'); })">

<div id="log"></div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<script type="text/javascript">
setup({ explicit_done: true });
</script>

<body onload="checkLayout('.grid')">
<body onload="document.fonts.ready.then(() => { checkLayout('.grid'); })">

<div id="log"></div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,11 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<script type="text/javascript">
setup({ explicit_done: true });
</script>

<body onload="checkLayout('.grid')">
<body onload="document.fonts.ready.then(() => { checkLayout('.grid'); })">

<div id="log"></div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<script type="text/javascript">
setup({ explicit_done: true });
</script>

<body onload="checkLayout('.grid')">
<body onload="document.fonts.ready.then(() => { checkLayout('.grid'); })">

<div id="log"></div>

Expand Down
5 changes: 4 additions & 1 deletion css/css-grid/abspos/grid-sizing-positioned-items-001.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,11 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<script type="text/javascript">
setup({ explicit_done: true });
</script>

<body onload="checkLayout('.grid')">
<body onload="document.fonts.ready.then(() => { checkLayout('.grid'); })">

<div id="log"></div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<script type="text/javascript">
setup({ explicit_done: true });
</script>

<body onload="checkLayout('.grid')">
<body onload="document.fonts.ready.then(() => { checkLayout('.grid'); })">

<div id="log"></div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<script type="text/javascript">
setup({ explicit_done: true });
</script>

<body onload="checkLayout('.grid')">
<body onload="document.fonts.ready.then(() => { checkLayout('.grid'); })">

<div id="log"></div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<script type="text/javascript">
setup({ explicit_done: true });
</script>

<body onload="checkLayout('.grid')">
<body onload="document.fonts.ready.then(() => { checkLayout('.grid'); })">

<p>This test checks that the align-content property is applied correctly when using content-distribution values in vertical-lr writing mode.</p>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<script type="text/javascript">
setup({ explicit_done: true });
</script>

<body onload="checkLayout('.grid')">
<body onload="document.fonts.ready.then(() => { checkLayout('.grid'); })">

<p>This test checks that the align-content property is applied correctly when using content-distribution values for vertical-rl mode.</p>

Expand Down
5 changes: 4 additions & 1 deletion css/css-grid/alignment/grid-align-content-distribution.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<script type="text/javascript">
setup({ explicit_done: true });
</script>

<body onload="checkLayout('.grid')">
<body onload="document.fonts.ready.then(() => { checkLayout('.grid'); })">

<p>This test checks that the align-content property is applied correctly when using content-distribution values.</p>

Expand Down
5 changes: 4 additions & 1 deletion css/css-grid/alignment/grid-align-content-vertical-lr.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<script type="text/javascript">
setup({ explicit_done: true });
</script>

<body onload="checkLayout('.grid')">
<body onload="document.fonts.ready.then(() => { checkLayout('.grid'); })">

<div style="position: relative">
<p>direction: LTR | align-content: 'center'</p>
Expand Down
5 changes: 4 additions & 1 deletion css/css-grid/alignment/grid-align-content-vertical-rl.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<script type="text/javascript">
setup({ explicit_done: true });
</script>

<body onload="checkLayout('.grid')">
<body onload="document.fonts.ready.then(() => { checkLayout('.grid'); })">

<div style="position: relative">
<p>direction: LTR | align-content: 'center'</p>
Expand Down
5 changes: 4 additions & 1 deletion css/css-grid/alignment/grid-align-content.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<script type="text/javascript">
setup({ explicit_done: true });
</script>

<body onload="checkLayout('.grid')">
<body onload="document.fonts.ready.then(() => { checkLayout('.grid'); })">

<div style="position: relative">
<p>direction: LTR | align-content: 'center'</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<script type="text/javascript">
setup({ explicit_done: true });
</script>

<body onload="checkLayout('.grid')">
<body onload="document.fonts.ready.then(() => { checkLayout('.grid'); })">

<p>This test checks that the 'margin', 'border' and 'padding' properties are applied together correctly for 'align' and 'justify' properties on vertical-LR grids.</p>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<script type="text/javascript">
setup({ explicit_done: true });
</script>

<body onload="checkLayout('.grid')">
<body onload="document.fonts.ready.then(() => { checkLayout('.grid'); })">

<p>This test checks that the 'margin', 'border' and 'padding' properties are applied together correctly for 'align' and 'justify' properties on vertical-RL grids.</p>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<script type="text/javascript">
setup({ explicit_done: true });
</script>

<body onload="checkLayout('.grid')">
<body onload="document.fonts.ready.then(() => { checkLayout('.grid'); })">

<p>This test checks that the 'margin', 'border' and 'padding' properties are applied together correctly for 'align' and 'justify' properties.</p>

Expand Down
5 changes: 4 additions & 1 deletion css/css-grid/alignment/grid-align-justify-overflow.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<script type="text/javascript">
setup({ explicit_done: true });
</script>

<body onload="checkLayout('.grid')">
<body onload="document.fonts.ready.then(() => { checkLayout('.grid'); })">

<p>This test checks that the 'overflow' keyword is applied correctly for 'align' and 'justify' properties.</p>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<script type="text/javascript">
setup({ explicit_done: true });
</script>

<body onload="checkLayout('.grid')">
<body onload="document.fonts.ready.then(() => { checkLayout('.grid'); })">

<p>This test checks that stretching alignment works as expected with orthogonal flows.</p>

Expand Down
5 changes: 4 additions & 1 deletion css/css-grid/alignment/grid-align-justify-stretch.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<script type="text/javascript">
setup({ explicit_done: true });
</script>

<body onload="checkLayout('.grid')">
<body onload="document.fonts.ready.then(() => { checkLayout('.grid'); })">

<div style="position: relative">
<div class="grid fit-content" data-expected-width="200" data-expected-height="400">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<script type="text/javascript">
setup({ explicit_done: true });
</script>

<body onload="checkLayout('.grid')">
<body onload="document.fonts.ready.then(() => { checkLayout('.grid'); })">

<p>This test checks that the alignment properties align-self and justify-self apply the 'stretch' value correctly on replaced elements.</p>

Expand Down
5 changes: 4 additions & 1 deletion css/css-grid/alignment/grid-align.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<script type="text/javascript">
setup({ explicit_done: true });
</script>

<body onload="checkLayout('.grid')">
<body onload="document.fonts.ready.then(() => { checkLayout('.grid'); })">

<div style="position: relative">
<div class="grid fit-content" data-expected-width="200" data-expected-height="400">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@
<script src="/resources/check-layout-th.js"></script>
<script src="support/style-change.js"></script>
<script>
setup({ explicit_done: true });
function runTest() {
evaluateStyleChange(item, "before", "data-expected-height", 200);
grid.style.alignItems = "start";
evaluateStyleChange(item, "after", "data-expected-height", 100);
done();
}
</script>
<body onload="runTest()">
<body onload="document.fonts.ready.then(() => { runTest(); })">
<div class="grid" id="grid">
<div data-expected-width="100" id="item">XX X<br>X XXX<br>X<br>XX XXX</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@
<script src="/resources/check-layout-th.js"></script>
<script src="support/style-change.js"></script>
<script>
setup({ explicit_done: true });
function runTest() {
evaluateStyleChange(item, "before", "data-expected-height", 100);
grid.style.alignItems = "stretch";
evaluateStyleChange(item, "after", "data-expected-height", 200);
done();
}
</script>
<body onload="runTest()">
<body onload="document.fonts.ready.then(() => { runTest(); })">
<div class="grid" id="grid">
<div data-expected-width="100" id="item">XX X<br>X XXX<br>X<br>XX XXX</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@
<script src="/resources/check-layout-th.js"></script>
<script src="support/style-change.js"></script>
<script>
setup({ explicit_done: true });
function runTest() {
evaluateStyleChange(item, "before", "data-expected-height", 200);
grid.style.alignItems = "normal";
evaluateStyleChange(item, "after", "data-expected-height", 200);
done();
}
</script>
<body onload="runTest()">
<body onload="document.fonts.ready.then(() => { runTest(); })">
<div class="grid" id="grid">
<div data-expected-width="100" id="item">XX X<br>X XXX<br>X<br>XX XXX</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@
<script src="/resources/check-layout-th.js"></script>
<script src="support/style-change.js"></script>
<script>
setup({ explicit_done: true });
function runTest() {
evaluateStyleChange(item, "before", "data-expected-height", 200);
grid.style.alignItems = "stretch";
evaluateStyleChange(item, "after", "data-expected-height", 200);
done();
}
</script>
<body onload="runTest()">
<body onload="document.fonts.ready.then(() => { runTest(); })">
<div class="grid" id="grid">
<div data-expected-width="100" id="item">XX X<br>X XXX<br>X<br>XX XXX</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@
<script src="/resources/check-layout-th.js"></script>
<script src="support/style-change.js"></script>
<script>
setup({ explicit_done: true });
function runTest() {
evaluateStyleChange(item, "before", "data-expected-height", 100);
grid.style.alignItems = "normal";
evaluateStyleChange(item, "after", "data-expected-height", 200);
done();
}
</script>
<body onload="runTest()">
<body onload="document.fonts.ready.then(() => { runTest(); })">
<div class="grid" id="grid">
<div data-expected-width="100" id="item">XX X<br>X XXX<br>X<br>XX XXX</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@
<script src="/resources/check-layout-th.js"></script>
<script src="support/style-change.js"></script>
<script>
setup({ explicit_done: true });
function runTest() {
evaluateStyleChange(item, "before", "data-expected-height", 200);
grid.style.alignItems = "start";
evaluateStyleChange(item, "after", "data-expected-height", 100);
done();
}
</script>
<body onload="runTest()">
<body onload="document.fonts.ready.then(() => { runTest(); })">
<div class="grid" id="grid">
<div data-expected-width="100" id="item">XX X<br>X XXX<br>X<br>XX XXX</div>
</div>
Expand Down
Loading

0 comments on commit ea0533f

Please sign in to comment.