Skip to content

Commit

Permalink
[webview_flutter_wkwebview] Only set `limitsNavigationsToAppBoundDoma…
Browse files Browse the repository at this point in the history
…ins` when it is set to true (#5137)

This changes the flag to only flag to only call the method if it sets it to `true`.

Fixes flutter/flutter#136449
  • Loading branch information
bparrishMines committed Oct 24, 2023
1 parent c6821f9 commit f22ff36
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
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

0 comments on commit f22ff36

Please sign in to comment.