summaryrefslogtreecommitdiffstats
path: root/webkit/glue/plugins/test
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-30 05:49:12 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-30 05:49:12 +0000
commitadb2923ca85bd46112112df8d056308ad3798b0f (patch)
tree77f12bab8d89832ff623bd3d964e5e839726ba59 /webkit/glue/plugins/test
parent1fc13aae9f6326f44f7db26954aa60df84eb8677 (diff)
downloadchromium_src-adb2923ca85bd46112112df8d056308ad3798b0f.zip
chromium_src-adb2923ca85bd46112112df8d056308ad3798b0f.tar.gz
chromium_src-adb2923ca85bd46112112df8d056308ad3798b0f.tar.bz2
Another attempt at landing this patch.
The reliability tests regressions caused by this patch have been addressed by the upstream bug fix https://bugs.webkit.org/show_bug.cgi?id=27769 The IPCs for carrying data requested by plugins have been changed from synchronous IPCs to asynchronous IPCs. This fixes bug http://code.google.com/p/chromium/issues/detail?id=14323, where the Flash plugin would not render content on the page if these IPCs were processed while the plugin waited for sync calls like NPN_Evaluate to return. Test=covered by UI tests. Bug=14323 Review URL: http://codereview.chromium.org/160338 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22041 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/plugins/test')
-rw-r--r--webkit/glue/plugins/test/plugin_get_javascript_url_test.cc83
-rw-r--r--webkit/glue/plugins/test/plugin_get_javascript_url_test.h10
2 files changed, 92 insertions, 1 deletions
diff --git a/webkit/glue/plugins/test/plugin_get_javascript_url_test.cc b/webkit/glue/plugins/test/plugin_get_javascript_url_test.cc
index 74d01f1..ebdd745 100644
--- a/webkit/glue/plugins/test/plugin_get_javascript_url_test.cc
+++ b/webkit/glue/plugins/test/plugin_get_javascript_url_test.cc
@@ -17,11 +17,19 @@
// The maximum chunk size of stream data.
#define STREAM_CHUNK 197
+const int kNPNEvaluateTimerID = 100;
+const int kNPNEvaluateTimerElapse = 50;
+
+
namespace NPAPIClient {
ExecuteGetJavascriptUrlTest::ExecuteGetJavascriptUrlTest(NPP id, NPNetscapeFuncs *host_functions)
: PluginTest(id, host_functions),
- test_started_(false) {
+ test_started_(false),
+#ifdef OS_WIN
+ window_(NULL),
+#endif
+ npn_evaluate_context_(false) {
}
NPError ExecuteGetJavascriptUrlTest::SetWindow(NPWindow* pNPWindow) {
@@ -30,15 +38,64 @@ NPError ExecuteGetJavascriptUrlTest::SetWindow(NPWindow* pNPWindow) {
HostFunctions()->geturlnotify(id(), url.c_str(), "_top",
reinterpret_cast<void*>(SELF_URL_STREAM_ID));
test_started_ = true;
+
+#ifdef OS_WIN
+ HWND window_handle = reinterpret_cast<HWND>(pNPWindow->window);
+ if (!::GetProp(window_handle, L"Plugin_Instance")) {
+ ::SetProp(window_handle, L"Plugin_Instance", this);
+ // We attempt to retreive the NPObject for the plugin instance identified
+ // by the NPObjectLifetimeTestInstance2 class as it may not have been
+ // instantiated yet.
+ SetTimer(window_handle, kNPNEvaluateTimerID, kNPNEvaluateTimerElapse,
+ TimerProc);
+ }
+ window_ = window_handle;
+#endif
}
+
return NPERR_NO_ERROR;
}
+#ifdef OS_WIN
+void CALLBACK ExecuteGetJavascriptUrlTest::TimerProc(
+ HWND window, UINT message, UINT timer_id, unsigned long elapsed_time) {
+ ExecuteGetJavascriptUrlTest* this_instance =
+ reinterpret_cast<ExecuteGetJavascriptUrlTest*>
+ (::GetProp(window, L"Plugin_Instance"));
+
+ NPObject *window_obj = NULL;
+ this_instance->HostFunctions()->getvalue(this_instance->id(),
+ NPNVWindowNPObject,
+ &window_obj);
+ if (!window_obj) {
+ this_instance->SetError("Failed to get NPObject for plugin instance2");
+ this_instance->SignalTestCompleted();
+ return;
+ }
+
+ std::string script = "javascript:window.location";
+ NPString script_string;
+ script_string.UTF8Characters = script.c_str();
+ script_string.UTF8Length = static_cast<unsigned int>(script.length());
+ NPVariant result_var;
+
+ this_instance->npn_evaluate_context_ = true;
+ NPError result = this_instance->HostFunctions()->evaluate(
+ this_instance->id(), window_obj, &script_string, &result_var);
+ this_instance->npn_evaluate_context_ = false;
+}
+#endif
+
NPError ExecuteGetJavascriptUrlTest::NewStream(NPMIMEType type, NPStream* stream,
NPBool seekable, uint16* stype) {
if (stream == NULL)
SetError("NewStream got null stream");
+ if (npn_evaluate_context_) {
+ SetError("NewStream received in context of NPN_Evaluate");
+ return NPERR_NO_ERROR;
+ }
+
COMPILE_ASSERT(sizeof(unsigned long) <= sizeof(stream->notifyData),
cast_validity_check);
unsigned long stream_id = reinterpret_cast<unsigned long>(stream->notifyData);
@@ -53,6 +110,10 @@ NPError ExecuteGetJavascriptUrlTest::NewStream(NPMIMEType type, NPStream* stream
}
int32 ExecuteGetJavascriptUrlTest::WriteReady(NPStream *stream) {
+ if (npn_evaluate_context_) {
+ SetError("WriteReady received in context of NPN_Evaluate");
+ return NPERR_NO_ERROR;
+ }
return STREAM_CHUNK;
}
@@ -63,6 +124,11 @@ int32 ExecuteGetJavascriptUrlTest::Write(NPStream *stream, int32 offset, int32 l
if (len < 0 || len > STREAM_CHUNK)
SetError("Write got bogus stream chunk size");
+ if (npn_evaluate_context_) {
+ SetError("Write received in context of NPN_Evaluate");
+ return len;
+ }
+
COMPILE_ASSERT(sizeof(unsigned long) <= sizeof(stream->notifyData),
cast_validity_check);
unsigned long stream_id = reinterpret_cast<unsigned long>(stream->notifyData);
@@ -83,6 +149,15 @@ NPError ExecuteGetJavascriptUrlTest::DestroyStream(NPStream *stream, NPError rea
if (stream == NULL)
SetError("NewStream got null stream");
+#ifdef OS_WIN
+ KillTimer(window_, kNPNEvaluateTimerID);
+#endif
+
+ if (npn_evaluate_context_) {
+ SetError("DestroyStream received in context of NPN_Evaluate");
+ return NPERR_NO_ERROR;
+ }
+
COMPILE_ASSERT(sizeof(unsigned long) <= sizeof(stream->notifyData),
cast_validity_check);
unsigned long stream_id = reinterpret_cast<unsigned long>(stream->notifyData);
@@ -100,6 +175,12 @@ NPError ExecuteGetJavascriptUrlTest::DestroyStream(NPStream *stream, NPError rea
void ExecuteGetJavascriptUrlTest::URLNotify(const char* url, NPReason reason, void* data) {
COMPILE_ASSERT(sizeof(unsigned long) <= sizeof(data),
cast_validity_check);
+
+ if (npn_evaluate_context_) {
+ SetError("URLNotify received in context of NPN_Evaluate");
+ return;
+ }
+
unsigned long stream_id = reinterpret_cast<unsigned long>(data);
switch (stream_id) {
case SELF_URL_STREAM_ID:
diff --git a/webkit/glue/plugins/test/plugin_get_javascript_url_test.h b/webkit/glue/plugins/test/plugin_get_javascript_url_test.h
index cff6775..5c2540d 100644
--- a/webkit/glue/plugins/test/plugin_get_javascript_url_test.h
+++ b/webkit/glue/plugins/test/plugin_get_javascript_url_test.h
@@ -28,8 +28,18 @@ class ExecuteGetJavascriptUrlTest : public PluginTest {
virtual void URLNotify(const char* url, NPReason reason, void* data);
private:
+#if defined(OS_WIN)
+ static void CALLBACK TimerProc(HWND window, UINT message, UINT timer_id,
+ unsigned long elapsed_time);
+#endif
bool test_started_;
+ // This flag is set to true in the context of the NPN_Evaluate call.
+ bool npn_evaluate_context_;
std::string self_url_;
+
+#if defined(OS_WIN)
+ HWND window_;
+#endif
};
} // namespace NPAPIClient