summaryrefslogtreecommitdiffstats
path: root/android_webview
diff options
context:
space:
mode:
authorigsolla <igsolla@chromium.org>2015-01-12 07:24:20 -0800
committerCommit bot <commit-bot@chromium.org>2015-01-12 15:25:17 +0000
commitde81adf0a1dcca10a26ada9b2509637232cee5ef (patch)
tree62ca9af4ea6a12aadd4cd82de99b9e1736a3d3c9 /android_webview
parent6e47c3e25c0d3f4a2bcdf24f9b3c8cb9072dc839 (diff)
downloadchromium_src-de81adf0a1dcca10a26ada9b2509637232cee5ef.zip
chromium_src-de81adf0a1dcca10a26ada9b2509637232cee5ef.tar.gz
chromium_src-de81adf0a1dcca10a26ada9b2509637232cee5ef.tar.bz2
[WebView] Fix possible stack overflow when exiting fullscreen.
BUG=448032 Review URL: https://codereview.chromium.org/809073008 Cr-Commit-Position: refs/heads/master@{#311050}
Diffstat (limited to 'android_webview')
-rw-r--r--android_webview/java/src/org/chromium/android_webview/AwContentViewClient.java6
-rw-r--r--android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientFullScreenTest.java29
-rw-r--r--android_webview/javatests/src/org/chromium/android_webview/test/FullScreenVideoTestAwContentsClient.java11
3 files changed, 44 insertions, 2 deletions
diff --git a/android_webview/java/src/org/chromium/android_webview/AwContentViewClient.java b/android_webview/java/src/org/chromium/android_webview/AwContentViewClient.java
index 4d8b275..93ae5dd 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwContentViewClient.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwContentViewClient.java
@@ -104,7 +104,9 @@ public class AwContentViewClient extends ContentViewClient implements ContentVid
WebChromeClient.CustomViewCallback cb = new WebChromeClient.CustomViewCallback() {
@Override
public void onCustomViewHidden() {
- mAwContents.requestExitFullscreen();
+ if (mCustomView != null) {
+ mAwContents.requestExitFullscreen();
+ }
}
};
mCustomView = new FrameLayout(mContext);
@@ -117,9 +119,9 @@ public class AwContentViewClient extends ContentViewClient implements ContentVid
*/
public void exitFullscreen() {
if (mCustomView != null) {
+ mCustomView = null;
mAwContents.exitFullScreen();
mAwContentsClient.onHideCustomView();
- mCustomView = null;
}
}
}
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientFullScreenTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientFullScreenTest.java
index 336f477..b991a9c 100644
--- a/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientFullScreenTest.java
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientFullScreenTest.java
@@ -158,6 +158,19 @@ public class AwContentsClientFullScreenTest extends AwTestBase {
sendKeys(KeyEvent.KEYCODE_BACK);
mContentsClient.waitForCustomViewHidden();
assertFalse(mContentsClient.wasOnUnhandledKeyUpEventCalled());
+ assertWaitForIsEmbedded();
+ }
+
+ @MediumTest
+ @Feature({"AndroidWebView"})
+ public void testExitFullscreenEndsIfAppInvokesCallbackFromOnHideCustomView() throws Throwable {
+ mContentsClient.setOnHideCustomViewRunnable(new Runnable() {
+ @Override
+ public void run() {
+ mContentsClient.getExitCallback().onCustomViewHidden();
+ }
+ });
+ doTestOnShowAndHideCustomViewWithCallback(VIDEO_TEST_URL);
}
@MediumTest
@@ -449,6 +462,21 @@ public class AwContentsClientFullScreenTest extends AwTestBase {
}));
}
+ private void assertWaitForIsEmbedded() throws InterruptedException {
+ // We need to poll because the Javascript state is updated asynchronously
+ assertTrue(CriteriaHelper.pollForCriteria(new Criteria() {
+ @Override
+ public boolean isSatisfied() {
+ try {
+ return !DOMUtils.isFullscreen(getWebContentsOnUiThread());
+ } catch (InterruptedException | TimeoutException e) {
+ fail(e.getMessage());
+ return false;
+ }
+ }
+ }));
+ }
+
private void assertContainsContentVideoView() throws Exception {
VideoSurfaceViewUtils.assertContainsOneContentVideoView(this,
mContentsClient.getCustomView());
@@ -470,6 +498,7 @@ public class AwContentsClientFullScreenTest extends AwTestBase {
doOnShowCustomViewTest(videoTestUrl);
runTestOnUiThread(existFullscreen);
mContentsClient.waitForCustomViewHidden();
+ assertWaitForIsEmbedded();
}
private void doOnShowCustomViewTest(String videoTestUrl) throws Exception {
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/FullScreenVideoTestAwContentsClient.java b/android_webview/javatests/src/org/chromium/android_webview/test/FullScreenVideoTestAwContentsClient.java
index 6d1c06b1..19d9ad5 100644
--- a/android_webview/javatests/src/org/chromium/android_webview/test/FullScreenVideoTestAwContentsClient.java
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/FullScreenVideoTestAwContentsClient.java
@@ -29,6 +29,7 @@ public class FullScreenVideoTestAwContentsClient extends TestAwContentsClient {
private CallbackHelper mOnHideCustomViewCallbackHelper = new CallbackHelper();
private CallbackHelper mOnUnhandledKeyUpEventCallbackHelper = new CallbackHelper();
+ private Runnable mOnHideCustomViewRunnable;
private final Activity mActivity;
private final boolean mAllowHardwareAcceleration;
private View mCustomView;
@@ -61,10 +62,20 @@ public class FullScreenVideoTestAwContentsClient extends TestAwContentsClient {
mOnShowCustomViewCallbackHelper.notifyCalled();
}
+ /**
+ * Sets a task that will be run when {@link #onHideCustomView()} is invoked.
+ */
+ public void setOnHideCustomViewRunnable(Runnable runnable) {
+ mOnHideCustomViewRunnable = runnable;
+ }
+
@Override
public void onHideCustomView() {
mActivity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
mOnHideCustomViewCallbackHelper.notifyCalled();
+ if (mOnHideCustomViewRunnable != null) {
+ mOnHideCustomViewRunnable.run();
+ }
}
public WebChromeClient.CustomViewCallback getExitCallback() {