Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/rb/spec/integration/selenium/webdriver/fedcm_spec.rb
1864 views
1
# frozen_string_literal: true
2
3
# Licensed to the Software Freedom Conservancy (SFC) under one
4
# or more contributor license agreements. See the NOTICE file
5
# distributed with this work for additional information
6
# regarding copyright ownership. The SFC licenses this file
7
# to you under the Apache License, Version 2.0 (the
8
# "License"); you may not use this file except in compliance
9
# with the License. You may obtain a copy of the License at
10
#
11
# http://www.apache.org/licenses/LICENSE-2.0
12
#
13
# Unless required by applicable law or agreed to in writing,
14
# software distributed under the License is distributed on an
15
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
# KIND, either express or implied. See the License for the
17
# specific language governing permissions and limitations
18
# under the License.
19
20
require_relative 'spec_helper'
21
22
module Selenium
23
module WebDriver
24
module FedCM
25
describe FedCM,
26
exclude: {browser: :chrome, reason: 'https://issues.chromium.org/u/0/issues/425801332'},
27
exclusive: [{bidi: false, reason: 'Not yet implemented with BiDi'}, {browser: %i[chrome edge]}] do
28
let(:dialog) { driver.fedcm_dialog }
29
30
before { driver.get url_for('fedcm/fedcm.html') }
31
after { reset_driver! }
32
33
context 'without dialog present' do
34
it 'throws an error' do
35
expect { dialog.title }.to raise_error(Error::NoSuchAlertError)
36
expect { dialog.subtitle }.to raise_error(Error::NoSuchAlertError)
37
expect { dialog.type }.to raise_error(Error::NoSuchAlertError)
38
expect { dialog.accounts }.to raise_error(Error::NoSuchAlertError)
39
expect { dialog.select_account(1) }.to raise_error(Error::NoSuchAlertError)
40
expect { dialog.cancel }.to raise_error(Error::NoSuchAlertError)
41
end
42
end
43
44
context 'with dialog present' do
45
before do
46
driver.execute_script('triggerFedCm();')
47
driver.wait_for_fedcm_dialog
48
end
49
50
it 'returns the title' do
51
expect(dialog.title).to eq('Sign in to localhost with localhost')
52
end
53
54
it 'returns the subtitle' do
55
expect(dialog.subtitle).to be_nil
56
end
57
58
it 'returns the type' do
59
expect(dialog.type).to eq('AccountChooser')
60
end
61
62
it 'returns the accounts' do
63
first_account = dialog.accounts.first
64
expect(first_account.name).to eq 'John Doe'
65
end
66
67
it 'selects an account' do
68
expect(dialog.select_account(1)).to be_nil
69
end
70
71
it 'clicks the dialog', except: {browser: %i[chrome edge],
72
reason: "error: 'Use another account' not supported for this IDP"} do
73
expect(dialog.click).to be_nil
74
end
75
76
it 'cancels the dialog' do
77
dialog.cancel
78
expect { dialog.title }.to raise_error(Error::NoSuchAlertError)
79
end
80
81
it 'sets the delay' do
82
expect(driver.enable_fedcm_delay = true).to be_truthy
83
end
84
85
it 'resets the cooldown' do
86
expect(driver.reset_fedcm_cooldown).to be_nil
87
end
88
end
89
end
90
end # FedCm
91
end # WebDriver
92
end # Selenium
93
94