Skip to content

Commit 1a0b11f

Browse files
mfreed7chromium-wpt-export-bot
authored andcommitted
Fix a bug in test_driver.bless()
This code was previously doing this: let wait_click = new Promise(resolve => { button.addEventListener("click", resolve)); }; return test_driver.click(button) .then(wait_click) .then(... but the argument to `.then(wait_click)` isn't a function, it's the promise to return. Therefore .then() creates an already-resolved promise containing `wait_click` as its resolved value. Which the next `.then()` block ignores. So this wasn't actually waiting for the click to occur. This triggered a number of test bugs (caused by erroneous assumptions accidentally baked into the tests. I fixed a few, and filed a few bugs for the rest (after failing to figure out how to fix them). Note that the WPT version of testdriver.js is rolled into Chromium, so that change is being made here: #49691 Bug: 384009734,384050894 Change-Id: Ibdb8a97d23998ad89c5a48c23a7e780dc605283b
1 parent 0a38a00 commit 1a0b11f

File tree

3 files changed

+28
-27
lines changed

3 files changed

+28
-27
lines changed

fullscreen/rendering/backdrop-object.html

+8-7
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@
1111
background: blue;
1212
}
1313
</style>
14-
<object width="200" type="image/svg+xml" data="/images/100px-green-rect.svg"></object>
14+
<object width="200" type="image/svg+xml"></object>
15+
1516
<script>
1617
const object = document.querySelector("object");
17-
Promise.all([
18-
new Promise((resolve, reject) => document.addEventListener("fullscreenchange", resolve)),
19-
new Promise((resolve, reject) => object.addEventListener("load", resolve))
20-
]).then(() => document.documentElement.classList.remove('reftest-wait'));
21-
22-
test_driver.bless('fullscreen', () => object.requestFullscreen());
18+
test_driver.bless('fullscreen')
19+
.then(() => {object.data="/images/100px-green-rect.svg";})
20+
.then(() => new Promise((resolve) => object.addEventListener("load", resolve)))
21+
.then(() => object.requestFullscreen())
22+
.then(() => new Promise((resolve) => document.addEventListener("fullscreenchange", resolve)))
23+
.then(() => document.documentElement.classList.remove('reftest-wait'));
2324
</script>

html/semantics/forms/the-input-element/show-picker-user-gesture.html

+18-18
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,39 @@
55
<script src="/resources/testharnessreport.js"></script>
66
<script src="/resources/testdriver.js"></script>
77
<script src="/resources/testdriver-vendor.js"></script>
8-
<body></body>
8+
9+
<body>
910
<script type=module>
1011
import inputTypes from "./input-types.js";
1112

12-
for (const inputType of inputTypes) {
13-
test(() => {
14-
const input = document.createElement("input");
15-
input.setAttribute("type", inputType);
13+
// File pickers can't be closed.
14+
const types = inputTypes.filter((t) => t != 'file');
1615

16+
function createElement(t,type) {
17+
const input = document.createElement("input");
18+
input.setAttribute("type", type);
19+
document.body.appendChild(input);
20+
t.add_cleanup(() => input.remove());
21+
return input;
22+
}
23+
for (const inputType of types) {
24+
promise_test(async (t) => {
25+
const input = createElement(t,inputType);
1726
assert_throws_dom('NotAllowedError', () => { input.showPicker(); });
1827
}, `input[type=${inputType}] showPicker() requires a user gesture`);
19-
}
20-
21-
for (const inputType of inputTypes) {
22-
promise_test(async t => {
23-
const input = document.createElement("input");
24-
input.setAttribute("type", inputType);
2528

29+
promise_test(async (t) => {
30+
const input = createElement(t,inputType);
2631
await test_driver.bless('show picker');
2732
input.showPicker();
2833
input.blur();
2934
}, `input[type=${inputType}] showPicker() does not throw when user activation is active`);
30-
}
31-
32-
for (const inputType of inputTypes) {
33-
promise_test(async () => {
34-
const input = document.createElement('input');
35-
input.setAttribute('type', inputType);
3635

36+
promise_test(async (t) => {
37+
const input = createElement(t,inputType);
3738
await test_driver.bless('show picker');
3839
input.showPicker();
3940
input.blur();
40-
4141
assert_false(navigator.userActivation.isActive);
4242
}, `input[type=${inputType}] showPicker() consumes user activation`);
4343
}

resources/testdriver.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,8 @@
250250
let wait_click = new Promise(resolve => button.addEventListener("click", resolve));
251251

252252
return test_driver.click(button)
253-
.then(wait_click)
254-
.then(function() {
253+
.then(() => wait_click)
254+
.then(() => {
255255
button.remove();
256256

257257
if (typeof action === "function") {

0 commit comments

Comments
 (0)