Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[webview_flutter_wkwebview] Only set limitsNavigationsToAppBoundDomains when it is set to true #5137

Merged
merged 3 commits into from
Oct 24, 2023
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
@@ -1,3 +1,8 @@
## 3.9.2

* Fixes error caused by calling `WKWebViewConfiguration.limitsNavigationsToAppBoundDomains` on
versions below 14.

## 3.9.1

* Fixes bug where `WebkitWebViewController.getUserAgent` was incorrectly returning an empty String.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,14 @@ class WebKitWebViewControllerCreationParams
);
}
_configuration.setAllowsInlineMediaPlayback(allowsInlineMediaPlayback);
_configuration.setLimitsNavigationsToAppBoundDomains(
limitsNavigationsToAppBoundDomains);
// `WKWebViewConfiguration.limitsNavigationsToAppBoundDomains` is only
// supported on iOS versions 14+. So this only calls it if the value is set
// to true.
if (limitsNavigationsToAppBoundDomains) {
_configuration.setLimitsNavigationsToAppBoundDomains(
limitsNavigationsToAppBoundDomains,
);
}
}

/// Constructs a [WebKitWebViewControllerCreationParams] using a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: webview_flutter_wkwebview
description: A Flutter plugin that provides a WebView widget based on Apple's WKWebView control.
repository: https://github.com/flutter/packages/tree/main/packages/webview_flutter/webview_flutter_wkwebview
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+webview%22
version: 3.9.1
version: 3.9.2

environment:
sdk: ">=2.19.0 <4.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,25 @@ void main() {
);
});

test(
'limitsNavigationsToAppBoundDomains is not called if it uses default value (false)',
() {
final MockWKWebViewConfiguration mockConfiguration =
MockWKWebViewConfiguration();

WebKitWebViewControllerCreationParams(
webKitProxy: WebKitProxy(
createWebViewConfiguration: ({InstanceManager? instanceManager}) {
return mockConfiguration;
},
),
);

verifyNever(
mockConfiguration.setLimitsNavigationsToAppBoundDomains(any),
);
});

test('mediaTypesRequiringUserAction', () {
final MockWKWebViewConfiguration mockConfiguration =
MockWKWebViewConfiguration();
Expand Down