OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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.os.Handler; | 7 import android.os.Handler; |
8 import android.os.Looper; | 8 import android.os.Looper; |
9 import android.test.suitebuilder.annotation.SmallTest; | 9 import android.test.suitebuilder.annotation.SmallTest; |
10 | 10 |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 @SmallTest | 326 @SmallTest |
327 @Feature({"AndroidWebView", "Android-JavaBridge"}) | 327 @Feature({"AndroidWebView", "Android-JavaBridge"}) |
328 public void testObjectPersistsAcrossPageLoads() throws Throwable { | 328 public void testObjectPersistsAcrossPageLoads() throws Throwable { |
329 assertEquals("object", executeJavaScriptAndGetStringResult("typeof testC
ontroller")); | 329 assertEquals("object", executeJavaScriptAndGetStringResult("typeof testC
ontroller")); |
330 synchronousPageReload(); | 330 synchronousPageReload(); |
331 assertEquals("object", executeJavaScriptAndGetStringResult("typeof testC
ontroller")); | 331 assertEquals("object", executeJavaScriptAndGetStringResult("typeof testC
ontroller")); |
332 } | 332 } |
333 | 333 |
334 @SmallTest | 334 @SmallTest |
335 @Feature({"AndroidWebView", "Android-JavaBridge"}) | 335 @Feature({"AndroidWebView", "Android-JavaBridge"}) |
336 public void testClientPropertiesPersistAcrossPageLoads() throws Throwable { | 336 public void testCustomPropertiesCleanedUpOnPageReloads() throws Throwable { |
337 assertEquals("object", executeJavaScriptAndGetStringResult("typeof testC
ontroller")); | 337 assertEquals("object", executeJavaScriptAndGetStringResult("typeof testC
ontroller")); |
338 executeJavaScript("testController.myProperty = 42;"); | 338 executeJavaScript("testController.myProperty = 42;"); |
339 assertEquals("42", executeJavaScriptAndGetStringResult("testController.m
yProperty")); | 339 assertEquals("42", executeJavaScriptAndGetStringResult("testController.m
yProperty")); |
340 synchronousPageReload(); | 340 synchronousPageReload(); |
341 assertEquals("42", executeJavaScriptAndGetStringResult("testController.m
yProperty")); | 341 assertEquals("object", executeJavaScriptAndGetStringResult("typeof testC
ontroller")); |
| 342 assertEquals("undefined", executeJavaScriptAndGetStringResult("testContr
oller.myProperty")); |
342 } | 343 } |
343 | 344 |
344 @SmallTest | 345 @SmallTest |
345 @Feature({"AndroidWebView", "Android-JavaBridge"}) | 346 @Feature({"AndroidWebView", "Android-JavaBridge"}) |
346 public void testSameObjectInjectedMultipleTimes() throws Throwable { | 347 public void testSameObjectInjectedMultipleTimes() throws Throwable { |
347 class TestObject { | 348 class TestObject { |
348 private int mNumMethodInvocations; | 349 private int mNumMethodInvocations; |
349 public void method() { mTestController.setIntValue(++mNumMethodInvoc
ations); } | 350 public void method() { mTestController.setIntValue(++mNumMethodInvoc
ations); } |
350 } | 351 } |
351 final TestObject testObject = new TestObject(); | 352 final TestObject testObject = new TestObject(); |
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
902 } while (mTestController.getStringValue() == null || | 903 } while (mTestController.getStringValue() == null || |
903 // When an exception in an injected method happens, the
function returns | 904 // When an exception in an injected method happens, the
function returns |
904 // null. We ignore this and wait until the exception on
the browser side | 905 // null. We ignore this and wait until the exception on
the browser side |
905 // will be thrown. | 906 // will be thrown. |
906 mTestController.getStringValue().equals("null")); | 907 mTestController.getStringValue().equals("null")); |
907 } | 908 } |
908 }); | 909 }); |
909 return mTestController.getStringValue(); | 910 return mTestController.getStringValue(); |
910 } | 911 } |
911 } | 912 } |
OLD | NEW |