[ 
https://issues.apache.org/jira/browse/CB-12218?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16310144#comment-16310144
 ] 

ASF GitHub Bot commented on CB-12218:
-------------------------------------

infil00p closed pull request #425: CB-12218: (android) Fix consistency of null 
result message
URL: https://github.com/apache/cordova-android/pull/425
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/framework/src/org/apache/cordova/NativeToJsMessageQueue.java 
b/framework/src/org/apache/cordova/NativeToJsMessageQueue.java
index a8f59fad9..d17b1c43a 100755
--- a/framework/src/org/apache/cordova/NativeToJsMessageQueue.java
+++ b/framework/src/org/apache/cordova/NativeToJsMessageQueue.java
@@ -511,6 +511,9 @@ void buildJsMessage(StringBuilder sb) {
                             .append(pluginResult.getMessage())
                             .append("')");
                     break;
+                case PluginResult.MESSAGE_TYPE_NULL:
+                    sb.append("null");
+                    break;
                 default:
                     sb.append(pluginResult.getMessage());
             }
diff --git 
a/test/app/src/test/java/org/apache/cordova/unittests/NativeToJsMessageQueueTest.java
 
b/test/app/src/test/java/org/apache/cordova/unittests/NativeToJsMessageQueueTest.java
index e52789494..dc7bb6725 100644
--- 
a/test/app/src/test/java/org/apache/cordova/unittests/NativeToJsMessageQueueTest.java
+++ 
b/test/app/src/test/java/org/apache/cordova/unittests/NativeToJsMessageQueueTest.java
@@ -161,4 +161,17 @@ public void testMultipartPopAndEncodeAsJs()
         assertEquals(result, 
"cordova.callbackFromNative('37',true,1,[0,1,2,3,4],false);");
     }
 
+    @Test
+    public void testNullPopAndEncodeAsJs()
+    {
+        NativeToJsMessageQueue queue = new NativeToJsMessageQueue();
+        queue.addBridgeMode(new NativeToJsMessageQueue.NoOpBridgeMode());
+        queue.setBridgeMode(0);
+
+        PluginResult result = new PluginResult(PluginResult.Status.OK, 
(String)null);
+        queue.addPluginResult(result, TEST_CALLBACK_ID);
+        assertFalse(queue.isEmpty());
+        String resultString = queue.popAndEncodeAsJs();
+        assertEquals(resultString, "cordova.callbackFromNative('" + 
TEST_CALLBACK_ID + "',true,1,[null],false);");
+    }
 }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> inconsistent null handling between EVAL and ONLINE bridge modes
> ---------------------------------------------------------------
>
>                 Key: CB-12218
>                 URL: https://issues.apache.org/jira/browse/CB-12218
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: cordova-android
>    Affects Versions: 6.0.0
>         Environment: Android
>            Reporter: Alan Kinzie
>            Assignee: Joe Bowser
>         Attachments: CB12218.zip
>
>
> If the Android native code invokes the success callback like this:
> callbackContext.success(null);
> then the value given to the javascript callback changes depending on the 
> bridge type used.
> If the ONLINE_EVENT type is used, then null will be passed to the javascript 
> callback.
> ie: if result is the parameter of the javascript success callback then
> result === null  // will be true
> result === "" // will be false
> If the EVAL_BRIDGE type is used, then an empty string will be passed to the 
> javascript callback.
> ie: if result is the parameter of the javascript success callback then
> result === null  // will be false
> result === "" // will be true
> The value of the parameter given to the success callback should not change 
> depending on the bridge type.  Since ONLINE_EVENT was the default before 
> cordova android 6.0.0, I am inclined to think the ONLINE bridge is doing the 
> correct behaviour.  Also, converting null to an empty string loses 
> information.  Therefore I think the EVAL mode should to be changed to be 
> consistent with the ONLINE mode.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org
For additional commands, e-mail: issues-h...@cordova.apache.org

Reply via email to