Skip to content
Open
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
5 changes: 4 additions & 1 deletion Source/Turbo/Visitable/VisitableView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ open class VisitableView: UIView {
open func activateWebView(_ webView: WKWebView, forVisitable visitable: Visitable) {
self.webView = webView
self.visitable = visitable
addSubview(webView)
// For behaviour like UINavigationBar.prefersLargeTitles or
// TabBarMinimize to work the scrollable view shoud be the
// first child in the hierarchy from the moment it is added.
insertSubview(webView, at: 0)
addFillConstraints(for: webView)
installRefreshControl()
showOrHideWebView()
Expand Down
24 changes: 24 additions & 0 deletions Tests/Turbo/VisitableViewControllerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,30 @@ class VisitableViewControllerTests: XCTestCase {
XCTAssertEqual(viewController.initialVisitableURL, originalURL)
XCTAssertEqual(viewController.currentVisitableURL, overriddenURL)
}

func test_webview_is_first_child_during_loading() {
XCTAssertEqual(viewController.visitableView.subviews.first, viewController.visitableView.activityIndicatorView)

viewController.visitableView.activateWebView(webView, forVisitable: viewController)

XCTAssertEqual(viewController.visitableView.subviews.first, webView)
XCTAssertEqual(viewController.visitableView.subviews.last, viewController.visitableView.activityIndicatorView)
}

func test_webview_is_first_child_on_restore() {
XCTAssertEqual(viewController.visitableView.subviews.first, viewController.visitableView.activityIndicatorView)

viewController.showVisitableScreenshot()
viewController.visitableView.activateWebView(webView, forVisitable: viewController)

XCTAssertEqual(viewController.visitableView.subviews.count, 3)
XCTAssertEqual(viewController.visitableView.subviews.first, viewController.visitableView.webView)

viewController.hideVisitableScreenshot()

XCTAssertEqual(viewController.visitableView.subviews.count, 2)
XCTAssertEqual(viewController.visitableView.subviews.first, viewController.visitableView.webView)
}
}

final class WebViewSpy: WKWebView {
Expand Down
Loading