From d5d62601976ba05cd854c32faebcd1f72b8d56b1 Mon Sep 17 00:00:00 2001 From: Stephen McGruer Date: Tue, 28 Jun 2022 11:44:10 +0000 Subject: [PATCH] Bug 1775316 [wpt PR 34508] - [SPC] Fix createCredentialForAltDomain, a=testonly Automatic update from web-platform-tests [SPC] Fix createCredentialForAltDomain (#34508) This was accidentally broken in 00f936932, but went unnoticed due to issue #33690 . Fixing the method 'fixes' the test authentication-cross-origin.sub.https.html, though it still fails due to the underlying issue #33690 -- wpt-commits: 70113ca5f42c66856b99b1ba50a0126e196d266f wpt-pr: 34508 --- .../secure-payment-confirmation/utils.sub.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/testing/web-platform/tests/secure-payment-confirmation/utils.sub.js b/testing/web-platform/tests/secure-payment-confirmation/utils.sub.js index 705de30bbd6f8..904f3d8d64812 100644 --- a/testing/web-platform/tests/secure-payment-confirmation/utils.sub.js +++ b/testing/web-platform/tests/secure-payment-confirmation/utils.sub.js @@ -64,7 +64,21 @@ async function createCredentialForAltDomain() { frame.src = 'https://{{hosts[alt][]}}:{{ports[https][0]}}' + '/secure-payment-confirmation/resources/iframe-enroll.html'; - return new Promise(resolve => { + // Wait for the iframe to load. + const readyPromise = new Promise(resolve => { + window.addEventListener('message', function handler(evt) { + if (evt.source === frame.contentWindow && evt.data.type == 'loaded') { + window.removeEventListener('message', handler); + + resolve(evt.data); + } + }); + }); + document.body.appendChild(frame); + await readyPromise; + + // Setup the result promise, and then trigger credential creation. + const resultPromise = new Promise(resolve => { window.addEventListener('message', function handler(evt) { if (evt.source === frame.contentWindow) { document.body.removeChild(frame); @@ -73,8 +87,9 @@ async function createCredentialForAltDomain() { resolve(evt.data); } }); - document.body.appendChild(frame); }); + frame.contentWindow.postMessage({ userActivation: true }, '*'); + return resultPromise; } function arrayBufferToString(buffer) {