| 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.test.suitebuilder.annotation.SmallTest; | 7 import android.test.suitebuilder.annotation.SmallTest; |
| 8 | 8 |
| 9 import org.chromium.android_webview.AwContents; | 9 import org.chromium.android_webview.AwContents; |
| 10 import org.chromium.android_webview.test.util.CommonResources; | 10 import org.chromium.android_webview.test.util.CommonResources; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 public void testOnPageFinishedCalledOnDomModificationAfterNavigation() throw
s Throwable { | 70 public void testOnPageFinishedCalledOnDomModificationAfterNavigation() throw
s Throwable { |
| 71 final String popupPath = "/popup.html"; | 71 final String popupPath = "/popup.html"; |
| 72 final String parentPageHtml = CommonResources.makeHtmlPageFrom("", "<scr
ipt>" | 72 final String parentPageHtml = CommonResources.makeHtmlPageFrom("", "<scr
ipt>" |
| 73 + "function tryOpenWindow() {" | 73 + "function tryOpenWindow() {" |
| 74 + " window.popupWindow = window.open('" + popupPath + "
');" | 74 + " window.popupWindow = window.open('" + popupPath + "
');" |
| 75 + "}" | 75 + "}" |
| 76 + "function modifyDomOfPopup() {" | 76 + "function modifyDomOfPopup() {" |
| 77 + " window.popupWindow.document.body.innerHTML = 'Hello
from the parent!';" | 77 + " window.popupWindow.document.body.innerHTML = 'Hello
from the parent!';" |
| 78 + "}</script>"); | 78 + "}</script>"); |
| 79 | 79 |
| 80 final String popupPageHtml = CommonResources.makeHtmlPageFrom( |
| 81 "<title>" + POPUP_TITLE + "</title>", |
| 82 "This is a popup window"); |
| 83 |
| 80 triggerPopup(mParentContents, mParentContentsClient, mWebServer, parentP
ageHtml, | 84 triggerPopup(mParentContents, mParentContentsClient, mWebServer, parentP
ageHtml, |
| 81 null, popupPath, "tryOpenWindow()"); | 85 popupPageHtml, popupPath, "tryOpenWindow()"); |
| 86 PopupInfo popupInfo = connectPendingPopup(mParentContents); |
| 87 assertEquals(POPUP_TITLE, getTitleOnUiThread(popupInfo.popupContents)); |
| 88 |
| 82 TestCallbackHelperContainer.OnPageFinishedHelper onPageFinishedHelper = | 89 TestCallbackHelperContainer.OnPageFinishedHelper onPageFinishedHelper = |
| 83 connectPendingPopup(mParentContents).popupContentsClient.getOnPa
geFinishedHelper(); | 90 popupInfo.popupContentsClient.getOnPageFinishedHelper(); |
| 84 final int onPageFinishedCallCount = onPageFinishedHelper.getCallCount(); | 91 final int onPageFinishedCallCount = onPageFinishedHelper.getCallCount(); |
| 92 |
| 85 executeJavaScriptAndWaitForResult(mParentContents, mParentContentsClient
, | 93 executeJavaScriptAndWaitForResult(mParentContents, mParentContentsClient
, |
| 86 "modifyDomOfPopup()"); | 94 "modifyDomOfPopup()"); |
| 95 // Test that |waitForCallback| does not time out. |
| 87 onPageFinishedHelper.waitForCallback(onPageFinishedCallCount); | 96 onPageFinishedHelper.waitForCallback(onPageFinishedCallCount); |
| 88 assertEquals("about:blank", onPageFinishedHelper.getUrl()); | |
| 89 } | 97 } |
| 90 | 98 |
| 91 @SmallTest | 99 @SmallTest |
| 92 @Feature({"AndroidWebView"}) | 100 @Feature({"AndroidWebView"}) |
| 93 public void testPopupWindowTextHandle() throws Throwable { | 101 public void testPopupWindowTextHandle() throws Throwable { |
| 94 final String popupPath = "/popup.html"; | 102 final String popupPath = "/popup.html"; |
| 95 final String parentPageHtml = CommonResources.makeHtmlPageFrom("", "<scr
ipt>" | 103 final String parentPageHtml = CommonResources.makeHtmlPageFrom("", "<scr
ipt>" |
| 96 + "function tryOpenWindow() {" | 104 + "function tryOpenWindow() {" |
| 97 + " var newWindow = window.open('" + popupPath + "');" | 105 + " var newWindow = window.open('" + popupPath + "');" |
| 98 + "}</script>"); | 106 + "}</script>"); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 152 |
| 145 private void hideSelectActionMode(final ContentViewCore cvc) { | 153 private void hideSelectActionMode(final ContentViewCore cvc) { |
| 146 getInstrumentation().runOnMainSync(new Runnable() { | 154 getInstrumentation().runOnMainSync(new Runnable() { |
| 147 @Override | 155 @Override |
| 148 public void run() { | 156 public void run() { |
| 149 cvc.hideSelectActionMode(); | 157 cvc.hideSelectActionMode(); |
| 150 } | 158 } |
| 151 }); | 159 }); |
| 152 } | 160 } |
| 153 } | 161 } |
| OLD | NEW |