Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(577)

Side by Side Diff: android_webview/javatests/src/org/chromium/android_webview/test/PopupWindowTest.java

Issue 970883002: [Android WebView] Synthesize a fake page loading event on page source modification (Re-land) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed findbugs warning Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.test.suitebuilder.annotation.SmallTest; 8 import android.test.suitebuilder.annotation.SmallTest;
9 9
10 import org.chromium.android_webview.AwContents; 10 import org.chromium.android_webview.AwContents;
11 import org.chromium.android_webview.test.util.CommonResources; 11 import org.chromium.android_webview.test.util.CommonResources;
12 import org.chromium.base.test.util.Feature; 12 import org.chromium.base.test.util.Feature;
13 import org.chromium.base.test.util.MinAndroidSdkLevel; 13 import org.chromium.base.test.util.MinAndroidSdkLevel;
14 import org.chromium.content.browser.test.util.TestCallbackHelperContainer;
14 import org.chromium.net.test.util.TestWebServer; 15 import org.chromium.net.test.util.TestWebServer;
15 16
16 /** 17 /**
17 * Tests for pop up window flow. 18 * Tests for pop up window flow.
18 */ 19 */
19 @MinAndroidSdkLevel(Build.VERSION_CODES.KITKAT) 20 @MinAndroidSdkLevel(Build.VERSION_CODES.KITKAT)
20 public class PopupWindowTest extends AwTestBase { 21 public class PopupWindowTest extends AwTestBase {
21 private TestAwContentsClient mParentContentsClient; 22 private TestAwContentsClient mParentContentsClient;
22 private AwTestContainerView mParentContainerView; 23 private AwTestContainerView mParentContainerView;
23 private AwContents mParentContents; 24 private AwContents mParentContents;
(...skipping 25 matching lines...) Expand all
49 final String parentPageHtml = CommonResources.makeHtmlPageFrom("", "<scr ipt>" 50 final String parentPageHtml = CommonResources.makeHtmlPageFrom("", "<scr ipt>"
50 + "function tryOpenWindow() {" 51 + "function tryOpenWindow() {"
51 + " var newWindow = window.open('" + popupPath + "');" 52 + " var newWindow = window.open('" + popupPath + "');"
52 + "}</script>"); 53 + "}</script>");
53 54
54 final String popupPageHtml = CommonResources.makeHtmlPageFrom( 55 final String popupPageHtml = CommonResources.makeHtmlPageFrom(
55 "<title>" + POPUP_TITLE + "</title>", 56 "<title>" + POPUP_TITLE + "</title>",
56 "This is a popup window"); 57 "This is a popup window");
57 58
58 triggerPopup(mParentContents, mParentContentsClient, mWebServer, parentP ageHtml, 59 triggerPopup(mParentContents, mParentContentsClient, mWebServer, parentP ageHtml,
59 popupPageHtml, "/popup.html", "tryOpenWindow()"); 60 popupPageHtml, popupPath, "tryOpenWindow()");
60 AwContents popupContents = connectPendingPopup(mParentContents); 61 AwContents popupContents = connectPendingPopup(mParentContents).popupCon tents;
61 assertEquals(POPUP_TITLE, getTitleOnUiThread(popupContents)); 62 assertEquals(POPUP_TITLE, getTitleOnUiThread(popupContents));
62 } 63 }
64
65 @SmallTest
66 @Feature({"AndroidWebView"})
67 public void testOnPageFinishedCalledOnDomModificationAfterNavigation() throw s Throwable {
68 final String popupPath = "/popup.html";
69 final String parentPageHtml = CommonResources.makeHtmlPageFrom("", "<scr ipt>"
70 + "function tryOpenWindow() {"
71 + " window.popupWindow = window.open('" + popupPath + " ');"
72 + "}"
73 + "function modifyDomOfPopup() {"
74 + " window.popupWindow.document.body.innerHTML = 'Hello from the parent!';"
75 + "}</script>");
76
77 triggerPopup(mParentContents, mParentContentsClient, mWebServer, parentP ageHtml,
78 null, popupPath, "tryOpenWindow()");
79 TestCallbackHelperContainer.OnPageFinishedHelper onPageFinishedHelper =
80 connectPendingPopup(mParentContents).popupContentsClient.getOnPa geFinishedHelper();
81 final int onPageFinishedCallCount = onPageFinishedHelper.getCallCount();
82 executeJavaScriptAndWaitForResult(mParentContents, mParentContentsClient ,
83 "modifyDomOfPopup()");
84 onPageFinishedHelper.waitForCallback(onPageFinishedCallCount);
85 assertEquals("about:blank", onPageFinishedHelper.getUrl());
86 }
63 } 87 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698