-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[🚀 Feature] [py]: Support FedCM commands for python #14710
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
6da9cd0
FedCM python implementation
navin772 729f2bd
set dialog.py methods to use webdriver methods
navin772 eca9892
fix implementation and unit tests
navin772 bd2b3f6
use webserver in tests
navin772 8ff195d
use a custom fedcm_webserver fixture to use the ExtendedHandler
navin772 10aa166
rename to `extended_webserver`
navin772 4df92a3
Merge branch 'SeleniumHQ:trunk' into py-fedcm
navin772 484b621
use `webserver`
navin772 1559f8f
Merge branch 'SeleniumHQ:trunk' into py-fedcm
navin772 c2f5115
move fedcm commands to a new `fedcm` namespace
navin772 f5d47fa
support both edge and chrome browser for fedcm
navin772 25d3431
fix tests as per new implementation
navin772 bfb5a42
remove old commented code
navin772 6ade5a8
Merge branch 'trunk' into py-fedcm
navin772 2a2772a
Merge branch 'trunk' into py-fedcm
navin772 9e52be8
remove mixin and implement in remote webdriver
navin772 b925513
fix python usage in docstrings
navin772 f86e3bf
Merge branch 'trunk' into py-fedcm
navin772 c2c4faf
move to `accept` and `dismiss` for dialog
navin772 229154e
Merge branch 'trunk' into py-fedcm
navin772 46302f3
update docs and remove duplicate methods
navin772 02f3ca9
Merge branch 'trunk' into py-fedcm
navin772 687813a
Merge branch 'trunk' into py-fedcm
navin772 a91eb5a
Merge branch 'trunk' into py-fedcm
VietND96 035f9d0
Merge branch 'trunk' into py-fedcm
VietND96 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,71 @@ | ||
| # 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. | ||
|
|
||
| from enum import Enum | ||
| from typing import Optional | ||
|
|
||
|
|
||
| class LoginState(Enum): | ||
| SIGN_IN = "SignIn" | ||
| SIGN_UP = "SignUp" | ||
|
|
||
|
|
||
| class Account: | ||
| """Represents an account displayed in a FedCM account list. | ||
|
|
||
| See: https://w3c-fedid.github.io/FedCM/#dictdef-identityprovideraccount | ||
| https://w3c-fedid.github.io/FedCM/#webdriver-accountlist | ||
| """ | ||
|
|
||
| def __init__(self, account_data): | ||
| self._account_data = account_data | ||
|
|
||
| @property | ||
| def account_id(self) -> Optional[str]: | ||
| return self._account_data.get("accountId") | ||
|
|
||
| @property | ||
| def email(self) -> Optional[str]: | ||
| return self._account_data.get("email") | ||
|
|
||
| @property | ||
| def name(self) -> Optional[str]: | ||
| return self._account_data.get("name") | ||
|
|
||
| @property | ||
| def given_name(self) -> Optional[str]: | ||
| return self._account_data.get("givenName") | ||
|
|
||
| @property | ||
| def picture_url(self) -> Optional[str]: | ||
| return self._account_data.get("pictureUrl") | ||
|
|
||
| @property | ||
| def idp_config_url(self) -> Optional[str]: | ||
| return self._account_data.get("idpConfigUrl") | ||
|
|
||
| @property | ||
| def terms_of_service_url(self) -> Optional[str]: | ||
| return self._account_data.get("termsOfServiceUrl") | ||
|
|
||
| @property | ||
| def privacy_policy_url(self) -> Optional[str]: | ||
| return self._account_data.get("privacyPolicyUrl") | ||
|
|
||
| @property | ||
| def login_state(self) -> Optional[str]: | ||
| return self._account_data.get("loginState") |
This file contains hidden or 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,64 @@ | ||
| # 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. | ||
|
|
||
| from typing import List | ||
| from typing import Optional | ||
|
|
||
| from .account import Account | ||
|
|
||
|
|
||
| class Dialog: | ||
| """Represents a FedCM dialog that can be interacted with.""" | ||
|
|
||
| DIALOG_TYPE_ACCOUNT_LIST = "AccountChooser" | ||
| DIALOG_TYPE_AUTO_REAUTH = "AutoReauthn" | ||
|
|
||
| def __init__(self, driver) -> None: | ||
| self._driver = driver | ||
|
|
||
| @property | ||
| def type(self) -> Optional[str]: | ||
| """Gets the type of the dialog currently being shown.""" | ||
| return self._driver.fedcm.dialog_type | ||
|
|
||
| @property | ||
| def title(self) -> str: | ||
| """Gets the title of the dialog.""" | ||
| return self._driver.fedcm.title | ||
|
|
||
| @property | ||
| def subtitle(self) -> Optional[str]: | ||
| """Gets the subtitle of the dialog.""" | ||
| result = self._driver.fedcm.subtitle | ||
| return result.get("subtitle") if result else None | ||
|
|
||
| def get_accounts(self) -> List[Account]: | ||
| """Gets the list of accounts shown in the dialog.""" | ||
| accounts = self._driver.fedcm.account_list | ||
| return [Account(account) for account in accounts] | ||
|
|
||
| def select_account(self, index: int) -> None: | ||
| """Selects an account from the dialog by index.""" | ||
| self._driver.fedcm.select_account(index) | ||
|
|
||
| def accept(self) -> None: | ||
| """Clicks the continue button in the dialog.""" | ||
| self._driver.fedcm.accept() | ||
|
|
||
| def dismiss(self) -> None: | ||
| """Cancels/dismisses the dialog.""" | ||
| self._driver.fedcm.dismiss() |
This file contains hidden or 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 hidden or 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 hidden or 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,70 @@ | ||
| # 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. | ||
|
|
||
| from typing import List | ||
| from typing import Optional | ||
|
|
||
| from .command import Command | ||
|
|
||
|
|
||
| class FedCM: | ||
| def __init__(self, driver) -> None: | ||
| self._driver = driver | ||
|
|
||
| @property | ||
| def title(self) -> str: | ||
| """Gets the title of the dialog.""" | ||
| return self._driver.execute(Command.GET_FEDCM_TITLE)["value"].get("title") | ||
|
|
||
| @property | ||
| def subtitle(self) -> Optional[str]: | ||
| """Gets the subtitle of the dialog.""" | ||
| return self._driver.execute(Command.GET_FEDCM_TITLE)["value"].get("subtitle") | ||
|
|
||
| @property | ||
| def dialog_type(self) -> str: | ||
| """Gets the type of the dialog currently being shown.""" | ||
| return self._driver.execute(Command.GET_FEDCM_DIALOG_TYPE).get("value") | ||
|
|
||
| @property | ||
| def account_list(self) -> List[dict]: | ||
| """Gets the list of accounts shown in the dialog.""" | ||
| return self._driver.execute(Command.GET_FEDCM_ACCOUNT_LIST).get("value") | ||
|
|
||
| def select_account(self, index: int) -> None: | ||
| """Selects an account from the dialog by index.""" | ||
| self._driver.execute(Command.SELECT_FEDCM_ACCOUNT, {"accountIndex": index}) | ||
|
|
||
| def accept(self) -> None: | ||
| """Clicks the continue button in the dialog.""" | ||
| self._driver.execute(Command.CLICK_FEDCM_DIALOG_BUTTON, {"dialogButton": "ConfirmIdpLoginContinue"}) | ||
|
|
||
| def dismiss(self) -> None: | ||
| """Cancels/dismisses the FedCM dialog.""" | ||
| self._driver.execute(Command.CANCEL_FEDCM_DIALOG) | ||
|
|
||
| def enable_delay(self) -> None: | ||
| """Re-enables the promise rejection delay for FedCM.""" | ||
| self._driver.execute(Command.SET_FEDCM_DELAY, {"enabled": True}) | ||
|
|
||
| def disable_delay(self) -> None: | ||
| """Disables the promise rejection delay for FedCM.""" | ||
| self._driver.execute(Command.SET_FEDCM_DELAY, {"enabled": False}) | ||
|
|
||
| def reset_cooldown(self) -> None: | ||
| """Resets the FedCM dialog cooldown, allowing immediate retriggers.""" | ||
| self._driver.execute(Command.RESET_FEDCM_COOLDOWN) |
This file contains hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.