Skip to content

Commit

Permalink
More test fixes
Browse files Browse the repository at this point in the history
Make more iOS codepaths iOS/macOS, where they are really about general webview behavior.
  • Loading branch information
stuartmorgan authored Aug 20, 2024
1 parent f026094 commit 5f600c3
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ Future<void> main() async {
'localStorage.getItem("myCat");',
) as String;
} catch (exception) {
if (defaultTargetPlatform == TargetPlatform.iOS &&
if (_isWKWebView() &&
exception is ArgumentError &&
(exception.message as String).contains(
'Result of JavaScript execution returned a `null` value.')) {
Expand All @@ -960,10 +960,10 @@ Future<void> main() async {
);
}

// JavaScript `null` evaluate to different string values on Android and iOS.
// JavaScript `null` evaluate to different string values per platform.
// This utility method returns the string boolean value of the current platform.
String _webViewNull() {
if (defaultTargetPlatform == TargetPlatform.iOS) {
if (_isWKWebView()) {
return '<null>';
}
return 'null';
Expand All @@ -972,13 +972,17 @@ String _webViewNull() {
// JavaScript String evaluates to different strings depending on the platform.
// This utility method returns the string boolean value of the current platform.
String _webViewString(String value) {
if (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform == TargetPlatform.macOS) {
if (_isWKWebView()) {
return value;
}
return '"$value"';
}

bool _isWKWebView() {
return defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform == TargetPlatform.macOS;
}

class ResizableWebView extends StatefulWidget {
const ResizableWebView({
super.key,
Expand Down

0 comments on commit 5f600c3

Please sign in to comment.