Path: blob/trunk/rb/spec/integration/selenium/webdriver/fedcm_spec.rb
1864 views
# frozen_string_literal: true12# Licensed to the Software Freedom Conservancy (SFC) under one3# or more contributor license agreements. See the NOTICE file4# distributed with this work for additional information5# regarding copyright ownership. The SFC licenses this file6# to you under the Apache License, Version 2.0 (the7# "License"); you may not use this file except in compliance8# with the License. You may obtain a copy of the License at9#10# http://www.apache.org/licenses/LICENSE-2.011#12# Unless required by applicable law or agreed to in writing,13# software distributed under the License is distributed on an14# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY15# KIND, either express or implied. See the License for the16# specific language governing permissions and limitations17# under the License.1819require_relative 'spec_helper'2021module Selenium22module WebDriver23module FedCM24describe FedCM,25exclude: {browser: :chrome, reason: 'https://issues.chromium.org/u/0/issues/425801332'},26exclusive: [{bidi: false, reason: 'Not yet implemented with BiDi'}, {browser: %i[chrome edge]}] do27let(:dialog) { driver.fedcm_dialog }2829before { driver.get url_for('fedcm/fedcm.html') }30after { reset_driver! }3132context 'without dialog present' do33it 'throws an error' do34expect { dialog.title }.to raise_error(Error::NoSuchAlertError)35expect { dialog.subtitle }.to raise_error(Error::NoSuchAlertError)36expect { dialog.type }.to raise_error(Error::NoSuchAlertError)37expect { dialog.accounts }.to raise_error(Error::NoSuchAlertError)38expect { dialog.select_account(1) }.to raise_error(Error::NoSuchAlertError)39expect { dialog.cancel }.to raise_error(Error::NoSuchAlertError)40end41end4243context 'with dialog present' do44before do45driver.execute_script('triggerFedCm();')46driver.wait_for_fedcm_dialog47end4849it 'returns the title' do50expect(dialog.title).to eq('Sign in to localhost with localhost')51end5253it 'returns the subtitle' do54expect(dialog.subtitle).to be_nil55end5657it 'returns the type' do58expect(dialog.type).to eq('AccountChooser')59end6061it 'returns the accounts' do62first_account = dialog.accounts.first63expect(first_account.name).to eq 'John Doe'64end6566it 'selects an account' do67expect(dialog.select_account(1)).to be_nil68end6970it 'clicks the dialog', except: {browser: %i[chrome edge],71reason: "error: 'Use another account' not supported for this IDP"} do72expect(dialog.click).to be_nil73end7475it 'cancels the dialog' do76dialog.cancel77expect { dialog.title }.to raise_error(Error::NoSuchAlertError)78end7980it 'sets the delay' do81expect(driver.enable_fedcm_delay = true).to be_truthy82end8384it 'resets the cooldown' do85expect(driver.reset_fedcm_cooldown).to be_nil86end87end88end89end # FedCm90end # WebDriver91end # Selenium929394