Skip to content

Commit

Permalink
Fix timeout in svg-mouse-listener a11y test
Browse files Browse the repository at this point in the history
The recommended approach to make a crash test asynchronous is to use
reftest-wait. Unfortunately, test-driver does not work with ref-tests.
The fix is to pull the test out of crashtests and author as a promise
test.  This is the only a11y crash test that uses test-driver, and
thus, the only one that is affected.

The test needs to be asynchronous to avoid a memory leak. The reason is
due to the fact that we have armed an event listener that is never
triggered unless we wait. A crash-test only waits until onload is complete.

Bug: 328403023
Change-Id: If33410bd498995b8216e805c8edc27c093e3db1a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5348198
Reviewed-by: Aaron Leventhal <[email protected]>
Commit-Queue: Kevin Ellis <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1269156}
  • Loading branch information
kevers-google authored and chromium-wpt-export-bot committed Mar 6, 2024
1 parent fae30e9 commit fcb1f27
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 19 deletions.
19 changes: 0 additions & 19 deletions accessibility/crashtests/svg-mouse-listener.html

This file was deleted.

34 changes: 34 additions & 0 deletions accessibility/svg-mouse-listener.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!DOCTYPE html>
<html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<svg viewBox="0 0 500 500">
<rect width="500" height="500" id="target" fill="red">
</svg>

<script>
function clickPromise() {
return new Promise(resolve => {
document.getElementById("target").addEventListener("click", resolve,
{ once: true });
});
}

// While the other accessibility tests are crash-tests, this one cannot be
// authored as one. The reason is that a crash-test is complete when a onload
// is complete. The recommended strategy for supporting asynchronous testing
// is to use reftest wait. Unfortunately, reftests are not compatible with
// test-driver. The test needs to be asynchronous as unless we wait for the
// click to be handled, we are not giving the browser a chance to crash. In
// addition the lack of a wait triggers detection of a memory leak in Blink.
promise_test(async () => {
const click_promise = clickPromise();
await test_driver.click(document.body);
return click_promise;
}, 'Clicking SVG element does not crash the browser');

</script>
</html>

0 comments on commit fcb1f27

Please sign in to comment.