initial commit

This commit is contained in:
2026-06-25 21:29:21 +00:00
commit 0d0a7456de
2738 changed files with 542622 additions and 0 deletions
@@ -0,0 +1,16 @@
# 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.
@@ -0,0 +1,55 @@
# 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
class LoginState(Enum):
SIGN_IN = "SignIn"
SIGN_UP = "SignUp"
class _AccountDescriptor:
def __init__(self, name):
self.name = name
def __get__(self, obj, cls) -> str | None:
return obj._account_data.get(self.name)
def __set__(self, obj, value) -> None:
raise AttributeError("Cannot set readonly attribute")
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
"""
account_id = _AccountDescriptor("accountId")
email = _AccountDescriptor("email")
name = _AccountDescriptor("name")
given_name = _AccountDescriptor("givenName")
picture_url = _AccountDescriptor("pictureUrl")
idp_config_url = _AccountDescriptor("idpConfigUrl")
terms_of_service_url = _AccountDescriptor("termsOfServiceUrl")
privacy_policy_url = _AccountDescriptor("privacyPolicyUrl")
login_state = _AccountDescriptor("loginState")
def __init__(self, account_data):
self._account_data = account_data
@@ -0,0 +1,62 @@
# 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 selenium.webdriver.common.fedcm.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) -> str | None:
"""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) -> str | None:
"""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()