Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,27 @@ class FrameInfoProxyAPITests: XCTestCase {
let registrar = TestProxyApiRegistrar()
let api = registrar.apiDelegate.pigeonApiWKFrameInfo(registrar)

let instance: TestFrameInfo? = TestFrameInfo()
let value = try? api.pigeonDelegate.isMainFrame(pigeonApi: api, pigeonInstance: instance!)
let instance = TestFrameInfo.instance
let value = try? api.pigeonDelegate.isMainFrame(pigeonApi: api, pigeonInstance: instance)

XCTAssertEqual(value, instance!.isMainFrame)
XCTAssertEqual(value, instance.isMainFrame)
}

@MainActor func testRequest() {
let registrar = TestProxyApiRegistrar()
let api = registrar.apiDelegate.pigeonApiWKFrameInfo(registrar)

let instance: TestFrameInfo? = TestFrameInfo()
let value = try? api.pigeonDelegate.request(pigeonApi: api, pigeonInstance: instance!)
let instance = TestFrameInfo.instance
let value = try? api.pigeonDelegate.request(pigeonApi: api, pigeonInstance: instance)

XCTAssertEqual(value?.value, instance!.request)
XCTAssertEqual(value?.value, instance.request)
}

@MainActor func testNilRequest() {
let registrar = TestProxyApiRegistrar()
let api = registrar.apiDelegate.pigeonApiWKFrameInfo(registrar)

let instance = TestFrameInfoWithNilRequest()
let instance = TestFrameInfoWithNilRequest.instance
let value = try? api.pigeonDelegate.request(pigeonApi: api, pigeonInstance: instance)
// On macOS 15.5+, `WKFrameInfo.request` returns with an empty URLRequest.
// Previously it would return nil so accept either.
Expand All @@ -46,6 +46,14 @@ class FrameInfoProxyAPITests: XCTestCase {
}

class TestFrameInfo: WKFrameInfo {
// Global test instance of `WKFrameInfo`. Using a static instance prevents a crash when
// a `WKFrameInfo` is deallocated during a test on iOS 26+.
Comment thread
bparrishMines marked this conversation as resolved.
static let instance = TestFrameInfo()

private override init() {

}

override var isMainFrame: Bool {
return true
}
Expand All @@ -56,4 +64,11 @@ class TestFrameInfo: WKFrameInfo {
}

class TestFrameInfoWithNilRequest: WKFrameInfo {
// Global test instance of `WKFrameInfo` with a nil URLRequest. Using a static instance prevents a
// crash when a `WKFrameInfo` is deallocated during a test on iOS 26+.
Comment thread
bparrishMines marked this conversation as resolved.
static let instance = TestFrameInfoWithNilRequest()

private override init() {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class NavigationActionProxyAPITests: XCTestCase {
}

class TestNavigationAction: WKNavigationAction {
let internalTargetFrame = TestFrameInfo()
let internalTargetFrame = TestFrameInfo.instance

override var request: URLRequest {
return URLRequest(url: URL(string: "http://google.com")!)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,7 @@ class TestWebView: WKWebView {
}

class TestURLAuthenticationChallengeSender: NSObject, URLAuthenticationChallengeSender,
@unchecked
Sendable
@unchecked Sendable
{
func use(_ credential: URLCredential, for challenge: URLAuthenticationChallenge) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class UIDelegateProxyAPITests: XCTestCase {
let instance = UIDelegateImpl(api: api, registrar: registrar)
let webView = WKWebView(frame: .zero)
let origin = SecurityOriginProxyAPITests.testSecurityOrigin
let frame = TestFrameInfo()
let frame = TestFrameInfo.instance
let type: WKMediaCaptureType = .camera

var resultDecision: WKPermissionDecision?
Expand All @@ -64,7 +64,7 @@ class UIDelegateProxyAPITests: XCTestCase {
let instance = UIDelegateImpl(api: api, registrar: registrar)
let webView = WKWebView(frame: .zero)
let message = "myString"
let frame = TestFrameInfo()
let frame = TestFrameInfo.instance

instance.webView(webView, runJavaScriptAlertPanelWithMessage: message, initiatedByFrame: frame)
{
Expand All @@ -79,7 +79,7 @@ class UIDelegateProxyAPITests: XCTestCase {
let instance = UIDelegateImpl(api: api, registrar: registrar)
let webView = WKWebView(frame: .zero)
let message = "myString"
let frame = TestFrameInfo()
let frame = TestFrameInfo.instance

var confirmedResult: Bool?
let callbackExpectation = expectation(description: "Wait for callback.")
Expand All @@ -103,7 +103,7 @@ class UIDelegateProxyAPITests: XCTestCase {
let webView = WKWebView(frame: .zero)
let prompt = "myString"
let defaultText = "myString3"
let frame = TestFrameInfo()
let frame = TestFrameInfo.instance

var inputResult: String?
let callbackExpectation = expectation(description: "Wait for callback.")
Expand Down
Loading