Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
e25faa3
[webview_flutter_platform_interface] Update webview platform interfac…
BeMacized Oct 1, 2021
f19b5c3
Fix tests
BeMacized Oct 1, 2021
3a22d00
[webview_flutter] Implemented `runJavaScript` and `runJavaScriptForRe…
BeMacized Oct 1, 2021
2bcec1c
Remove accidental development team inclusion from project.pbxproj
BeMacized Oct 1, 2021
8e5a2de
[webview_flutter] Deprecate `evaluateJavascript` in favour of `runJav…
BeMacized Oct 1, 2021
5a84981
Updated changelog
BeMacized Oct 1, 2021
ff493a2
Implemented PR feedback
BeMacized Oct 1, 2021
6bf082f
Merge branch 'webview/js_eval_fix_platform' into webview/js_eval_fix_…
BeMacized Oct 1, 2021
ff125c9
Updated runJavaScriptForResult behaviour
BeMacized Oct 1, 2021
79707d7
Merge branch 'webview/js_eval_fix_native' into webview/js_eval_fix_app
BeMacized Oct 1, 2021
73f3407
Updated documentation
BeMacized Oct 1, 2021
9f661e8
Implemented PR feedback partially
BeMacized Oct 4, 2021
cbc88e8
Implement PR feedback
BeMacized Oct 4, 2021
9f537c7
Merge branch 'webview/js_eval_fix_platform' into webview/js_eval_fix_…
BeMacized Oct 4, 2021
26004c3
Update changelog
BeMacized Oct 4, 2021
283f8a7
Merge branch 'webview/js_eval_fix_platform' into webview/js_eval_fix_…
BeMacized Oct 4, 2021
b95d986
Implement PR feedback from interface PR
BeMacized Oct 4, 2021
3d8b9ce
Update changelog
BeMacized Oct 4, 2021
840a73e
Merge branch 'webview/js_eval_fix_native' into webview/js_eval_fix_app
BeMacized Oct 4, 2021
45c4a7d
Fix issues from merge.
BeMacized Oct 4, 2021
0ecf641
Revert inclusion of development team
BeMacized Oct 4, 2021
d7b57f4
Merge branch 'webview/js_eval_fix_native' into webview/js_eval_fix_app
BeMacized Oct 4, 2021
02e1106
Implement PR feedback
BeMacized Oct 5, 2021
d7780dd
Merge branch 'webview/js_eval_fix_platform' into webview/js_eval_fix_…
BeMacized Oct 5, 2021
d8f51ed
Implemented platform interface PR feedback
BeMacized Oct 5, 2021
3ccb8ae
Merge branch 'webview/js_eval_fix_native' into webview/js_eval_fix_app
BeMacized Oct 5, 2021
c884665
Implemented platform interface PR feedback
BeMacized Oct 5, 2021
285c2cc
Merge branch 'master' into webview/js_eval_fix_platform
BeMacized Oct 6, 2021
90cb648
Merge branch 'webview/js_eval_fix_platform' into webview/js_eval_fix_…
BeMacized Oct 6, 2021
156f77f
Merge branch 'webview/js_eval_fix_native' into webview/js_eval_fix_app
BeMacized Oct 6, 2021
bfcacdc
Update pubspec dependency
BeMacized Oct 6, 2021
bcb368c
Merge branch 'master' into webview/js_eval_fix_native
BeMacized Oct 6, 2021
485ead3
Fixed capitalisation
BeMacized Oct 6, 2021
a7d10c0
Fixed capitalisation
BeMacized Oct 6, 2021
d98bc6a
Fix warning
BeMacized Oct 7, 2021
738a9ad
Partially implement PR feedback
BeMacized Oct 8, 2021
527bd67
Partially implement PR feedback
BeMacized Oct 8, 2021
acf5ff9
Format
BeMacized Oct 8, 2021
aed3830
Update podfile
BeMacized Oct 8, 2021
6967c4f
Update podfile
BeMacized Oct 8, 2021
37ba26e
Update podfiles
BeMacized Oct 8, 2021
13076ba
Update iOS project files
BeMacized Oct 8, 2021
0c87362
Update podspec
BeMacized Oct 8, 2021
28ac939
Merge remote-tracking branch 'origin/webview/js_eval_fix_native' into…
BeMacized Oct 8, 2021
962ad02
Remove unnecessary podfile configuration
BeMacized Oct 8, 2021
9184d48
Implemented PR feedback
BeMacized Oct 8, 2021
a111502
Merge branch 'master' into webview/js_eval_fix_native
BeMacized Oct 18, 2021
80cbe9b
Format
BeMacized Oct 18, 2021
9fdab9d
Revert podfile changes
BeMacized Oct 22, 2021
6e609d7
Implemented PR feedback
BeMacized Oct 22, 2021
f6d8cb4
Fix formatting
BeMacized Oct 22, 2021
b019d3c
Fix formatting
BeMacized Oct 22, 2021
2b0f490
Fixed test.
BeMacized Oct 22, 2021
fa9526c
Re-add integration tests for deprecated evaluateJavascript method.
BeMacized Oct 26, 2021
45e799b
Merge branch 'master' into webview/js_eval_fix_native
BeMacized Oct 28, 2021
40a6b38
Merge branch 'master' into webview/js_eval_fix_native
BeMacized Oct 28, 2021
e2f4710
Fix merge conflicts
BeMacized Oct 28, 2021
29cca43
Merge branch 'webview/js_eval_fix_native' into webview/js_eval_fix_app
BeMacized Nov 1, 2021
fcf1723
Merge branch 'master' into webview/js_eval_fix_app
BeMacized Nov 1, 2021
a3656a3
Add missing test and format
BeMacized Nov 1, 2021
662e563
Fixed dependencies and updated changelog
BeMacized Nov 1, 2021
834465e
Ignore deprecated uses of evaluateJavascript in tests
BeMacized Nov 1, 2021
20b5a90
Fix analysis errors
BeMacized Nov 1, 2021
5c2885e
Fix unit tests
BeMacized Nov 1, 2021
6341867
Merge branch 'master' into webview/js_eval_fix_app
BeMacized Nov 2, 2021
37504c9
Implemented PR feedback
BeMacized Nov 4, 2021
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
Prev Previous commit
Next Next commit
Implement PR feedback from interface PR
  • Loading branch information
BeMacized committed Oct 4, 2021
commit b95d986d4acee379c6ceb2a10b2fe0188255a43c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## 2.1.0

* Implemented new `runJavaScript` and `runJavaScriptForResult` methods in platform interface.
* Implemented new `runJavascript` and `runJavascriptReturningResult` methods in platform interface.

## 2.0.15

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public void onProgressChanged(WebView view, int progress) {
if (params.containsKey(JS_CHANNEL_NAMES_FIELD)) {
List<String> names = (List<String>) params.get(JS_CHANNEL_NAMES_FIELD);
if (names != null) {
registerJavaScriptChannelNames(names);
registerJavascriptChannelNames(names);
}
}

Expand All @@ -149,7 +149,7 @@ public void onProgressChanged(WebView view, int progress) {
*
* <ul>
* <li>always enable the DOM storage API;
* <li>always allow JavaScript to automatically open windows;
* <li>always allow Javascript to automatically open windows;
* <li>always allow support for multiple windows;
* <li>always use the {@link FlutterWebChromeClient} as web Chrome client.
* </ul>
Expand Down Expand Up @@ -244,17 +244,17 @@ public void onMethodCall(MethodCall methodCall, Result result) {
currentUrl(result);
break;
case "evaluateJavascript":
case "runJavaScriptForResult":
evaluateJavaScript(methodCall, result, true);
case "runJavascriptReturningResult":
evaluateJavascript(methodCall, result, true);
break;
case "runJavaScript":
evaluateJavaScript(methodCall, result, false);
case "runJavascript":
evaluateJavascript(methodCall, result, false);
break;
case "addJavascriptChannels":
addJavaScriptChannels(methodCall, result);
addJavascriptChannels(methodCall, result);
break;
case "removeJavascriptChannels":
removeJavaScriptChannels(methodCall, result);
removeJavascriptChannels(methodCall, result);
break;
case "clearCache":
clearCache(result);
Expand Down Expand Up @@ -329,11 +329,11 @@ private void updateSettings(MethodCall methodCall, Result result) {
}

@TargetApi(Build.VERSION_CODES.KITKAT)
private void evaluateJavaScript(
private void evaluateJavascript(
MethodCall methodCall, final Result result, final boolean returnValue) {
String jsString = (String) methodCall.arguments;
if (jsString == null) {
throw new UnsupportedOperationException("JavaScript string cannot be null");
throw new UnsupportedOperationException("Javascript string cannot be null");
}
webView.evaluateJavascript(
jsString,
Expand All @@ -350,14 +350,14 @@ public void onReceiveValue(String value) {
}

@SuppressWarnings("unchecked")
private void addJavaScriptChannels(MethodCall methodCall, Result result) {
private void addJavascriptChannels(MethodCall methodCall, Result result) {
List<String> channelNames = (List<String>) methodCall.arguments;
registerJavaScriptChannelNames(channelNames);
registerJavascriptChannelNames(channelNames);
result.success(null);
}

@SuppressWarnings("unchecked")
private void removeJavaScriptChannels(MethodCall methodCall, Result result) {
private void removeJavascriptChannels(MethodCall methodCall, Result result) {
List<String> channelNames = (List<String>) methodCall.arguments;
for (String channelName : channelNames) {
webView.removeJavascriptInterface(channelName);
Expand Down Expand Up @@ -452,7 +452,7 @@ private void updateJsMode(int mode) {
webView.getSettings().setJavaScriptEnabled(true);
break;
default:
throw new IllegalArgumentException("Trying to set unknown JavaScript mode: " + mode);
throw new IllegalArgumentException("Trying to set unknown Javascript mode: " + mode);
}
}

Expand All @@ -465,10 +465,10 @@ private void updateAutoMediaPlaybackPolicy(int mode) {
}
}

private void registerJavaScriptChannelNames(List<String> channelNames) {
private void registerJavascriptChannelNames(List<String> channelNames) {
for (String channelName : channelNames) {
webView.addJavascriptInterface(
new JavaScriptChannel(methodChannel, channelName, platformThreadHandler), channelName);
new JavascriptChannel(methodChannel, channelName, platformThreadHandler), channelName);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@
* <p>Exposes a single method named `postMessage` to JavaScript, which sends a message over a method
* channel to the Dart code.
*/
class JavaScriptChannel {
class JavascriptChannel {
private final MethodChannel methodChannel;
private final String javaScriptChannelName;
private final String javascriptChannelName;
private final Handler platformThreadHandler;

/**
* @param methodChannel the Flutter WebView method channel to which JS messages are sent
* @param javaScriptChannelName the name of the JavaScript channel, this is sent over the method
* @param javascriptChannelName the name of the JavaScript channel, this is sent over the method
* channel with each message to let the Dart code know which JavaScript channel the message
* was sent through
*/
JavaScriptChannel(
MethodChannel methodChannel, String javaScriptChannelName, Handler platformThreadHandler) {
JavascriptChannel(
MethodChannel methodChannel, String javascriptChannelName, Handler platformThreadHandler) {
this.methodChannel = methodChannel;
this.javaScriptChannelName = javaScriptChannelName;
this.javascriptChannelName = javascriptChannelName;
this.platformThreadHandler = platformThreadHandler;
}

Expand All @@ -44,7 +44,7 @@ public void postMessage(final String message) {
@Override
public void run() {
HashMap<String, String> arguments = new HashMap<>();
arguments.put("channel", javaScriptChannelName);
arguments.put("channel", javascriptChannelName);
arguments.put("message", message);
methodChannel.invokeMethod("javascriptChannelMessage", arguments);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void createWebView_shouldCreateWebViewWithDefaultConfiguration() {
}

@Test(expected = UnsupportedOperationException.class)
public void evaluateJavaScript_shouldThrowForNullString() {
public void evaluateJavascript_shouldThrowForNullString() {
try (MockedStatic<FlutterWebView> mockedFlutterWebView = mockStatic(FlutterWebView.class)) {
// Setup
mockedFlutterWebView
Expand All @@ -92,12 +92,12 @@ public void apply() throws Throwable {
new FlutterWebView(mockContext, mockMethodChannel, new HashMap<String, Object>(), null);

// Run
flutterWebView.onMethodCall(new MethodCall("runJavaScript", null), mockResult);
flutterWebView.onMethodCall(new MethodCall("runJavascript", null), mockResult);
}
}

@Test
public void evaluateJavaScript_shouldReturnValueOnSuccessForReturnValue() {
public void evaluateJavascript_shouldReturnValueOnSuccessForReturnValue() {
try (MockedStatic<FlutterWebView> mockedFlutterWebView = mockStatic(FlutterWebView.class)) {
// Setup
mockedFlutterWebView
Expand All @@ -112,25 +112,25 @@ public void evaluateJavaScript_shouldReturnValueOnSuccessForReturnValue() {
doAnswer(
invocation -> {
android.webkit.ValueCallback<String> callback = invocation.getArgument(1);
callback.onReceiveValue("Test JavaScript Result");
callback.onReceiveValue("Test Javascript Result");
return null;
})
.when(mockWebView)
.evaluateJavascript(eq("Test JavaScript String"), any());
.evaluateJavascript(eq("Test Javascript String"), any());
FlutterWebView flutterWebView =
new FlutterWebView(mockContext, mockMethodChannel, new HashMap<String, Object>(), null);

// Run
flutterWebView.onMethodCall(
new MethodCall("runJavaScriptForResult", "Test JavaScript String"), mockResult);
new MethodCall("runJavascriptReturningResult", "Test Javascript String"), mockResult);

// Verify
verify(mockResult, times(1)).success("Test JavaScript Result");
verify(mockResult, times(1)).success("Test Javascript Result");
}
}

@Test
public void evaluateJavaScript_shouldReturnNilOnSuccessForNoReturnValue() {
public void evaluateJavascript_shouldReturnNilOnSuccessForNoReturnValue() {
try (MockedStatic<FlutterWebView> mockedFlutterWebView = mockStatic(FlutterWebView.class)) {
// Setup
mockedFlutterWebView
Expand All @@ -145,17 +145,17 @@ public void evaluateJavaScript_shouldReturnNilOnSuccessForNoReturnValue() {
doAnswer(
invocation -> {
android.webkit.ValueCallback<String> callback = invocation.getArgument(1);
callback.onReceiveValue("Test JavaScript Result");
callback.onReceiveValue("Test Javascript Result");
return null;
})
.when(mockWebView)
.evaluateJavascript(eq("Test JavaScript String"), any());
.evaluateJavascript(eq("Test Javascript String"), any());
FlutterWebView flutterWebView =
new FlutterWebView(mockContext, mockMethodChannel, new HashMap<String, Object>(), null);

// Run
flutterWebView.onMethodCall(
new MethodCall("runJavaScript", "Test JavaScript String"), mockResult);
new MethodCall("runJavascript", "Test Javascript String"), mockResult);

// Verify
verify(mockResult, times(1)).success(isNull());
Expand Down
Loading