/
BrowserTests.swift
55 lines (46 loc) · 2.36 KB
/
BrowserTests.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import Foundation
import Storage
import EarlGrey
@testable import Client
class BrowserTests: KIFTestCase {
private var webRoot: String!
override func setUp() {
super.setUp()
webRoot = SimplePageServer.start()
BrowserUtils.dismissFirstRunUI()
}
override func tearDown() {
BrowserUtils.resetToAboutHome(tester())
BrowserUtils.clearPrivateData(tester: tester())
super.tearDown()
}
func testDisplaySharesheetWhileJSPromptOccurs() {
let url = "\(webRoot!)/JSPrompt.html"
EarlGrey.select(elementWithMatcher: grey_accessibilityID("url")).perform(grey_tap())
EarlGrey.select(elementWithMatcher: grey_accessibilityID("address")).perform(grey_replaceText(url))
EarlGrey.select(elementWithMatcher: grey_accessibilityID("address")).perform(grey_typeText("\n"))
tester().waitForWebViewElementWithAccessibilityLabel("JS Prompt")
//EarlGrey.select(elementWithMatcher: grey_kindOfClass(NSClassFromString("_UIAlertControllerInterfaceActionGroupView")!))
// .assert(grey_sufficientlyVisible())
// Show share sheet and wait for the JS prompt to fire
EarlGrey.select(elementWithMatcher: grey_accessibilityLabel("Share")).perform(grey_tap())
if BrowserUtils.iPad() {
// iPad does not have cancel btn to close dialog
EarlGrey.select(elementWithMatcher: grey_accessibilityLabel("Share")).perform(grey_tap())
} else {
let matcher = grey_allOf([grey_accessibilityLabel("Cancel"),
grey_accessibilityTrait(UIAccessibilityTraitButton),
grey_sufficientlyVisible()])
EarlGrey.select(elementWithMatcher: matcher).perform(grey_tap())
}
// Check to see if the JS Prompt is dequeued and showing
tester().waitForView(withAccessibilityLabel: "OK")
EarlGrey.select(elementWithMatcher: grey_accessibilityLabel("OK"))
.inRoot(grey_kindOfClass(NSClassFromString("_UIAlertControllerActionView")!))
.assert(grey_enabled())
.perform((grey_tap()))
}
}