Bug 1888258 [wpt PR 45388] - [FedCM] Always notify opener that we're done loading, a=testonly

Automatic update from web-platform-tests
[FedCM] Always notify opener that we're done loading

If FencedFrameConfig does not exist, we never send the
message to the opener.
That leads to a test timeout, which is unfortunate.

Instead, rearrange this code so that we always add the onload listener.

Noticed this while running
credential-management/fedcm-login-status/cross-origin-status.https.html

Bug: 331237776
Change-Id: Id47677cf591337c3a548c10e33ad29f56985d882
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5402337
Commit-Queue: Christian Biesinger <cbiesinger@chromium.org>
Reviewed-by: Nicolás Peña <npm@chromium.org>
Auto-Submit: Christian Biesinger <cbiesinger@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1279256}

--

wpt-commits: b313ed0b09d7b7aca6132707ff8fbec4a0e08890
wpt-pr: 45388
This commit is contained in:
Christian Biesinger 2024-03-28 21:43:16 +00:00 committed by moz-wptsync-bot
parent 903e102d23
commit ff086471c9

View File

@ -3,13 +3,17 @@
<fencedframe></fencedframe>
<script>
const url = new URL("mark_signedin", location.href);
document.querySelector("fencedframe").config = new FencedFrameConfig(url);
// If this page was opened as a popup, notify the opener when we are done loading.
if (window.opener) {
window.onload = function() {
window.opener.postMessage("done_loading", "*");
};
}
// This code is intentionally after the onload listener registration
// because it can throw if FencedFrameConfig is not defined. In that
// case, we still want to notify the opener to avoid a test timeout.
const url = new URL("mark_signedin", location.href);
document.querySelector("fencedframe").config = new FencedFrameConfig(url);
</script>