Index: webkit/plugins/npapi/test/plugin_windowless_test.cc |
=================================================================== |
--- webkit/plugins/npapi/test/plugin_windowless_test.cc (revision 151213) |
+++ webkit/plugins/npapi/test/plugin_windowless_test.cc (working copy) |
@@ -11,6 +11,8 @@ |
#if defined(OS_MACOSX) |
#include <ApplicationServices/ApplicationServices.h> |
#include <Carbon/Carbon.h> |
+#elif defined(TOOLKIT_GTK) |
+#include <gdk/gdkx.h> |
#endif |
namespace NPAPIClient { |
@@ -18,9 +20,14 @@ |
// Remember the first plugin instance for tests involving multiple instances |
WindowlessPluginTest* g_other_instance = NULL; |
+void OnFinishTest(void* data) { |
+ static_cast<WindowlessPluginTest*>(data)->SignalTestCompleted(); |
+} |
+ |
WindowlessPluginTest::WindowlessPluginTest(NPP id, |
NPNetscapeFuncs *host_functions) |
- : PluginTest(id, host_functions) { |
+ : PluginTest(id, host_functions), |
+ paint_counter_(0) { |
if (!g_other_instance) |
g_other_instance = this; |
} |
@@ -30,6 +37,8 @@ |
return WM_PAINT == np_event->event; |
#elif defined(OS_MACOSX) |
return np_event->what == updateEvt; |
+#elif defined(TOOLKIT_GTK) |
+ return np_event->type == GraphicsExpose; |
#else |
NOTIMPLEMENTED(); |
return false; |
@@ -72,7 +81,6 @@ |
} |
int16 WindowlessPluginTest::HandleEvent(void* event) { |
- |
NPNetscapeFuncs* browser = NPAPIClient::PluginClient::HostFunctions(); |
NPBool supports_windowless = 0; |
@@ -86,6 +94,7 @@ |
NPEvent* np_event = reinterpret_cast<NPEvent*>(event); |
if (IsPaintEvent(np_event)) { |
+ paint_counter_++; |
#if defined(OS_WIN) |
HDC paint_dc = reinterpret_cast<HDC>(np_event->wParam); |
if (paint_dc == NULL) { |
@@ -109,6 +118,19 @@ |
ExecuteScriptDeleteInPaint(browser); |
} else if (test_name() == "multiple_instances_sync_calls") { |
MultipleInstanceSyncCalls(browser); |
+ } else if (test_name() == "resize_during_paint") { |
+ if (paint_counter_ == 1) { |
+ // So that we get another paint later. |
+ browser->invalidaterect(id(), NULL); |
+ } else if (paint_counter_ == 2) { |
+ // Do this in the second paint since that's asynchronous. The first will |
+ // be async and WebKit will assert that style recalc doesn't occur while |
+ // _it's_ painting (as opposed to the plugin). |
Tom Hudson
2012/08/15 17:04:00
Nit: I'd like to understand this, but I don't foll
jam
2012/08/15 17:28:11
my bad, I was lazy and wrote a comment that I myse
Tom Hudson
2012/08/15 17:59:04
So there are two paints, and both are asynchronous
jam
2012/08/15 18:22:22
that was a typo, check out the update
|
+ ExecuteScriptResizeInPaint(browser); |
+ |
+ // So that we can exit later. |
+ browser->pluginthreadasynccall(id(), OnFinishTest, this); |
+ } |
} |
#if defined(OS_MACOSX) |
} else if (IsWindowActivationEvent(np_event) && |
@@ -159,6 +181,11 @@ |
SignalTestCompleted(); |
} |
+void WindowlessPluginTest::ExecuteScriptResizeInPaint( |
+ NPNetscapeFuncs* browser) { |
+ ExecuteScript(browser, id(), "ResizePluginWithinScript();", NULL); |
+} |
+ |
void WindowlessPluginTest::MultipleInstanceSyncCalls(NPNetscapeFuncs* browser) { |
if (this == g_other_instance) |
return; |