OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.android_webview.test; | 5 package org.chromium.android_webview.test; |
6 | 6 |
7 import android.os.Build; | 7 import android.os.Build; |
8 import android.os.Handler; | 8 import android.os.Handler; |
9 import android.test.suitebuilder.annotation.SmallTest; | 9 import android.test.suitebuilder.annotation.SmallTest; |
10 import android.webkit.JavascriptInterface; | 10 import android.webkit.JavascriptInterface; |
(...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1024 } | 1024 } |
1025 }); | 1025 }); |
1026 channelContainer.waitForMessage(); | 1026 channelContainer.waitForMessage(); |
1027 assertEquals(HELLO + JS_MESSAGE, channelContainer.getMessage()); | 1027 assertEquals(HELLO + JS_MESSAGE, channelContainer.getMessage()); |
1028 } | 1028 } |
1029 | 1029 |
1030 private static final String TEST_PAGE_FOR_UNSUPPORTED_MESSAGES = "<!DOCTYPE
html><html><body>" | 1030 private static final String TEST_PAGE_FOR_UNSUPPORTED_MESSAGES = "<!DOCTYPE
html><html><body>" |
1031 + " <script>" | 1031 + " <script>" |
1032 + " onmessage = function (e) {" | 1032 + " onmessage = function (e) {" |
1033 + " e.source.postMessage('" + HELLO + "', '*');" | 1033 + " e.source.postMessage('" + HELLO + "', '*');" |
1034 + " e.ports[0].postMessage();" | |
1035 + " e.ports[0].postMessage(null);" | 1034 + " e.ports[0].postMessage(null);" |
1036 + " e.ports[0].postMessage(undefined);" | 1035 + " e.ports[0].postMessage(undefined);" |
1037 + " e.ports[0].postMessage(NaN);" | 1036 + " e.ports[0].postMessage(NaN);" |
1038 + " e.ports[0].postMessage(0);" | 1037 + " e.ports[0].postMessage(0);" |
1039 + " e.ports[0].postMessage(new Set());" | 1038 + " e.ports[0].postMessage(new Set());" |
1040 + " e.ports[0].postMessage({});" | 1039 + " e.ports[0].postMessage({});" |
1041 + " e.ports[0].postMessage(['1','2','3']);" | 1040 + " e.ports[0].postMessage(['1','2','3']);" |
1042 + " e.ports[0].postMessage('" + JS_MESSAGE + "');" | 1041 + " e.ports[0].postMessage('" + JS_MESSAGE + "');" |
1043 + " }" | 1042 + " }" |
1044 + " </script>" | 1043 + " </script>" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1098 } | 1097 } |
1099 }, null); | 1098 }, null); |
1100 mAwContents.postMessageToFrame(null, WEBVIEW_MESSAGE, mWebServer
.getBaseUrl(), | 1099 mAwContents.postMessageToFrame(null, WEBVIEW_MESSAGE, mWebServer
.getBaseUrl(), |
1101 new AwMessagePort[] {channel[1]}); | 1100 new AwMessagePort[] {channel[1]}); |
1102 } | 1101 } |
1103 }); | 1102 }); |
1104 channelContainer.waitForMessage(); | 1103 channelContainer.waitForMessage(); |
1105 assertEquals("12", channelContainer.getMessage()); | 1104 assertEquals("12", channelContainer.getMessage()); |
1106 } | 1105 } |
1107 } | 1106 } |
OLD | NEW |