forked from SeleniumHQ/selenium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[js] Add Federated Credential Management support (SeleniumHQ#15008)
- Loading branch information
Showing
9 changed files
with
413 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>FedCM Example</title> | ||
</head> | ||
<body> | ||
<button id="triggerButton" onclick="triggerFedCm()">Trigger FedCM</button> | ||
<div id="result"></div> | ||
|
||
<script> | ||
// Use a relative path for the configURL | ||
let configURL = `http://${location.host}/common/fedcm/config.json`; | ||
console.log(configURL) | ||
let result = null; | ||
|
||
async function triggerFedCm() { | ||
console.log("Config URL:", configURL); | ||
try { | ||
let promise = await navigator.credentials.get({ | ||
identity: { | ||
providers: [{ | ||
configURL: configURL, | ||
clientId: '1', | ||
}] | ||
} | ||
}); | ||
result = promise; | ||
|
||
console.log("Promised!") | ||
console.log(result) | ||
document.getElementById('result').innerText = JSON.stringify(result); | ||
} catch (error) { | ||
console.error("FedCM Error:", error); | ||
result = { error: error.message }; | ||
document.getElementById('result').innerText = JSON.stringify(result); | ||
} | ||
} | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// Licensed to the Software Freedom Conservancy (SFC) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
class Account { | ||
constructor( | ||
accountId, | ||
email, | ||
name, | ||
givenName, | ||
pictureUrl, | ||
idpConfigUrl, | ||
loginState, | ||
termsOfServiceUrl, | ||
privacyPolicyUrl, | ||
) { | ||
this._accountId = accountId | ||
this._email = email | ||
this._name = name | ||
this._givenName = givenName | ||
this._pictureUrl = pictureUrl | ||
this._idpConfigUrl = idpConfigUrl | ||
this._loginState = loginState | ||
this._termsOfServiceUrl = termsOfServiceUrl | ||
this._privacyPolicyUrl = privacyPolicyUrl | ||
} | ||
|
||
get accountId() { | ||
return this._accountId | ||
} | ||
|
||
get email() { | ||
return this._email | ||
} | ||
|
||
get name() { | ||
return this._name | ||
} | ||
|
||
get givenName() { | ||
return this._givenName | ||
} | ||
|
||
get pictureUrl() { | ||
return this._pictureUrl | ||
} | ||
|
||
get idpConfigUrl() { | ||
return this._idpConfigUrl | ||
} | ||
|
||
get loginState() { | ||
return this._loginState | ||
} | ||
|
||
get termsOfServiceUrl() { | ||
return this._termsOfServiceUrl | ||
} | ||
|
||
get privacyPolicyUrl() { | ||
return this._privacyPolicyUrl | ||
} | ||
} | ||
|
||
module.exports = Account |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// Licensed to the Software Freedom Conservancy (SFC) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
const command = require('../command') | ||
const Account = require('./account') | ||
|
||
class Dialog { | ||
constructor(driver) { | ||
this._driver = driver | ||
} | ||
|
||
async title() { | ||
const result = await this._driver.execute(new command.Command(command.Name.GET_FEDCM_TITLE)) | ||
|
||
return result.title | ||
} | ||
|
||
subtitle() { | ||
return this._driver.execute(new command.Command(command.Name.GET_FEDCM_TITLE)) | ||
} | ||
|
||
type() { | ||
return this._driver.execute(new command.Command(command.Name.GET_FEDCM_DIALOG_TYPE)) | ||
} | ||
|
||
async accounts() { | ||
const result = await this._driver.execute(new command.Command(command.Name.GET_ACCOUNTS)) | ||
|
||
const accountArray = [] | ||
|
||
result.forEach((account) => { | ||
const acc = new Account( | ||
account.accountId, | ||
account.email, | ||
account.name, | ||
account.givenName, | ||
account.pictureUrl, | ||
account.idpConfigUrl, | ||
account.loginState, | ||
account.termsOfServiceUrl, | ||
account.privacyPolicyUrl, | ||
) | ||
accountArray.push(acc) | ||
}) | ||
|
||
return accountArray | ||
} | ||
|
||
selectAccount(index) { | ||
return this._driver.execute(new command.Command(command.Name.SELECT_ACCOUNT).setParameter('accountIndex', index)) | ||
} | ||
|
||
accept() { | ||
return this._driver.execute(new command.Command(command.Name.CLICK_DIALOG_BUTTON)) | ||
} | ||
|
||
dismiss() { | ||
return this._driver.execute(new command.Command(command.Name.CANCEL_DIALOG)) | ||
} | ||
} | ||
|
||
module.exports = Dialog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.