| 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; |
| 11 | 11 |
| 12 import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout; | 12 import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout; |
| 13 import static org.chromium.content.browser.test.util.TestCallbackHelperContainer
.OnPageFinishedHelper; | 13 import static org.chromium.content.browser.test.util.TestCallbackHelperContainer
.OnPageFinishedHelper; |
| 14 | 14 |
| 15 import org.chromium.android_webview.AwContents; | 15 import org.chromium.android_webview.AwContents; |
| 16 import org.chromium.android_webview.AwMessagePort; | 16 import org.chromium.android_webview.AwMessagePort; |
| 17 import org.chromium.android_webview.AwMessagePortService; | 17 import org.chromium.android_webview.AwMessagePortService; |
| 18 import org.chromium.android_webview.test.util.CommonResources; | 18 import org.chromium.android_webview.test.util.CommonResources; |
| 19 import org.chromium.base.ThreadUtils; | 19 import org.chromium.base.ThreadUtils; |
| 20 import org.chromium.base.annotations.SuppressFBWarnings; |
| 20 import org.chromium.base.test.util.DisabledTest; | 21 import org.chromium.base.test.util.DisabledTest; |
| 21 import org.chromium.base.test.util.Feature; | 22 import org.chromium.base.test.util.Feature; |
| 22 import org.chromium.base.test.util.MinAndroidSdkLevel; | 23 import org.chromium.base.test.util.MinAndroidSdkLevel; |
| 23 import org.chromium.content.browser.test.util.Criteria; | 24 import org.chromium.content.browser.test.util.Criteria; |
| 24 import org.chromium.content.browser.test.util.CriteriaHelper; | 25 import org.chromium.content.browser.test.util.CriteriaHelper; |
| 25 import org.chromium.net.test.util.TestWebServer; | 26 import org.chromium.net.test.util.TestWebServer; |
| 26 | 27 |
| 27 import java.util.concurrent.Callable; | 28 import java.util.concurrent.Callable; |
| 28 import java.util.concurrent.CountDownLatch; | 29 import java.util.concurrent.CountDownLatch; |
| 29 | 30 |
| 30 /** | 31 /** |
| 31 * The tests for content postMessage API. | 32 * The tests for content postMessage API. |
| 32 */ | 33 */ |
| 33 @MinAndroidSdkLevel(Build.VERSION_CODES.KITKAT) | 34 @MinAndroidSdkLevel(Build.VERSION_CODES.KITKAT) |
| 35 @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE") |
| 34 public class PostMessageTest extends AwTestBase { | 36 public class PostMessageTest extends AwTestBase { |
| 35 | 37 |
| 36 private static final String SOURCE_ORIGIN = ""; | 38 private static final String SOURCE_ORIGIN = ""; |
| 37 // Timeout to failure, in milliseconds | 39 // Timeout to failure, in milliseconds |
| 38 private static final long TIMEOUT = scaleTimeout(5000); | 40 private static final long TIMEOUT = scaleTimeout(5000); |
| 39 | 41 |
| 40 // Inject to the page to verify received messages. | 42 // Inject to the page to verify received messages. |
| 41 private static class MessageObject { | 43 private static class MessageObject { |
| 42 private boolean mReady; | 44 private boolean mReady; |
| 43 private String mData; | 45 private String mData; |
| (...skipping 1053 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1097 } | 1099 } |
| 1098 }, null); | 1100 }, null); |
| 1099 mAwContents.postMessageToFrame(null, WEBVIEW_MESSAGE, mWebServer
.getBaseUrl(), | 1101 mAwContents.postMessageToFrame(null, WEBVIEW_MESSAGE, mWebServer
.getBaseUrl(), |
| 1100 new AwMessagePort[] {channel[1]}); | 1102 new AwMessagePort[] {channel[1]}); |
| 1101 } | 1103 } |
| 1102 }); | 1104 }); |
| 1103 channelContainer.waitForMessage(); | 1105 channelContainer.waitForMessage(); |
| 1104 assertEquals("12", channelContainer.getMessage()); | 1106 assertEquals("12", channelContainer.getMessage()); |
| 1105 } | 1107 } |
| 1106 } | 1108 } |
| OLD | NEW |