| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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.MediumTest; | 7 import android.test.suitebuilder.annotation.MediumTest; |
| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 } | 98 } |
| 99 | 99 |
| 100 /** | 100 /** |
| 101 * Tests whether a page was successfully reloaded. | 101 * Tests whether a page was successfully reloaded. |
| 102 * Checks to make sure that OnPageFinished events were fired and that the ti
mestamps of when | 102 * Checks to make sure that OnPageFinished events were fired and that the ti
mestamps of when |
| 103 * the page loaded are different after the reload. | 103 * the page loaded are different after the reload. |
| 104 */ | 104 */ |
| 105 @MediumTest | 105 @MediumTest |
| 106 @Feature({"Navigation"}) | 106 @Feature({"Navigation"}) |
| 107 public void testPageReload() throws Throwable { | 107 public void testPageReload() throws Throwable { |
| 108 final String htmlLoadTime = "<html><head>" + | 108 final String htmlLoadTime = "<html><head>" |
| 109 "<script type=\"text/javascript\">var loadTimestamp = new Date()
.getTime();" + | 109 + "<script type=\"text/javascript\">var loadTimestamp = new Date
().getTime();" |
| 110 "function getLoadtime() { return loadTimestamp; }</script></head
></html>"; | 110 + "function getLoadtime() { return loadTimestamp; }</script></he
ad></html>"; |
| 111 final String urlLoadTime = UrlUtils.encodeHtmlDataUri(htmlLoadTime); | 111 final String urlLoadTime = UrlUtils.encodeHtmlDataUri(htmlLoadTime); |
| 112 | 112 |
| 113 ContentShellActivity activity = launchContentShellWithUrl(urlLoadTime); | 113 ContentShellActivity activity = launchContentShellWithUrl(urlLoadTime); |
| 114 waitForActiveShellToBeDoneLoading(); | 114 waitForActiveShellToBeDoneLoading(); |
| 115 ContentViewCore contentViewCore = activity.getActiveContentViewCore(); | 115 ContentViewCore contentViewCore = activity.getActiveContentViewCore(); |
| 116 TestCallbackHelperContainer testCallbackHelperContainer = | 116 TestCallbackHelperContainer testCallbackHelperContainer = |
| 117 new TestCallbackHelperContainer(contentViewCore); | 117 new TestCallbackHelperContainer(contentViewCore); |
| 118 OnEvaluateJavaScriptResultHelper javascriptHelper = new OnEvaluateJavaSc
riptResultHelper(); | 118 OnEvaluateJavaScriptResultHelper javascriptHelper = new OnEvaluateJavaSc
riptResultHelper(); |
| 119 | 119 |
| 120 // Grab the first timestamp. | 120 // Grab the first timestamp. |
| 121 javascriptHelper.evaluateJavaScript(contentViewCore.getWebContents(), "g
etLoadtime();"); | 121 javascriptHelper.evaluateJavaScript(contentViewCore.getWebContents(), "g
etLoadtime();"); |
| 122 javascriptHelper.waitUntilHasValue(); | 122 javascriptHelper.waitUntilHasValue(); |
| 123 String firstTimestamp = javascriptHelper.getJsonResultAndClear(); | 123 String firstTimestamp = javascriptHelper.getJsonResultAndClear(); |
| 124 assertNotNull("Timestamp was null.", firstTimestamp); | 124 assertNotNull("Timestamp was null.", firstTimestamp); |
| 125 | 125 |
| 126 // Grab the timestamp after a reload and make sure they don't match. | 126 // Grab the timestamp after a reload and make sure they don't match. |
| 127 reload(contentViewCore.getWebContents().getNavigationController(), | 127 reload(contentViewCore.getWebContents().getNavigationController(), |
| 128 testCallbackHelperContainer); | 128 testCallbackHelperContainer); |
| 129 javascriptHelper.evaluateJavaScript(contentViewCore.getWebContents(), "g
etLoadtime();"); | 129 javascriptHelper.evaluateJavaScript(contentViewCore.getWebContents(), "g
etLoadtime();"); |
| 130 javascriptHelper.waitUntilHasValue(); | 130 javascriptHelper.waitUntilHasValue(); |
| 131 String secondTimestamp = javascriptHelper.getJsonResultAndClear(); | 131 String secondTimestamp = javascriptHelper.getJsonResultAndClear(); |
| 132 assertNotNull("Timestamp was null.", secondTimestamp); | 132 assertNotNull("Timestamp was null.", secondTimestamp); |
| 133 assertFalse("Timestamps matched.", firstTimestamp.equals(secondTimestamp
)); | 133 assertFalse("Timestamps matched.", firstTimestamp.equals(secondTimestamp
)); |
| 134 } | 134 } |
| 135 } | 135 } |
| OLD | NEW |