| Index: android_webview/javatests/src/org/chromium/android_webview/test/JniCrashTest.java
|
| diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/JniCrashTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/JniCrashTest.java
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..856dd52959b4d244be3deaba915f03855da75d06
|
| --- /dev/null
|
| +++ b/android_webview/javatests/src/org/chromium/android_webview/test/JniCrashTest.java
|
| @@ -0,0 +1,52 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +package org.chromium.android_webview.test;
|
| +
|
| +import android.os.Handler;
|
| +import android.os.Message;
|
| +import android.test.suitebuilder.annotation.LargeTest;
|
| +
|
| +import org.chromium.base.test.util.Feature;
|
| +
|
| +/**
|
| + * Test class ensuring we handle Java exceptions thrown in WebView callbacks correctly.
|
| + */
|
| +public class JniCrashTest extends SeparateServiceTestBase {
|
| + private static final String TAG = JniCrashTest.class.getSimpleName();
|
| +
|
| + /**
|
| + * Ensure that java exceptions thrown in the shouldOverrideUrlLoading callback are propagated
|
| + * properly to the process using WebView (rather than causing a native crash).
|
| + *
|
| + * OBS! This test does not support method annotations such as DisableHardwareAccelerationForTest
|
| + * since the actual "WebView" creation is performed in another process.
|
| + */
|
| + @LargeTest
|
| + @Feature({"AndroidWebView"})
|
| + public void testShouldOverrideUrlLoadingCrash() throws Exception {
|
| + runServiceTestBlocking(
|
| + new ShouldOverrideUrlLoadingJniCrashTestRunner(), new Handler.Callback() {
|
| + @Override
|
| + public boolean handleMessage(Message message) {
|
| + switch (message.what) {
|
| + case ShouldOverrideUrlLoadingJniCrashTestRunner
|
| + .RETURN_JNI_CRASH_TEST_SUCCESS:
|
| + return true;
|
| + case ShouldOverrideUrlLoadingJniCrashTestRunner
|
| + .RETURN_JNI_CRASH_TEST_FAILED:
|
| + fail("Something went wrong in the separate process, see logcat");
|
| + return true;
|
| + default:
|
| + fail("Received an unexpected message response " + message);
|
| + return false;
|
| + }
|
| + }
|
| + }, true /* unBindAndStopService */);
|
| + // Since we override the UnhandledExceptionHandler in the separate WebView process we
|
| + // should ensure we kill it properly.
|
| + killSeparateProcess();
|
| + resetSeparateProcessPid();
|
| + }
|
| +}
|
|
|