Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2352)

Unified Diff: android_webview/javatests/src/org/chromium/android_webview/test/PostMessageTest.java

Issue 896673005: Add a test to make sure source port cannot be transferred. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: minor stylistic fix Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « android_webview/java/src/org/chromium/android_webview/MessagePort.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/javatests/src/org/chromium/android_webview/test/PostMessageTest.java
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/PostMessageTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/PostMessageTest.java
index 57669be5a5748d1aaa34c1fdb6efd31608646049..e87ca2c9effed42fde4587c67e00c36690fd2d85 100644
--- a/android_webview/javatests/src/org/chromium/android_webview/test/PostMessageTest.java
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/PostMessageTest.java
@@ -145,7 +145,7 @@ public class PostMessageTest extends AwTestBase {
@SmallTest
@Feature({"AndroidWebView", "Android-PostMessage"})
- public void testTransferringSamePortTwiceNotAllowed() throws Throwable {
+ public void testTransferringSamePortTwiceViaPostMessageToFrameNotAllowed() throws Throwable {
loadPage(TEST_PAGE);
final CountDownLatch latch = new CountDownLatch(1);
runTestOnUiThread(new Runnable() {
@@ -175,6 +175,39 @@ public class PostMessageTest extends AwTestBase {
boolean ignore = latch.await(TIMEOUT, java.util.concurrent.TimeUnit.MILLISECONDS);
}
+ // channel[0] and channel[1] are entangled ports, establishing a channel. Verify
+ // it is not allowed to transfer channel[0] on channel[0].postMessage.
+ // TODO(sgurun) Note that the related case of posting channel[1] via
+ // channel[0].postMessage does not throw a JS exception at present. We do not throw
+ // an exception in this case either since the information of entangled port is not
+ // available at the source port. We need a new mechanism to implement to prevent
+ // this case.
+ @SmallTest
+ @Feature({"AndroidWebView", "Android-PostMessage"})
+ public void testTransferSourcePortViaMessageChannelNotAllowed() throws Throwable {
+ loadPage(TEST_PAGE);
+ final CountDownLatch latch = new CountDownLatch(1);
+ runTestOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ ValueCallback<MessagePort[]> callback = new ValueCallback<MessagePort[]>() {
+ @Override
+ public void onReceiveValue(MessagePort[] channel) {
+ try {
+ channel[0].postMessage("1", new MessagePort[]{channel[0]});
+ } catch (IllegalStateException ex) {
+ latch.countDown();
+ return;
+ }
+ fail();
+ }
+ };
+ mAwContents.createMessageChannel(callback);
+ }
+ });
+ boolean ignore = latch.await(TIMEOUT, java.util.concurrent.TimeUnit.MILLISECONDS);
+ }
+
private static class ChannelContainer {
private boolean mReady;
private MessagePort[] mChannel;
« no previous file with comments | « android_webview/java/src/org/chromium/android_webview/MessagePort.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698