summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authormpcomplete@google.com <mpcomplete@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-12 22:18:18 +0000
committermpcomplete@google.com <mpcomplete@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-12 22:18:18 +0000
commit937e4c7b4b4744353ea2dc6d01749146664e3e76 (patch)
tree65cbce58cbad33d3b380f071f1f29840ed2c0f83 /chrome
parent13a8adfee148682b7f9489e34c428b37f465675d (diff)
downloadchromium_src-937e4c7b4b4744353ea2dc6d01749146664e3e76.zip
chromium_src-937e4c7b4b4744353ea2dc6d01749146664e3e76.tar.gz
chromium_src-937e4c7b4b4744353ea2dc6d01749146664e3e76.tar.bz2
Fix http://code.google.com/p/chromium/issues/detail?id=4270. Test case added.
BUG=4270 Review URL: http://codereview.chromium.org/10620 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5310 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/plugin/webplugin_delegate_stub.cc2
-rw-r--r--chrome/test/data/npapi/self_delete_plugin_invoke_alert.html43
-rw-r--r--chrome/test/ui/npapi_uitest.cpp19
3 files changed, 63 insertions, 1 deletions
diff --git a/chrome/plugin/webplugin_delegate_stub.cc b/chrome/plugin/webplugin_delegate_stub.cc
index 69177e1..158dc45 100644
--- a/chrome/plugin/webplugin_delegate_stub.cc
+++ b/chrome/plugin/webplugin_delegate_stub.cc
@@ -52,7 +52,7 @@ WebPluginDelegateStub::~WebPluginDelegateStub() {
if (channel_->in_send()) {
// The delegate or an npobject is in the callstack, so don't delete it
// right away.
- MessageLoop::current()->PostTask(FROM_HERE,
+ MessageLoop::current()->PostNonNestableTask(FROM_HERE,
new FinishDestructionTask(delegate_, webplugin_));
} else {
// Safe to delete right away.
diff --git a/chrome/test/data/npapi/self_delete_plugin_invoke_alert.html b/chrome/test/data/npapi/self_delete_plugin_invoke_alert.html
new file mode 100644
index 0000000..e056cf5
--- /dev/null
+++ b/chrome/test/data/npapi/self_delete_plugin_invoke_alert.html
@@ -0,0 +1,43 @@
+<html>
+<head>
+<title>Self Deleting Plugin Test - Invoke</title>
+<script src="npapi.js"></script>
+<script>
+function DeletePluginWithinScript() {
+ var plugin_div = document.getElementById("PluginDiv");
+ plugin_div.innerHTML = "Object Deleted";
+ alert('plugin deleted');
+}
+function SuccessCallback() {
+ onSuccess("self_delete_plugin_invoke_alert", 1);
+}
+function TimeoutCallback() {
+ var plg = window.document["plg"];
+ var plg2 = window.document["plg2"];
+ plg.testCallbackAndGetValue("DeletePluginWithinScript");
+ plg2.testCallback("SuccessCallback"); // will fail if the plugin crashed
+}
+</script>
+</head>
+
+<body>
+
+<h2>Test to delete a plugin during script execution</h2>
+
+<p>
+This test is for a corner case when a plugin executes a script
+that deletes the invoking plugin itself then shows a modal dialog.
+See http://code.google.com/p/chromium/issues/detail?id=4270.
+</p>
+
+<DIV ID=PluginDiv>
+<embed name="plg" type="application/x-webkit-test-netscape"></embed>
+</DIV>
+<embed name="plg2" type="application/x-webkit-test-netscape"></embed>
+<script>
+ setTimeout('TimeoutCallback()', 0);
+</script>
+
+</body>
+</html>
+
diff --git a/chrome/test/ui/npapi_uitest.cpp b/chrome/test/ui/npapi_uitest.cpp
index 2657220..1da15c46 100644
--- a/chrome/test/ui/npapi_uitest.cpp
+++ b/chrome/test/ui/npapi_uitest.cpp
@@ -48,6 +48,7 @@
#include "base/file_util.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/test/automation/tab_proxy.h"
+#include "chrome/test/automation/window_proxy.h"
#include "chrome/test/ui/npapi_test_helper.h"
#include "net/base/net_util.h"
@@ -167,6 +168,24 @@ TEST_F(NPAPITester, SelfDeletePluginInvoke) {
kShortWaitTimeout);
}
+// Tests if a plugin executing a self deleting script using Invoke with
+// a modal dialog showing works without crashing or hanging
+TEST_F(NPAPITester, SelfDeletePluginInvokeAlert) {
+ std::wstring test_case = L"self_delete_plugin_invoke_alert.html";
+ GURL url = GetTestUrl(L"npapi", test_case);
+ NavigateToURL(url);
+
+ // Wait for the alert dialog and then close it.
+ automation()->WaitForAppModalDialog(5000);
+ scoped_ptr<WindowProxy> window(automation()->GetActiveWindow());
+ ASSERT_TRUE(window.get());
+ ASSERT_TRUE(window->SimulateOSKeyPress(VK_ESCAPE, 0));
+
+ WaitForFinish("self_delete_plugin_invoke_alert", "1", url,
+ kTestCompleteCookie, kTestCompleteSuccess,
+ kShortWaitTimeout);
+}
+
// Tests if a plugin executing a self deleting script in the context of
// a synchronous paint event works correctly
TEST_F(NPAPIVisiblePluginTester, SelfDeletePluginInvokeInSynchronousPaint) {