summaryrefslogtreecommitdiffstats
path: root/Tools/DumpRenderTree/TestNetscapePlugIn
diff options
context:
space:
mode:
Diffstat (limited to 'Tools/DumpRenderTree/TestNetscapePlugIn')
-rw-r--r--Tools/DumpRenderTree/TestNetscapePlugIn/PluginObject.cpp20
-rw-r--r--Tools/DumpRenderTree/TestNetscapePlugIn/PluginTest.cpp5
-rw-r--r--Tools/DumpRenderTree/TestNetscapePlugIn/main.cpp32
3 files changed, 55 insertions, 2 deletions
diff --git a/Tools/DumpRenderTree/TestNetscapePlugIn/PluginObject.cpp b/Tools/DumpRenderTree/TestNetscapePlugIn/PluginObject.cpp
index 45e5ddb..24ee12c 100644
--- a/Tools/DumpRenderTree/TestNetscapePlugIn/PluginObject.cpp
+++ b/Tools/DumpRenderTree/TestNetscapePlugIn/PluginObject.cpp
@@ -199,6 +199,7 @@ enum {
ID_SET_STATUS,
ID_RESIZE_TO,
ID_NORMALIZE,
+ ID_INVALIDATE_RECT,
NUM_METHOD_IDENTIFIERS
};
@@ -239,7 +240,8 @@ static const NPUTF8 *pluginMethodIdentifierNames[NUM_METHOD_IDENTIFIERS] = {
"refCount",
"setStatus",
"resizeTo",
- "normalize"
+ "normalize",
+ "invalidateRect"
};
static NPUTF8* createCStringFromNPVariant(const NPVariant* variant)
@@ -986,6 +988,20 @@ static bool normalizeOverride(PluginObject* obj, const NPVariant* args, uint32_t
return true;
}
+static bool invalidateRect(PluginObject* obj, const NPVariant* args, uint32_t argCount, NPVariant* result)
+{
+ if (argCount != 4)
+ return false;
+
+ NPRect rect;
+ rect.left = static_cast<int>(NPVARIANT_TO_DOUBLE(args[0]));
+ rect.top = static_cast<int>(NPVARIANT_TO_DOUBLE(args[1]));
+ rect.right = static_cast<int>(NPVARIANT_TO_DOUBLE(args[2]));
+ rect.bottom = static_cast<int>(NPVARIANT_TO_DOUBLE(args[3]));
+
+ browser->invalidaterect(obj->npp, &rect);
+ return true;
+}
static bool pluginInvoke(NPObject* header, NPIdentifier name, const NPVariant* args, uint32_t argCount, NPVariant* result)
{
@@ -1101,6 +1117,8 @@ static bool pluginInvoke(NPObject* header, NPIdentifier name, const NPVariant* a
return testResizeTo(plugin, args, argCount, result);
if (name == pluginMethodIdentifiers[ID_NORMALIZE])
return normalizeOverride(plugin, args, argCount, result);
+ if (name == pluginMethodIdentifiers[ID_INVALIDATE_RECT])
+ return invalidateRect(plugin, args, argCount, result);
return false;
}
diff --git a/Tools/DumpRenderTree/TestNetscapePlugIn/PluginTest.cpp b/Tools/DumpRenderTree/TestNetscapePlugIn/PluginTest.cpp
index 703d9d5..0dd9da6 100644
--- a/Tools/DumpRenderTree/TestNetscapePlugIn/PluginTest.cpp
+++ b/Tools/DumpRenderTree/TestNetscapePlugIn/PluginTest.cpp
@@ -33,11 +33,14 @@ extern NPNetscapeFuncs *browser;
PluginTest* PluginTest::create(NPP npp, const string& identifier)
{
+ if (identifier.empty())
+ return new PluginTest(npp, identifier);
+
CreateTestFunction createTestFunction = createTestFunctions()[identifier];
if (createTestFunction)
return createTestFunction(npp, identifier);
- return new PluginTest(npp, identifier);
+ return 0;
}
PluginTest::PluginTest(NPP npp, const string& identifier)
diff --git a/Tools/DumpRenderTree/TestNetscapePlugIn/main.cpp b/Tools/DumpRenderTree/TestNetscapePlugIn/main.cpp
index b4b7fa3..7635a09 100644
--- a/Tools/DumpRenderTree/TestNetscapePlugIn/main.cpp
+++ b/Tools/DumpRenderTree/TestNetscapePlugIn/main.cpp
@@ -200,6 +200,9 @@ NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc
else if (strcasecmp(argn[i], "src") == 0 &&
strcasecmp(argv[i], "data:application/x-webkit-test-netscape,returnerrorfromnewstream") == 0)
obj->returnErrorFromNewStream = TRUE;
+ else if (strcasecmp(argn[i], "src") == 0 &&
+ strcasecmp(argv[i], "data:application/x-webkit-test-netscape,alertwhenloaded") == 0)
+ executeScript(obj, "alert('Plugin Loaded!')");
else if (strcasecmp(argn[i], "onSetWindow") == 0 && !obj->onSetWindow)
obj->onSetWindow = strdup(argv[i]);
else if (strcasecmp(argn[i], "onNew") == 0 && !onNewScript)
@@ -256,6 +259,15 @@ NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc
// When testing evaluate script on mouse-down or key-down, allow event logging to handle events.
if (obj->evaluateScriptOnMouseDownOrKeyDown)
obj->eventLogging = true;
+ } else if (!strcasecmp(argn[i], "windowedPlugin")) {
+ void* windowed = 0;
+ if (!strcasecmp(argv[i], "false") || !strcasecmp(argv[i], "0"))
+ windowed = 0;
+ else if (!strcasecmp(argv[i], "true") || !strcasecmp(argv[i], "1"))
+ windowed = reinterpret_cast<void*>(1);
+ else
+ assert(false);
+ browser->setvalue(instance, NPPVpluginWindowBool, windowed);
}
}
@@ -271,6 +283,11 @@ NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc
obj->pluginTest = PluginTest::create(instance, testIdentifier);
+ if (!obj->pluginTest) {
+ pluginLog(instance, "NPP_New: Could not find a test named \"%s\", maybe its .cpp file wasn't added to the build system?", testIdentifier.c_str());
+ return NPERR_GENERIC_ERROR;
+ }
+
#ifdef XP_UNIX
// On Unix, plugins only get events if they are windowless.
browser->setvalue(instance, NPPVpluginWindowBool, 0);
@@ -663,6 +680,19 @@ static int16_t handleEventX11(NPP instance, PluginObject* obj, XEvent* event)
}
#endif // XP_UNIX
+#ifdef XP_WIN
+static int16_t handleEventWin(NPP instance, PluginObject* obj, NPEvent* event)
+{
+ switch (event->event) {
+ case WM_PAINT:
+ if (obj->onPaintEvent)
+ executeScript(obj, obj->onPaintEvent);
+ return 1;
+ }
+ return 0;
+}
+#endif // XP_WIN
+
int16_t NPP_HandleEvent(NPP instance, void *event)
{
PluginObject* obj = static_cast<PluginObject*>(instance->pdata);
@@ -677,6 +707,8 @@ int16_t NPP_HandleEvent(NPP instance, void *event)
return handleEventCocoa(instance, obj, static_cast<NPCocoaEvent*>(event));
#elif defined(XP_UNIX)
return handleEventX11(instance, obj, static_cast<XEvent*>(event));
+#elif defined(XP_WIN)
+ return handleEventWin(instance, obj, static_cast<NPEvent*>(event));
#else
// FIXME: Implement for other platforms.
return 0;