Skip to content

Commit

Permalink
[wpt] Fix testdriver.js portability issues in digital-credentials/
Browse files Browse the repository at this point in the history
Some testdriver.js implementations use `postMessage()` to send
testdriver commands from a cross-origin iframe to the testharness
browsing context. [0] and [1] must be respected for testdriver.js to
work in those environments.

This is a no-op change when running the tests with content shell, which
implements testdriver.js with nonstandard JS bindings.

[0]: https://web-platform-tests.org/writing-tests/testdriver.html#using-test-driver-in-other-browsing-contexts
[1]: https://web-platform-tests.org/writing-tests/testdriver.html#markup:

> The testdriver.js and testdriver-vendor.js must both be included ...
> in the top-level test document when using testdriver from a different
> context

Bug: None
Change-Id: Idacd0b65d03d4feb77883927a5d90e61eb59797b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5922668
Reviewed-by: Weizhong Xia <weizhong@google.com>
Commit-Queue: Jonathan Lee <jonathanjlee@google.com>
Cr-Commit-Position: refs/heads/main@{#1370211}
  • Loading branch information
jonathan-j-lee authored and chromium-wpt-export-bot committed Oct 17, 2024
1 parent 9356370 commit f29200e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions digital-credentials/allow-attribute.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<script src="/common/get-host-info.sub.js"></script>
<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>
const hostInfo = get_host_info();
const iframeDetails = [
Expand Down
1 change: 1 addition & 0 deletions digital-credentials/support/iframe.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,6 @@
}
}

test_driver.set_test_context(parent);
window.addEventListener("message", messageListener);
</script>
1 change: 1 addition & 0 deletions permissions-policy/resources/digital-credentials-get.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
window.parent.postMessage({ type, enabled }, "*");
}
}
test_driver.set_test_context(parent);
window.onload = notify;
</script>
<body>
Expand Down

0 comments on commit f29200e

Please sign in to comment.