| 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;
|
|
|