Skip to content

Commit

Permalink
Fix a bug in test_driver.bless()
Browse files Browse the repository at this point in the history
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
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6094526
Reviewed-by: Jonathan Lee <[email protected]>
Auto-Submit: Mason Freed <[email protected]>
Commit-Queue: Mason Freed <[email protected]>
Commit-Queue: Jonathan Lee <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1397010}
  • Loading branch information
mfreed7 authored and chromium-wpt-export-bot committed Dec 16, 2024
1 parent 0a38a00 commit 61bf26b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 27 deletions.
15 changes: 8 additions & 7 deletions fullscreen/rendering/backdrop-object.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@
background: blue;
}
</style>
<object width="200" type="image/svg+xml" data="/images/100px-green-rect.svg"></object>
<object width="200" type="image/svg+xml"></object>

<script>
const object = document.querySelector("object");
Promise.all([
new Promise((resolve, reject) => document.addEventListener("fullscreenchange", resolve)),
new Promise((resolve, reject) => object.addEventListener("load", resolve))
]).then(() => document.documentElement.classList.remove('reftest-wait'));

test_driver.bless('fullscreen', () => object.requestFullscreen());
test_driver.bless('fullscreen')
.then(() => {object.data="/images/100px-green-rect.svg";})
.then(() => new Promise((resolve) => object.addEventListener("load", resolve)))
.then(() => object.requestFullscreen())
.then(() => new Promise((resolve) => document.addEventListener("fullscreenchange", resolve)))
.then(() => document.documentElement.classList.remove('reftest-wait'));
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,39 @@
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<body></body>

<body>
<script type=module>
import inputTypes from "./input-types.js";

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

function createElement(t,type) {
const input = document.createElement("input");
input.setAttribute("type", type);
document.body.appendChild(input);
t.add_cleanup(() => input.remove());
return input;
}
for (const inputType of types) {
promise_test(async (t) => {
const input = createElement(t,inputType);
assert_throws_dom('NotAllowedError', () => { input.showPicker(); });
}, `input[type=${inputType}] showPicker() requires a user gesture`);
}

for (const inputType of inputTypes) {
promise_test(async t => {
const input = document.createElement("input");
input.setAttribute("type", inputType);

promise_test(async (t) => {
const input = createElement(t,inputType);
await test_driver.bless('show picker');
input.showPicker();
input.blur();
}, `input[type=${inputType}] showPicker() does not throw when user activation is active`);
}

for (const inputType of inputTypes) {
promise_test(async () => {
const input = document.createElement('input');
input.setAttribute('type', inputType);

promise_test(async (t) => {
const input = createElement(t,inputType);
await test_driver.bless('show picker');
input.showPicker();
input.blur();

assert_false(navigator.userActivation.isActive);
}, `input[type=${inputType}] showPicker() consumes user activation`);
}
Expand Down
4 changes: 2 additions & 2 deletions resources/testdriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@
let wait_click = new Promise(resolve => button.addEventListener("click", resolve));

return test_driver.click(button)
.then(wait_click)
.then(function() {
.then(() => wait_click)
.then(() => {
button.remove();

if (typeof action === "function") {
Expand Down

0 comments on commit 61bf26b

Please sign in to comment.