diff options
author | wez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-06 17:48:25 +0000 |
---|---|---|
committer | wez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-06 17:48:25 +0000 |
commit | 0c2a2f543db364b6575a58ce7f3b9da1ad38c7ac (patch) | |
tree | fe4f0b725ddd687c168f9d01ad80f2d4987eb344 /chrome/test | |
parent | e4939783eecea0c43eed8b46b8347dcaf9bd03a2 (diff) | |
download | chromium_src-0c2a2f543db364b6575a58ce7f3b9da1ad38c7ac.zip chromium_src-0c2a2f543db364b6575a58ce7f3b9da1ad38c7ac.tar.gz chromium_src-0c2a2f543db364b6575a58ce7f3b9da1ad38c7ac.tar.bz2 |
Add DeletePluginInDeallocate UI test.
BUG=94179
TEST=
Review URL: http://codereview.chromium.org/7806020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99762 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r-- | chrome/test/data/npapi/plugin_delete_in_deallocate.html | 55 | ||||
-rw-r--r-- | chrome/test/ui/npapi_test_helper.cc | 3 | ||||
-rw-r--r-- | chrome/test/ui/npapi_uitest.cc | 16 |
3 files changed, 72 insertions, 2 deletions
diff --git a/chrome/test/data/npapi/plugin_delete_in_deallocate.html b/chrome/test/data/npapi/plugin_delete_in_deallocate.html new file mode 100644 index 0000000..4904469 --- /dev/null +++ b/chrome/test/data/npapi/plugin_delete_in_deallocate.html @@ -0,0 +1,55 @@ +<html> +<head> +<script src="npapi.js"></script> +<script> +function setTestObject(object) { + window.testObject = object; + setTimeout("deleteTestObject()", 0); + var statusPanel = document.getElementById("statusPanel"); + statusPanel.innerText = "Received test object..."; +} + +function deleteTestObject() { + window.testObject = null; + var statusPanel = document.getElementById("statusPanel"); + statusPanel.innerText = "Deleted test object..."; + gc(); +} + +function deletePlugin() { + var statusPanel = document.getElementById("statusPanel"); + statusPanel.innerText = "Deleting plugin..."; + var plugin = document.getElementById("delete_plugin_in_deallocate_test"); + if (plugin.parentNode && plugin.parentNode.removeChild) { + plugin.parentNode.removeChild(plugin); + } +} +</script> +</head> + +<body> +<div id="statusPanel" style="border: 1px solid red; width: 100%"> +Test running.... +</div> + +NPObject Delete in Deallocate<p> + +Tests the case where deallocation of an NPObject belonging to the plugin +triggers scripting which causes the whole plugin to be torn down, and verifies +that the object being deallocated is not deallocated a second time. + + +<embed type="application/vnd.npapi-test" + src="foo" + name="delete_plugin_in_deallocate_test" + id="signaller" + mode="np_embed"> + +<embed type="application/vnd.npapi-test" + src="foo" + name="delete_plugin_in_deallocate_test" + id="delete_plugin_in_deallocate_test" + mode="np_embed"> + +</body> +</html> diff --git a/chrome/test/ui/npapi_test_helper.cc b/chrome/test/ui/npapi_test_helper.cc index 65bf5a7..a376656 100644 --- a/chrome/test/ui/npapi_test_helper.cc +++ b/chrome/test/ui/npapi_test_helper.cc @@ -16,6 +16,9 @@ const char kTestCompleteSuccess[] = "OK"; } // namespace npapi_test. NPAPITesterBase::NPAPITesterBase() { + // Some NPAPI tests schedule garbage collection to force object tear-down. + launch_arguments_.AppendSwitchASCII(switches::kJavaScriptFlags, + "--expose_gc"); } void NPAPITesterBase::SetUp() { diff --git a/chrome/test/ui/npapi_uitest.cc b/chrome/test/ui/npapi_uitest.cc index 2ebf2b6..577ac59 100644 --- a/chrome/test/ui/npapi_uitest.cc +++ b/chrome/test/ui/npapi_uitest.cc @@ -29,14 +29,15 @@ #include "chrome/test/base/ui_test_utils.h" #include "chrome/test/ui/npapi_test_helper.h" #include "content/browser/net/url_request_mock_http_job.h" +#include "content/common/content_switches.h" using npapi_test::kTestCompleteCookie; using npapi_test::kTestCompleteSuccess; -static const FilePath::CharType* kTestDir = FILE_PATH_LITERAL("npapi"); - namespace { +const FilePath::CharType* kTestDir = FILE_PATH_LITERAL("npapi"); + class NPAPIAutomationEnabledTest : public NPAPIVisiblePluginTester { public: NPAPIAutomationEnabledTest() { @@ -159,6 +160,17 @@ TEST_F(NPAPIVisiblePluginTester, SelfDeletePluginInNewStream) { TestTimeouts::action_max_timeout_ms()); } +TEST_F(NPAPIVisiblePluginTester, DeletePluginInDeallocate) { + show_window_ = true; + const FilePath test_case( + FILE_PATH_LITERAL("plugin_delete_in_deallocate.html")); + GURL url = ui_test_utils::GetTestUrl(FilePath(kTestDir), test_case); + ASSERT_NO_FATAL_FAILURE(NavigateToURL(url)); + WaitForFinish("delete_plugin_in_deallocate_test", "signaller", url, + kTestCompleteCookie, kTestCompleteSuccess, + TestTimeouts::action_max_timeout_ms()); +} + #if defined(OS_WIN) // Tests if a plugin has a non zero window rect. TEST_F(NPAPIVisiblePluginTester, VerifyPluginWindowRect) { |