Skip to content

Commit

Permalink
[html] Refactor tests (#19918)
Browse files Browse the repository at this point in the history
testharness.js was recently extended with an API to explicitly opt-in to
the "single page test" feature [1]. As per WPT RFC 28 [2], tests which
do not use this API and which do not declare any subtests will soon be
reported as a harness error.

Update some tests which previously opted in implicitly to use the new
API. Update others to instead declare a single subtest (so that they are
no longer single-page tests).

[1] #19449
[2] https://github.com/web-platform-tests/rfcs/blob/master/rfcs/single_test.md
  • Loading branch information
jugglinmike committed Oct 29, 2019
1 parent fa4d010 commit efe71da
Show file tree
Hide file tree
Showing 25 changed files with 47 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<div id=log></div>
<iframe></iframe>
<script>
setup({ single_test: true });
onload = function() {
var fr = document.querySelector("iframe")
fr.contentWindow.location = "support/dummy.html"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<div id=log></div>
<iframe></iframe>
<script>
setup({ single_test: true });
onload = function() {
var fr = document.querySelector("iframe")
fr.src = "about:blank"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
<script>
"use strict";

const input = document.querySelector("input");
test(() => {
const input = document.querySelector("input");

assert_equals(document.activeElement, document.body);
assert_not_equals(document.activeElement, input);

done();
assert_equals(document.activeElement, document.body);
assert_not_equals(document.activeElement, input);
});
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
</style>
<dialog open id=dialog></dialog>
<script>
assert_equals(getComputedStyle(document.getElementById('dialog')).display, 'block');
done();
test(function() {
assert_equals(getComputedStyle(document.getElementById('dialog')).display, 'block');
});
</script>
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var testStyle = getComputedStyle(document.getElementById('test'));
var refStyle = getComputedStyle(document.getElementById('ref'));
for (var prop in testStyle) {
assert_equals(testStyle[prop], refStyle[prop], prop);
}
done();
test(function() {
var testStyle = getComputedStyle(document.getElementById('test'));
var refStyle = getComputedStyle(document.getElementById('ref'));
for (var prop in testStyle) {
assert_equals(testStyle[prop], refStyle[prop], prop);
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
<table vspace=25 hspace=25><tr><td>x</table>
<div>x</div>
<script>
var style = getComputedStyle(document.querySelector('table'));
['marginTop', 'marginRight', 'marginBottom', 'marginLeft'].forEach(function(m) {
assert_equals(style[m], '0px', m);
test(function() {
var style = getComputedStyle(document.querySelector('table'));
['marginTop', 'marginRight', 'marginBottom', 'marginLeft'].forEach(function(m) {
assert_equals(style[m], '0px', m);
});
});
done();
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
<table vspace=25 hspace=25><tr><td>x</table>
<div>x</div> <!-- prevent margin collapsing quirks -->
<script>
var style = getComputedStyle(document.querySelector('table'));
['marginTop', 'marginRight', 'marginBottom', 'marginLeft'].forEach(function(m) {
assert_equals(style[m], '0px', m);
test(function() {
var style = getComputedStyle(document.querySelector('table'));
['marginTop', 'marginRight', 'marginBottom', 'marginLeft'].forEach(function(m) {
assert_equals(style[m], '0px', m);
});
});
done();
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<script src="/resources/testharnessreport.js"></script>
<iframe src="/common/blank.html" marginwidth=0 marginheight=0></iframe>
<script>
setup({ single_test: true });
onload = () => {
assert_equals(window[0].document.body.attributes.length, 0, "Number of attributes on the child document's body");
done();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

<script>
"use strict";
setup({ single_test: true });

const sourceIFrame = document.createElement("iframe");
sourceIFrame.setAttribute("sandbox", "allow-same-origin");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

<script>
"use strict";
setup({ single_test: true });

const sourceIFrame = document.createElement("iframe");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

<script>
"use strict";
setup({ single_test: true });

const iframe = document.createElement("iframe");
let loadCount = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<div id="log"></div>
<script>
"use strict";
setup({ single_test: true });

const iframe = document.createElement("iframe");
iframe.src = "support/ufoo";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

<script>
"use strict";
setup({ single_test: true });

const sourceIFrame = document.createElement("iframe");
let sourceLoadCount = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<script src="/common/media.js"></script>
<div id="log"></div>
<script>
setup({ single_test: true });
// https://html.spec.whatwg.org/#ready-states says:
//
// HAVE_FUTURE_DATA: "the text tracks are ready".
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<iframe src="about:blank"></iframe>
<div id="target"></div>
<script>
setup({ single_test: true });
onload = function() {
var ifr = document.getElementsByTagName('iframe')[0];
ifr.contentDocument.body.appendChild(ifr.contentDocument.createElement('p')).textContent = 'Modified document';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<iframe src="about:blank"></iframe>
<div id="target"></div>
<script>
setup({ single_test: true });
onload = function() {
var ifr = document.getElementsByTagName('iframe')[0];
ifr.contentDocument.open();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<iframe src="support/blank.htm"></iframe>
<div id="target"></div>
<script>
setup({ single_test: true });
onload = function() {
var ifr = document.getElementsByTagName('iframe')[0];
ifr.contentDocument.body.appendChild(ifr.contentDocument.createElement('p')).textContent = 'Modified document';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<iframe src="support/blank.htm"></iframe>
<div id="target"></div>
<script>
setup({ single_test: true });
onload = function(){
var ifr = document.getElementsByTagName('iframe')[0];
ifr.contentDocument.open();
Expand Down
2 changes: 2 additions & 0 deletions html/semantics/embedded-content/the-img-element/data-url.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
setup({ single_test: true });

var c = document.createElement("canvas"),
con = c.getContext("2d"),
img = document.createElement("img")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
setup({explicit_done:true});
setup({single_test:true});
const image_was_loaded = () => {
const iframe = document.getElementById("iframe");
// Resize the iframe
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<script src="/resources/testharnessreport.js"></script>
<p id="display"><img src="image.png"></p>
<script>
setup({ single_test: true });

function check() {
var img = document.querySelector("img");
assert_true(img.complete, "By onload, image should have loaded");
Expand Down
1 change: 1 addition & 0 deletions html/webappapis/timers/negative-setinterval.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
setup({ single_test: true });
var i = 0;
var interval;
function next() {
Expand Down
1 change: 1 addition & 0 deletions html/webappapis/timers/negative-settimeout.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
setup({ single_test: true });
setTimeout(done, -100);
setTimeout(assert_unreached, 10);
</script>
1 change: 1 addition & 0 deletions html/webappapis/timers/type-long-setinterval.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
setup({ single_test: true });
var interval;
function next() {
clearInterval(interval);
Expand Down
1 change: 1 addition & 0 deletions html/webappapis/timers/type-long-settimeout.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
setup({ single_test: true });
setTimeout(done, Math.pow(2, 32));
setTimeout(assert_unreached, 100);
</script>

0 comments on commit efe71da

Please sign in to comment.