OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.content.browser; | 5 package org.chromium.content.browser; |
6 | 6 |
7 import android.test.suitebuilder.annotation.SmallTest; | 7 import android.test.suitebuilder.annotation.SmallTest; |
8 | 8 |
9 import org.chromium.base.test.util.Feature; | 9 import org.chromium.base.test.util.Feature; |
10 import org.chromium.base.test.util.UrlUtils; | 10 import org.chromium.base.test.util.UrlUtils; |
(...skipping 22 matching lines...) Expand all Loading... |
33 @Override | 33 @Override |
34 public void run() { | 34 public void run() { |
35 getContentViewCore().addPossiblyUnsafeJavascriptInterface( | 35 getContentViewCore().addPossiblyUnsafeJavascriptInterface( |
36 new Object(), name, null); | 36 new Object(), name, null); |
37 } | 37 } |
38 }); | 38 }); |
39 } | 39 } |
40 | 40 |
41 private String evaluateJsSync(String jsCode) throws Exception { | 41 private String evaluateJsSync(String jsCode) throws Exception { |
42 OnEvaluateJavaScriptResultHelper javascriptHelper = new OnEvaluateJavaSc
riptResultHelper(); | 42 OnEvaluateJavaScriptResultHelper javascriptHelper = new OnEvaluateJavaSc
riptResultHelper(); |
43 javascriptHelper.evaluateJavaScriptForTests(getWebContents(), jsCode); | 43 javascriptHelper.evaluateJavaScript(getWebContents(), jsCode); |
44 javascriptHelper.waitUntilHasValue(); | 44 javascriptHelper.waitUntilHasValue(); |
45 return javascriptHelper.getJsonResultAndClear(); | 45 return javascriptHelper.getJsonResultAndClear(); |
46 } | 46 } |
47 | 47 |
48 private void reloadSync() throws Throwable { | 48 private void reloadSync() throws Throwable { |
49 OnPageFinishedHelper pageFinishedHelper = | 49 OnPageFinishedHelper pageFinishedHelper = |
50 mTestCallbackHelperContainer.getOnPageFinishedHelper(); | 50 mTestCallbackHelperContainer.getOnPageFinishedHelper(); |
51 int currentCallCount = pageFinishedHelper.getCallCount(); | 51 int currentCallCount = pageFinishedHelper.getCallCount(); |
52 runTestOnUiThread(new Runnable() { | 52 runTestOnUiThread(new Runnable() { |
53 @Override | 53 @Override |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 } | 95 } |
96 | 96 |
97 @SmallTest | 97 @SmallTest |
98 @Feature({"AndroidWebView", "Android-JavaBridge"}) | 98 @Feature({"AndroidWebView", "Android-JavaBridge"}) |
99 public void testReloadAfterAddition() throws Throwable { | 99 public void testReloadAfterAddition() throws Throwable { |
100 injectDummyObject("testObject"); | 100 injectDummyObject("testObject"); |
101 reloadSync(); | 101 reloadSync(); |
102 assertEquals("\"object\"", evaluateJsSync("typeof testObject")); | 102 assertEquals("\"object\"", evaluateJsSync("typeof testObject")); |
103 } | 103 } |
104 } | 104 } |
OLD | NEW |