Path: blob/trunk/py/test/selenium/webdriver/common/fedcm_tests.py
1865 views
# Licensed to the Software Freedom Conservancy (SFC) under one1# or more contributor license agreements. See the NOTICE file2# distributed with this work for additional information3# regarding copyright ownership. The SFC licenses this file4# to you under the Apache License, Version 2.0 (the5# "License"); you may not use this file except in compliance6# with the License. You may obtain a copy of the License at7#8# http://www.apache.org/licenses/LICENSE-2.09#10# Unless required by applicable law or agreed to in writing,11# software distributed under the License is distributed on an12# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY13# KIND, either express or implied. See the License for the14# specific language governing permissions and limitations15# under the License.1617import pytest1819from selenium.common.exceptions import NoAlertPresentException202122@pytest.mark.xfail_safari(reason="FedCM not supported")23@pytest.mark.xfail_chrome(reason="https://issues.chromium.org/u/0/issues/425801332")24@pytest.mark.xfail_firefox(reason="FedCM not supported")25@pytest.mark.xfail_ie(reason="FedCM not supported")26@pytest.mark.xfail_remote(reason="FedCM not supported, since remote uses Firefox")27class TestFedCM:28@pytest.fixture(autouse=True)29def setup(self, driver, webserver):30driver.get(webserver.where_is("fedcm/fedcm.html", localhost=True))31self.dialog = driver.dialog3233def test_no_dialog_title(driver):34with pytest.raises(NoAlertPresentException):35driver.dialog.title3637def test_no_dialog_subtitle(driver):38with pytest.raises(NoAlertPresentException):39driver.dialog.subtitle4041def test_no_dialog_type(driver):42with pytest.raises(NoAlertPresentException):43driver.dialog.type4445def test_no_dialog_get_accounts(driver):46with pytest.raises(NoAlertPresentException):47driver.dialog.get_accounts()4849def test_no_dialog_select_account(driver):50with pytest.raises(NoAlertPresentException):51driver.dialog.select_account(1)5253def test_no_dialog_cancel(driver):54with pytest.raises(NoAlertPresentException):55driver.dialog.dismiss()5657def test_no_dialog_click_continue(driver):58with pytest.raises(NoAlertPresentException):59driver.dialog.accept()6061def test_trigger_and_verify_dialog_title(self, driver):62driver.execute_script("triggerFedCm();")63dialog = driver.fedcm_dialog()64assert dialog.title == "Sign in to localhost with localhost"65dialog.dismiss()6667def test_trigger_and_verify_dialog_subtitle(self, driver):68driver.execute_script("triggerFedCm();")69dialog = driver.fedcm_dialog()70assert dialog.subtitle is None71dialog.dismiss()7273def test_trigger_and_verify_dialog_type(self, driver):74driver.execute_script("triggerFedCm();")75dialog = driver.fedcm_dialog()76assert dialog.type == "AccountChooser"77dialog.dismiss()7879def test_trigger_and_verify_account_list(self, driver):80driver.execute_script("triggerFedCm();")81dialog = driver.fedcm_dialog()82accounts = dialog.get_accounts()83assert len(accounts) > 084assert accounts[0].name == "John Doe"85dialog.dismiss()8687def test_select_account(self, driver):88driver.execute_script("triggerFedCm();")89dialog = driver.fedcm_dialog()90dialog.select_account(1)91driver.fedcm_dialog() # Wait for dialog to become interactable92# dialog.click_continue()93dialog.dismiss()9495def test_dialog_cancel(self, driver):96driver.execute_script("triggerFedCm();")97dialog = driver.fedcm_dialog()98dialog.dismiss()99with pytest.raises(NoAlertPresentException):100dialog.title101102def test_enable_fedcm_delay(self, driver):103driver.fedcm.enable_delay()104105def test_disable_fedcm_delay(self, driver):106driver.fedcm.disable_delay()107108def test_fedcm_cooldown_reset(self, driver):109driver.fedcm.reset_cooldown()110111def test_fedcm_no_dialog_type_present(self, driver):112with pytest.raises(NoAlertPresentException):113driver.fedcm.dialog_type114115def test_fedcm_no_title_present(self, driver):116with pytest.raises(NoAlertPresentException):117driver.fedcm.title118119def test_fedcm_no_subtitle_present(self, driver):120with pytest.raises(NoAlertPresentException):121driver.fedcm.subtitle122123def test_fedcm_no_account_list_present(self, driver):124with pytest.raises(NoAlertPresentException):125driver.fedcm.account_list()126127def test_fedcm_no_select_account_present(self, driver):128with pytest.raises(NoAlertPresentException):129driver.fedcm.select_account(1)130131def test_fedcm_no_cancel_dialog_present(self, driver):132with pytest.raises(NoAlertPresentException):133driver.fedcm.dismiss()134135def test_fedcm_no_click_continue_present(self, driver):136with pytest.raises(NoAlertPresentException):137driver.fedcm.accept()138139def test_verify_dialog_type_after_cooldown_reset(self, driver):140driver.fedcm.reset_cooldown()141driver.execute_script("triggerFedCm();")142dialog = driver.fedcm_dialog()143assert dialog.type == "AccountChooser"144dialog.dismiss()145146147