summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-06 19:11:22 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-06 19:11:22 +0000
commit49f69aeb0f507096666e58e037a389712be4e585 (patch)
tree36d2b291928e0e1a539467b26d7186d096956dcf /chrome/test
parent519c21a5a3aefe5afc4123bda99d4e76d2a012bb (diff)
downloadchromium_src-49f69aeb0f507096666e58e037a389712be4e585.zip
chromium_src-49f69aeb0f507096666e58e037a389712be4e585.tar.gz
chromium_src-49f69aeb0f507096666e58e037a389712be4e585.tar.bz2
Fix scripting during NPP_Destroy. Note that if the plugin is making a call to the renderer so this instance is in the callstack, destruction will have to be asynchronous and so scripting still won't work. This change also fixes use of PluginChannel after it's deleted (if this was the last instance).
BUG=23713, 23706 TEST=added ui test Review URL: http://codereview.chromium.org/258026 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28141 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/data/npapi/ensure_scripting_works_in_destroy.html21
-rw-r--r--chrome/test/data/npapi/ensure_scripting_works_in_destroy_iframe.html33
-rw-r--r--chrome/test/ui/npapi_uitest.cc85
3 files changed, 104 insertions, 35 deletions
diff --git a/chrome/test/data/npapi/ensure_scripting_works_in_destroy.html b/chrome/test/data/npapi/ensure_scripting_works_in_destroy.html
new file mode 100644
index 0000000..80b9f65
--- /dev/null
+++ b/chrome/test/data/npapi/ensure_scripting_works_in_destroy.html
@@ -0,0 +1,21 @@
+<html>
+<head>
+<script src="npapi.js"></script>
+<script>
+function onloadfunction() {
+ document.getElementById("theiframe").src = "about:blank";
+}
+</script>
+</head>
+
+<body onload="setTimeout(onloadfunction(), 0)">
+<div id="statusPanel" style="border: 1px solid red; width: 100%">
+Test running....
+</div>
+
+Tests that scripting works during NPP_Destroy.
+
+<iframe src="ensure_scripting_works_in_destroy_iframe.html" id="theiframe">
+</iframe>
+</body>
+</html>
diff --git a/chrome/test/data/npapi/ensure_scripting_works_in_destroy_iframe.html b/chrome/test/data/npapi/ensure_scripting_works_in_destroy_iframe.html
new file mode 100644
index 0000000..10cef59
--- /dev/null
+++ b/chrome/test/data/npapi/ensure_scripting_works_in_destroy_iframe.html
@@ -0,0 +1,33 @@
+<html>
+<head>
+<script src="npapi.js"></script>
+<script>
+function GetMagicNumber() {
+ return 42;
+}
+
+function onSuccess(name, id) {
+ parent.onSuccess(name, id);
+}
+
+function onFailure(name, id, status) {
+ parent.onFailure(name, id);
+}
+</script>
+</head>
+
+<body>
+<div id=PluginDiv>
+<embed type="application/vnd.npapi-test"
+ src="foo"
+ name="ensure_scripting_works_in_destroy"
+ id="1"
+ mode="np_embed"
+>
+</DIV>
+<script>
+ var height = document.body.offsetHeight;
+</script>
+
+</body>
+</html>
diff --git a/chrome/test/ui/npapi_uitest.cc b/chrome/test/ui/npapi_uitest.cc
index ae93190..d379426 100644
--- a/chrome/test/ui/npapi_uitest.cc
+++ b/chrome/test/ui/npapi_uitest.cc
@@ -159,27 +159,29 @@ TEST_F(NPAPITester, DISABLED_SelfDeletePluginInvokeAlert) {
// Tests if a plugin executing a self deleting script in the context of
// a synchronous paint event works correctly
TEST_F(NPAPIVisiblePluginTester, SelfDeletePluginInvokeInSynchronousPaint) {
- if (!UITest::in_process_renderer()) {
- show_window_ = true;
- std::wstring test_case = L"execute_script_delete_in_paint.html";
- GURL url = GetTestUrl(L"npapi", test_case);
- NavigateToURL(url);
- WaitForFinish("execute_script_delete_in_paint", "1", url,
- kTestCompleteCookie, kTestCompleteSuccess,
- kShortWaitTimeout);
- }
+ if (UITest::in_process_renderer())
+ return;
+
+ show_window_ = true;
+ std::wstring test_case = L"execute_script_delete_in_paint.html";
+ GURL url = GetTestUrl(L"npapi", test_case);
+ NavigateToURL(url);
+ WaitForFinish("execute_script_delete_in_paint", "1", url,
+ kTestCompleteCookie, kTestCompleteSuccess,
+ kShortWaitTimeout);
}
TEST_F(NPAPIVisiblePluginTester, SelfDeletePluginInNewStream) {
- if (!UITest::in_process_renderer()) {
- show_window_ = true;
- std::wstring test_case = L"self_delete_plugin_stream.html";
- GURL url = GetTestUrl(L"npapi", test_case);
- NavigateToURL(url);
- WaitForFinish("self_delete_plugin_stream", "1", url,
- kTestCompleteCookie, kTestCompleteSuccess,
- kShortWaitTimeout);
- }
+ if (UITest::in_process_renderer())
+ return;
+
+ show_window_ = true;
+ std::wstring test_case = L"self_delete_plugin_stream.html";
+ GURL url = GetTestUrl(L"npapi", test_case);
+ NavigateToURL(url);
+ WaitForFinish("self_delete_plugin_stream", "1", url,
+ kTestCompleteCookie, kTestCompleteSuccess,
+ kShortWaitTimeout);
}
// Tests if a plugin has a non zero window rect.
@@ -235,15 +237,16 @@ TEST_F(NPAPIVisiblePluginTester, AlertInWindowMessage) {
#endif
TEST_F(NPAPIVisiblePluginTester, VerifyNPObjectLifetimeTest) {
- if (!UITest::in_process_renderer()) {
- show_window_ = true;
- std::wstring test_case = L"npobject_lifetime_test.html";
- GURL url = GetTestUrl(L"npapi", test_case);
- NavigateToURL(url);
- WaitForFinish("npobject_lifetime_test", "1", url,
- kTestCompleteCookie, kTestCompleteSuccess,
- kShortWaitTimeout);
- }
+ if (UITest::in_process_renderer())
+ return;
+
+ show_window_ = true;
+ std::wstring test_case = L"npobject_lifetime_test.html";
+ GURL url = GetTestUrl(L"npapi", test_case);
+ NavigateToURL(url);
+ WaitForFinish("npobject_lifetime_test", "1", url,
+ kTestCompleteCookie, kTestCompleteSuccess,
+ kShortWaitTimeout);
}
// Tests that we don't crash or assert if NPP_New fails
@@ -255,14 +258,15 @@ TEST_F(NPAPIVisiblePluginTester, NewFails) {
}
TEST_F(NPAPIVisiblePluginTester, SelfDeletePluginInNPNEvaluate) {
- if (!UITest::in_process_renderer()) {
- GURL url = GetTestUrl(L"npapi",
- L"execute_script_delete_in_npn_evaluate.html");
- NavigateToURL(url);
- WaitForFinish("npobject_delete_plugin_in_evaluate", "1", url,
- kTestCompleteCookie, kTestCompleteSuccess,
- kShortWaitTimeout);
- }
+ if (UITest::in_process_renderer())
+ return;
+
+ GURL url = GetTestUrl(L"npapi",
+ L"execute_script_delete_in_npn_evaluate.html");
+ NavigateToURL(url);
+ WaitForFinish("npobject_delete_plugin_in_evaluate", "1", url,
+ kTestCompleteCookie, kTestCompleteSuccess,
+ kShortWaitTimeout);
}
// Flaky. See http://crbug.com/17645
@@ -321,3 +325,14 @@ TEST_F(NPAPIVisiblePluginTester, GetURLRequestFailWrite) {
WaitForFinish("geturl_fail_write", "1", url, kTestCompleteCookie,
kTestCompleteSuccess, kShortWaitTimeout);
}
+
+TEST_F(NPAPITester, EnsureScriptingWorksInDestroy) {
+ if (UITest::in_process_renderer())
+ return;
+
+ GURL url = GetTestUrl(L"npapi", L"ensure_scripting_works_in_destroy.html");
+ NavigateToURL(url);
+ WaitForFinish("ensure_scripting_works_in_destroy", "1", url,
+ kTestCompleteCookie, kTestCompleteSuccess,
+ kShortWaitTimeout);
+}