diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-23 19:22:00 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-23 19:22:00 +0000 |
commit | 90aca24d74f13b7fb864caafb92e088a91b15903 (patch) | |
tree | 05bc6c5edeecefa91d06a6404f3925644e633b57 | |
parent | d3ef5942dc19d90fe64e721c0733573d4a89caa5 (diff) | |
download | chromium_src-90aca24d74f13b7fb864caafb92e088a91b15903.zip chromium_src-90aca24d74f13b7fb864caafb92e088a91b15903.tar.gz chromium_src-90aca24d74f13b7fb864caafb92e088a91b15903.tar.bz2 |
Add a regression test for the renderer hang when a plugin's NP_Initialize function crashes.
BUG=25104
Review URL: http://codereview.chromium.org/337004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29923 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/test/data/npapi/no_hang_if_init_crashes.html | 28 | ||||
-rw-r--r-- | chrome/test/ui/npapi_uitest.cc | 25 | ||||
-rw-r--r-- | webkit/glue/plugins/test/plugin_client.cc | 19 |
3 files changed, 70 insertions, 2 deletions
diff --git a/chrome/test/data/npapi/no_hang_if_init_crashes.html b/chrome/test/data/npapi/no_hang_if_init_crashes.html new file mode 100644 index 0000000..00e76a9 --- /dev/null +++ b/chrome/test/data/npapi/no_hang_if_init_crashes.html @@ -0,0 +1,28 @@ +<html> + +<head> +<script src="npapi.js"></script> +</head> + + +<body> +<div id="statusPanel" style="border: 1px solid red; width: 100%"> +Test running.... +</div> + + +No Hang If Init Crashes<p> + +Tests that if a plugin crashes during NP_Initialize the renderer doesn't hang. + +<embed type="application/vnd.npapi-test" + src="foo" + name="no_hang_if_init_crashes" + id="1" + mode="np_embed" +> +<script> +setTimeout('onSuccess("no_hang_if_init_crashes", 1);', 0); +</script> +</body> +</html> diff --git a/chrome/test/ui/npapi_uitest.cc b/chrome/test/ui/npapi_uitest.cc index 39e0571..34ba3fd 100644 --- a/chrome/test/ui/npapi_uitest.cc +++ b/chrome/test/ui/npapi_uitest.cc @@ -338,3 +338,28 @@ TEST_F(NPAPITester, EnsureScriptingWorksInDestroy) { kTestCompleteCookie, kTestCompleteSuccess, kShortWaitTimeout); } + +// This test uses a Windows Event to signal to the plugin that it should crash +// on NP_Initialize. +#if defined(OS_WIN) + +TEST_F(NPAPITester, NoHangIfInitCrashes) { + if (UITest::in_process_renderer()) + return; + + // Only Windows implements the crash service for now. +#if defined(OS_WIN) + expected_crashes_ = 1; +#endif + + HANDLE crash_event = CreateEvent(NULL, TRUE, FALSE, L"TestPluginCrashOnInit"); + SetEvent(crash_event); + GURL url = GetTestUrl(L"npapi", L"no_hang_if_init_crashes.html"); + NavigateToURL(url); + WaitForFinish("no_hang_if_init_crashes", "1", url, + kTestCompleteCookie, kTestCompleteSuccess, + kShortWaitTimeout); + CloseHandle(crash_event); +} + +#endif diff --git a/webkit/glue/plugins/test/plugin_client.cc b/webkit/glue/plugins/test/plugin_client.cc index 34b814f..1146a6a 100644 --- a/webkit/glue/plugins/test/plugin_client.cc +++ b/webkit/glue/plugins/test/plugin_client.cc @@ -1,7 +1,11 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 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. +#if defined(OS_WIN) +#include <windows.h> +#endif + #include "base/string_util.h" #include "webkit/glue/plugins/test/plugin_client.h" #include "webkit/glue/plugins/test/plugin_arguments_test.h" @@ -62,6 +66,16 @@ NPError PluginClient::Initialize(NPNetscapeFuncs* pFuncs) { return NPERR_INCOMPATIBLE_VERSION_ERROR; } +#if defined(OS_WIN) + // Check if we should crash. + HANDLE crash_event = CreateEvent(NULL, TRUE, FALSE, L"TestPluginCrashOnInit"); + if (WaitForSingleObject(crash_event, 0) == WAIT_OBJECT_0) { + int *zero = NULL; + *zero = 0; + } + CloseHandle(crash_event); +#endif + host_functions_ = pFuncs; return NPERR_NO_ERROR; @@ -112,7 +126,8 @@ NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, } else if (test_name == "execute_script_delete_in_paint" || test_name == "execute_script_delete_in_mouse_move" || test_name == "delete_frame_test" || - test_name == "multiple_instances_sync_calls") { + test_name == "multiple_instances_sync_calls" || + test_name == "no_hang_if_init_crashes") { new_test = new NPAPIClient::WindowlessPluginTest(instance, NPAPIClient::PluginClient::HostFunctions(), test_name); windowless_plugin = true; |