Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -7,10 +7,10 @@ public enum CheckoutProtocol {
public typealias Client = EmbeddedCheckoutProtocol.Client

public static func url(for url: URL) -> URL {
EmbeddedCheckoutProtocol.url(for: url, delegations: defaultDelegations)
EmbeddedCheckoutProtocol.url(for: url, options: .init(delegations: defaultDelegations))
}

static let defaultDelegations: [String] = ["window.open"]
static let defaultDelegations: [EmbeddedCheckoutProtocol.Delegation] = [.windowOpen]

static let methodNotFoundCode = -32601
static let methodNotFoundMessage = "Method not found"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ extension CheckoutWebView: WKScriptMessageHandler {
}

if method == EmbeddedCheckoutProtocol.readyMethod,
let response = EmbeddedCheckoutProtocol.acknowledgeReady(body, supportedDelegations: CheckoutProtocol.defaultDelegations)
let response = EmbeddedCheckoutProtocol.acknowledgeReady(body, supportedDelegations: CheckoutProtocol.defaultDelegations.map(\.rawValue))
{
OSLogger.shared.debug("Handling ec.ready: sending UCP ready acknowledgement, isPreload: \(isPreloadRequest)")
Task { @MainActor in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class CheckoutWebViewControllerTests: XCTestCase {
func test_presentationControllerDidDismiss_doesNotCleanUpBeforeViewDisappears() throws {
ShopifyCheckoutKit.configuration.preloading.enabled = true
ShopifyCheckoutKit.preload(checkout: url)
let viewController = TestableCheckoutWebViewController(checkoutURL: EmbeddedCheckoutProtocol.url(for: url, delegations: CheckoutProtocol.defaultDelegations), entryPoint: nil)
let viewController = TestableCheckoutWebViewController(checkoutURL: EmbeddedCheckoutProtocol.url(for: url, options: .init(delegations: CheckoutProtocol.defaultDelegations)), entryPoint: nil)
viewController.loadViewIfNeeded()

let checkoutView = try XCTUnwrap(viewController.checkoutView)
Expand All @@ -93,7 +93,7 @@ class CheckoutWebViewControllerTests: XCTestCase {
func test_viewDidDisappear_cleansUpConsumedPreloadedWebViewWhenDismissed() throws {
ShopifyCheckoutKit.configuration.preloading.enabled = true
ShopifyCheckoutKit.preload(checkout: url)
let viewController = TestableCheckoutWebViewController(checkoutURL: EmbeddedCheckoutProtocol.url(for: url, delegations: CheckoutProtocol.defaultDelegations), entryPoint: nil)
let viewController = TestableCheckoutWebViewController(checkoutURL: EmbeddedCheckoutProtocol.url(for: url, options: .init(delegations: CheckoutProtocol.defaultDelegations)), entryPoint: nil)
viewController.loadViewIfNeeded()

let checkoutView = try XCTUnwrap(viewController.checkoutView)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ class CheckoutWebViewTests: XCTestCase {
XCTAssertTrue(CheckoutWebView.preloadCache.hasEntry())
XCTAssertTrue(CheckoutWebView.preloadCache.hasActiveKeepAlive())

let cached = CheckoutWebView.for(checkout: EmbeddedCheckoutProtocol.url(for: url, delegations: CheckoutProtocol.defaultDelegations))
let cached = CheckoutWebView.for(checkout: EmbeddedCheckoutProtocol.url(for: url, options: .init(delegations: CheckoutProtocol.defaultDelegations)))

XCTAssertTrue(CheckoutWebView.preloadCache.hasEntry())
XCTAssertFalse(CheckoutWebView.preloadCache.hasActiveKeepAlive())
Expand All @@ -305,8 +305,8 @@ class CheckoutWebViewTests: XCTestCase {

func testPresentingMatchingCheckoutReusesCachedWebViewWithoutEvictingIt() {
ShopifyCheckoutKit.preload(checkout: url)
let first = CheckoutWebView.for(checkout: EmbeddedCheckoutProtocol.url(for: url, delegations: CheckoutProtocol.defaultDelegations))
let second = CheckoutWebView.for(checkout: EmbeddedCheckoutProtocol.url(for: url, delegations: CheckoutProtocol.defaultDelegations))
let first = CheckoutWebView.for(checkout: EmbeddedCheckoutProtocol.url(for: url, options: .init(delegations: CheckoutProtocol.defaultDelegations)))
let second = CheckoutWebView.for(checkout: EmbeddedCheckoutProtocol.url(for: url, options: .init(delegations: CheckoutProtocol.defaultDelegations)))

XCTAssertTrue(first === second)
XCTAssertTrue(CheckoutWebView.preloadCache.hasEntry())
Expand Down Expand Up @@ -411,7 +411,7 @@ class CheckoutWebViewTests: XCTestCase {

func testInvalidateDetachesCachedPreloadedWebView() {
ShopifyCheckoutKit.preload(checkout: url)
let cached = CheckoutWebView.for(checkout: EmbeddedCheckoutProtocol.url(for: url, delegations: CheckoutProtocol.defaultDelegations))
let cached = CheckoutWebView.for(checkout: EmbeddedCheckoutProtocol.url(for: url, options: .init(delegations: CheckoutProtocol.defaultDelegations)))
XCTAssertTrue(cached.isBridgeAttached)

ShopifyCheckoutKit.invalidate()
Expand All @@ -422,7 +422,7 @@ class CheckoutWebViewTests: XCTestCase {

func testHTTPErrorInvalidatesPreloadCache() throws {
ShopifyCheckoutKit.preload(checkout: url)
let cached = CheckoutWebView.for(checkout: EmbeddedCheckoutProtocol.url(for: url, delegations: CheckoutProtocol.defaultDelegations))
let cached = CheckoutWebView.for(checkout: EmbeddedCheckoutProtocol.url(for: url, options: .init(delegations: CheckoutProtocol.defaultDelegations)))
let link = try XCTUnwrap(cached.url)
let response = try XCTUnwrap(HTTPURLResponse(url: link, statusCode: 403, httpVersion: nil, headerFields: nil))

Expand Down
Loading
Loading