fedcm-identity-discovery.tentative.sub.https.html (6044B)
1 <!doctype html> 2 <head> 3 <title>Test discovery of 'identity' credentials</title> 4 </head> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <script src="/resources/testdriver.js"></script> 8 <script src="/resources/testdriver-vendor.js"></script> 9 <script src="../support/lfedcm-helpers.js"></script> 10 <script type="module"> 11 'use strict'; 12 13 import {fedcm_select_account_promise} from '../support/fedcm-helper.sub.js'; 14 15 promise_test(async t => { 16 let getCredentialPromise, credentialGotten; 17 18 await test_driver.bless(); 19 getCredentialPromise = navigator.credentials.get({identity: {providers: [{origin: "https://{{hosts[alt][]}}:{{ports[https][0]}}/", loginURL : `https://{{hosts[alt][]}}:{{ports[https][0]}}/fedcm/support/lfedcm-identity.provider-create.sub.html?id=wpt-pick-me&origin=${encodeURIComponent("https://{{hosts[][]}}:{{ports[https][0]}}/")}&close=true`, loginTarget : "popup"}]}}); 20 credentialGotten = await getCredentialPromise; 21 fedcm_select_account_promise(t, 0); 22 assert_not_equals(credentialGotten, null, "A discovered credential is returned from the CredentialContainer."); 23 24 await clearLightweightCredential("https://{{hosts[alt][]}}:{{ports[https][0]}}", "wpt-pick-me"); 25 }, "Cross-origin identity credential discovery works"); 26 27 promise_test(async t => { 28 let getCredentialPromise, credentialGotten; 29 30 await test_driver.bless(); 31 getCredentialPromise = navigator.credentials.get({identity: {providers: [{loginURL : `https://{{hosts[alt][]}}:{{ports[https][0]}}/fedcm/support/lfedcm-identity.provider-create.sub.html?id=wpt-pick-me&origin=${encodeURIComponent("https://{{hosts[][]}}:{{ports[https][0]}}/")}&close=true`, loginTarget : "popup"}]}}); 32 fedcm_select_account_promise(t, 0); 33 credentialGotten = await getCredentialPromise; 34 assert_not_equals(credentialGotten, null, "A discovered credential is returned from the CredentialContainer."); 35 36 await clearLightweightCredential("https://{{hosts[alt][]}}:{{ports[https][0]}}", "wpt-pick-me"); 37 }, "Origin inferred from loginURL for discovery"); 38 39 promise_test(async t => { 40 let getCredentialPromise, credentialGotten; 41 42 await test_driver.bless(); 43 getCredentialPromise = navigator.credentials.get({identity: {providers: [{origin: "https://{{hosts[alt][]}}:{{ports[https][0]}}/", loginURL : `https://{{hosts[alt][]}}:{{ports[https][0]}}/fedcm/support/lfedcm-identity.provider-create.sub.html?id=wpt-pick-me&url=cors&close=true`, loginTarget : "popup", effectiveQueryURL: "https://{{hosts[alt][]}}:{{ports[https][0]}}/fedcm/support/acao-cors.py"}]}}); 44 fedcm_select_account_promise(t, 0); 45 credentialGotten = await getCredentialPromise; 46 assert_not_equals(credentialGotten, null, "A discovered credential is returned from the CredentialContainer."); 47 48 await clearLightweightCredential("https://{{hosts[alt][]}}:{{ports[https][0]}}", "wpt-pick-me"); 49 }, "Cross-origin identity credential discovery works using the effectiveQueryURL"); 50 51 promise_test(async t => { 52 let getCredentialPromise, credentialGotten; 53 54 let createdPromise = new Promise((resolve) => { 55 window.addEventListener( 56 "message", 57 (event) => { 58 if (event.data == "created") { 59 resolve(); 60 } 61 } 62 ); 63 }); 64 65 await test_driver.bless(); 66 let state = "pending"; 67 getCredentialPromise = navigator.credentials.get({identity: {providers: [{origin: "https://{{hosts[alt][]}}:{{ports[https][0]}}/", loginURL : `https://{{hosts[alt][]}}:{{ports[https][0]}}/fedcm/support/lfedcm-identity.provider-create.sub.html?id=wpt-pick-me&postMessage&origin=${encodeURIComponent("https://{{hosts[alt][]}}:{{ports[https][0]}}/")}&close=true`, loginTarget : "popup"}]}}); 68 getCredentialPromise.finally(() => {state = "fulfilled"}); 69 await createdPromise; 70 assert_equals(state, "pending", "promise is not fulfilled during discovery window by get."); 71 72 window.open(`https://{{hosts[alt][]}}:{{ports[https][0]}}/fedcm/support/lfedcm-identity.provider-create.sub.html?id=wpt-pick-me&origin=${encodeURIComponent("https://{{hosts[][]}}:{{ports[https][0]}}/")}&close=true`); 73 fedcm_select_account_promise(t, 0); 74 credentialGotten = await getCredentialPromise; 75 76 assert_not_equals(credentialGotten, null, "Resolved with credential because the credential was stored."); 77 78 await clearLightweightCredential("https://{{hosts[alt][]}}:{{ports[https][0]}}", "wpt-pick-me"); 79 }, "Cross-origin identity credential discovery does not resolve with ineffective store from the right origin"); 80 81 82 promise_test(async t => { 83 let getCredentialPromise, credentialGotten; 84 85 let createdPromise = new Promise((resolve) => { 86 window.addEventListener( 87 "message", 88 (event) => { 89 if (event.data == "created") { 90 resolve(); 91 } 92 } 93 ); 94 }); 95 96 await test_driver.bless(); 97 let state = "pending"; 98 getCredentialPromise = navigator.credentials.get({identity: {providers: [{origin: "https://{{hosts[alt][]}}:{{ports[https][0]}}/", loginURL : `https://{{hosts[alt][www]}}:{{ports[https][0]}}/fedcm/support/lfedcm-identity.provider-create.sub.html?id=wpt-pick-me&postMessage&origin=${encodeURIComponent("https://{{hosts[][]}}:{{ports[https][0]}}/")}&close=true`, loginTarget : "popup"}]}}); 99 getCredentialPromise.finally(() => {state = "fulfilled"}); 100 await createdPromise; 101 assert_equals(state, "pending", "promise is not fulfilled during discovery window by get."); 102 103 window.open(`https://{{hosts[alt][]}}:{{ports[https][0]}}/fedcm/support/lfedcm-identity.provider-create.sub.html?id=wpt-pick-me&origin=${encodeURIComponent("https://{{hosts[][]}}:{{ports[https][0]}}")}&close=true`); 104 credentialGotten = await getCredentialPromise; 105 fedcm_select_account_promise(t, 0); 106 assert_not_equals(credentialGotten, null, "Resolved with credential because the credential was stored."); 107 108 await clearLightweightCredential("https://{{hosts[alt][]}}:{{ports[https][0]}}", "wpt-pick-me"); 109 }, "Cross-origin identity credential discovery does not resolve with effective store from the wrong origin"); 110 111 </script>