Skip to content

Commit

Permalink
Bug 1775316 [wpt PR 34508] - [SPC] Fix createCredentialForAltDomain, …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
stephenmcgruer authored and moz-wptsync-bot committed Jun 29, 2022
1 parent a3f9786 commit d5d6260
Showing 1 changed file with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -73,8 +87,9 @@ async function createCredentialForAltDomain() {
resolve(evt.data);
}
});
document.body.appendChild(frame);
});
frame.contentWindow.postMessage({ userActivation: true }, '*');
return resultPromise;
}

function arrayBufferToString(buffer) {
Expand Down

0 comments on commit d5d6260

Please sign in to comment.