summaryrefslogtreecommitdiffstats
path: root/WebKitTools/DumpRenderTree/TestNetscapePlugIn
diff options
context:
space:
mode:
Diffstat (limited to 'WebKitTools/DumpRenderTree/TestNetscapePlugIn')
-rw-r--r--WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginObject.cpp186
-rw-r--r--WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginObject.h4
-rw-r--r--WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginTest.cpp10
-rw-r--r--WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginTest.h2
-rw-r--r--WebKitTools/DumpRenderTree/TestNetscapePlugIn/TestObject.cpp50
-rw-r--r--WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/EvaluateJSAfterRemovingPluginElement.cpp64
-rw-r--r--WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/DrawsGradient.cpp118
-rw-r--r--WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/NPNInvalidateRectInvalidatesWindow.cpp49
-rw-r--r--WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/WindowRegionIsSetToClipRect.cpp114
-rw-r--r--WebKitTools/DumpRenderTree/TestNetscapePlugIn/main.cpp54
-rw-r--r--WebKitTools/DumpRenderTree/TestNetscapePlugIn/win/TestNetscapePlugin.vcproj39
-rw-r--r--WebKitTools/DumpRenderTree/TestNetscapePlugIn/win/WindowedPluginTest.cpp71
-rw-r--r--WebKitTools/DumpRenderTree/TestNetscapePlugIn/win/WindowedPluginTest.h50
13 files changed, 690 insertions, 121 deletions
diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginObject.cpp b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginObject.cpp
index db73a9d..7f1c4b4 100644
--- a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginObject.cpp
+++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginObject.cpp
@@ -27,13 +27,13 @@
#include "PluginObject.h"
+#include "PluginTest.h"
#include "TestObject.h"
#include <assert.h>
#include <stdarg.h>
#include <stdio.h>
-
-#include <string.h>
#include <stdlib.h>
+#include <string.h>
// Helper function which takes in the plugin window object for logging to the console object.
static void pluginLogWithWindowObject(NPObject* windowObject, NPP instance, const char* message)
@@ -118,10 +118,10 @@ static NPClass pluginClass = {
pluginSetProperty,
0, // NPClass::removeProperty
0, // NPClass::enumerate
- 0 // NPClass::construct
+ 0, // NPClass::construct
};
-NPClass *getPluginClass(void)
+NPClass* getPluginClass(void)
{
return &pluginClass;
}
@@ -176,6 +176,7 @@ enum {
ID_TEST_GET_PROPERTY_RETURN_VALUE,
ID_TEST_IDENTIFIER_TO_STRING,
ID_TEST_IDENTIFIER_TO_INT,
+ ID_TEST_PASS_TEST_OBJECT,
ID_TEST_POSTURL_FILE,
ID_TEST_CONSTRUCT,
ID_TEST_THROW_EXCEPTION_METHOD,
@@ -212,6 +213,7 @@ static const NPUTF8 *pluginMethodIdentifierNames[NUM_METHOD_IDENTIFIERS] = {
"testGetPropertyReturnValue",
"testIdentifierToString",
"testIdentifierToInt",
+ "testPassTestObject",
"testPostURLFile",
"testConstruct",
"testThrowException",
@@ -270,38 +272,48 @@ static bool pluginGetProperty(NPObject* obj, NPIdentifier name, NPVariant* resul
strcpy(buf, originalString);
STRINGZ_TO_NPVARIANT(buf, *result);
return true;
- } else if (name == pluginPropertyIdentifiers[ID_PROPERTY_EVENT_LOGGING]) {
+ }
+ if (name == pluginPropertyIdentifiers[ID_PROPERTY_EVENT_LOGGING]) {
BOOLEAN_TO_NPVARIANT(plugin->eventLogging, *result);
return true;
- } else if (name == pluginPropertyIdentifiers[ID_PROPERTY_LOG_DESTROY]) {
+ }
+ if (name == pluginPropertyIdentifiers[ID_PROPERTY_LOG_DESTROY]) {
BOOLEAN_TO_NPVARIANT(plugin->logDestroy, *result);
return true;
- } else if (name == pluginPropertyIdentifiers[ID_PROPERTY_HAS_STREAM]) {
- BOOLEAN_TO_NPVARIANT(plugin->stream != 0, *result);
+ }
+ if (name == pluginPropertyIdentifiers[ID_PROPERTY_HAS_STREAM]) {
+ BOOLEAN_TO_NPVARIANT(plugin->stream, *result);
return true;
- } else if (name == pluginPropertyIdentifiers[ID_PROPERTY_TEST_OBJECT]) {
+ }
+ if (name == pluginPropertyIdentifiers[ID_PROPERTY_TEST_OBJECT]) {
NPObject* testObject = plugin->testObject;
browser->retainobject(testObject);
OBJECT_TO_NPVARIANT(testObject, *result);
return true;
- } else if (name == pluginPropertyIdentifiers[ID_PROPERTY_RETURN_ERROR_FROM_NEWSTREAM]) {
+ }
+ if (name == pluginPropertyIdentifiers[ID_PROPERTY_RETURN_ERROR_FROM_NEWSTREAM]) {
BOOLEAN_TO_NPVARIANT(plugin->returnErrorFromNewStream, *result);
return true;
- } else if (name == pluginPropertyIdentifiers[ID_PROPERTY_RETURN_NEGATIVE_ONE_FROM_WRITE]) {
+ }
+ if (name == pluginPropertyIdentifiers[ID_PROPERTY_RETURN_NEGATIVE_ONE_FROM_WRITE]) {
BOOLEAN_TO_NPVARIANT(plugin->returnNegativeOneFromWrite, *result);
return true;
- } else if (name == pluginPropertyIdentifiers[ID_PROPERTY_PRIVATE_BROWSING_ENABLED]) {
+ }
+ if (name == pluginPropertyIdentifiers[ID_PROPERTY_PRIVATE_BROWSING_ENABLED]) {
NPBool privateBrowsingEnabled = FALSE;
browser->getvalue(plugin->npp, NPNVprivateModeBool, &privateBrowsingEnabled);
BOOLEAN_TO_NPVARIANT(privateBrowsingEnabled, *result);
return true;
- } else if (name == pluginPropertyIdentifiers[ID_PROPERTY_CACHED_PRIVATE_BROWSING_ENABLED]) {
+ }
+ if (name == pluginPropertyIdentifiers[ID_PROPERTY_CACHED_PRIVATE_BROWSING_ENABLED]) {
BOOLEAN_TO_NPVARIANT(plugin->cachedPrivateBrowsingMode, *result);
return true;
- } else if (name == pluginPropertyIdentifiers[ID_PROPERTY_THROW_EXCEPTION_PROPERTY]) {
+ }
+ if (name == pluginPropertyIdentifiers[ID_PROPERTY_THROW_EXCEPTION_PROPERTY]) {
browser->setexception(obj, "plugin object testThrowExceptionProperty SUCCESS");
return true;
- } else if (name == pluginPropertyIdentifiers[ID_LAST_SET_WINDOW_ARGUMENTS]) {
+ }
+ if (name == pluginPropertyIdentifiers[ID_LAST_SET_WINDOW_ARGUMENTS]) {
char* buf = static_cast<char*>(browser->memalloc(256));
snprintf(buf, 256, "x: %d, y: %d, width: %u, height: %u, clipRect: (%u, %u, %u, %u)", (int)plugin->lastWindow.x, (int)plugin->lastWindow.y, (unsigned)plugin->lastWindow.width, (unsigned)plugin->lastWindow.height,
plugin->lastWindow.clipRect.left, plugin->lastWindow.clipRect.top, plugin->lastWindow.clipRect.right - plugin->lastWindow.clipRect.left, plugin->lastWindow.clipRect.bottom - plugin->lastWindow.clipRect.top);
@@ -319,19 +331,24 @@ static bool pluginSetProperty(NPObject* obj, NPIdentifier name, const NPVariant*
if (name == pluginPropertyIdentifiers[ID_PROPERTY_EVENT_LOGGING]) {
plugin->eventLogging = NPVARIANT_TO_BOOLEAN(*variant);
return true;
- } else if (name == pluginPropertyIdentifiers[ID_PROPERTY_LOG_DESTROY]) {
+ }
+ if (name == pluginPropertyIdentifiers[ID_PROPERTY_LOG_DESTROY]) {
plugin->logDestroy = NPVARIANT_TO_BOOLEAN(*variant);
return true;
- } else if (name == pluginPropertyIdentifiers[ID_PROPERTY_RETURN_ERROR_FROM_NEWSTREAM]) {
+ }
+ if (name == pluginPropertyIdentifiers[ID_PROPERTY_RETURN_ERROR_FROM_NEWSTREAM]) {
plugin->returnErrorFromNewStream = NPVARIANT_TO_BOOLEAN(*variant);
return true;
- } else if (name == pluginPropertyIdentifiers[ID_PROPERTY_RETURN_NEGATIVE_ONE_FROM_WRITE]) {
+ }
+ if (name == pluginPropertyIdentifiers[ID_PROPERTY_RETURN_NEGATIVE_ONE_FROM_WRITE]) {
plugin->returnNegativeOneFromWrite = NPVARIANT_TO_BOOLEAN(*variant);
return true;
- } else if (name == pluginPropertyIdentifiers[ID_PROPERTY_THROW_EXCEPTION_PROPERTY]) {
+ }
+ if (name == pluginPropertyIdentifiers[ID_PROPERTY_THROW_EXCEPTION_PROPERTY]) {
browser->setexception(obj, "plugin object testThrowExceptionProperty SUCCESS");
return true;
- } else if (name == pluginPropertyIdentifiers[ID_PROPERTY_WINDOWED_PLUGIN]) {
+ }
+ if (name == pluginPropertyIdentifiers[ID_PROPERTY_WINDOWED_PLUGIN]) {
browser->setvalue(plugin->npp, NPPVpluginWindowBool, (void *)NPVARIANT_TO_BOOLEAN(*variant));
return true;
}
@@ -391,9 +408,9 @@ static NPIdentifier variantToIdentifier(NPVariant variant)
{
if (NPVARIANT_IS_STRING(variant))
return stringVariantToIdentifier(variant);
- else if (NPVARIANT_IS_INT32(variant))
+ if (NPVARIANT_IS_INT32(variant))
return int32VariantToIdentifier(variant);
- else if (NPVARIANT_IS_DOUBLE(variant))
+ if (NPVARIANT_IS_DOUBLE(variant))
return doubleVariantToIdentifier(variant);
return 0;
}
@@ -424,9 +441,29 @@ static bool testIdentifierToInt(PluginObject*, const NPVariant* args, uint32_t a
return true;
}
+static bool testPassTestObject(PluginObject* obj, const NPVariant* args, uint32_t argCount, NPVariant* result)
+{
+ if (argCount != 2 || !NPVARIANT_IS_STRING(args[0]))
+ return false;
+
+ NPObject* windowScriptObject;
+ browser->getvalue(obj->npp, NPNVWindowNPObject, &windowScriptObject);
+
+ NPUTF8* callbackString = createCStringFromNPVariant(&args[0]);
+ NPIdentifier callbackIdentifier = browser->getstringidentifier(callbackString);
+ free(callbackString);
+
+ NPVariant browserResult;
+ browser->invoke(obj->npp, windowScriptObject, callbackIdentifier, &args[1], 1, &browserResult);
+ browser->releasevariantvalue(&browserResult);
+
+ VOID_TO_NPVARIANT(*result);
+ return true;
+}
+
static bool testCallback(PluginObject* obj, const NPVariant* args, uint32_t argCount, NPVariant* result)
{
- if (argCount == 0 || !NPVARIANT_IS_STRING(args[0]))
+ if (!argCount || !NPVARIANT_IS_STRING(args[0]))
return false;
NPObject* windowScriptObject;
@@ -457,7 +494,8 @@ static bool getURL(PluginObject* obj, const NPVariant* args, uint32_t argCount,
INT32_TO_NPVARIANT(npErr, *result);
return true;
- } else if (argCount == 1 && NPVARIANT_IS_STRING(args[0])) {
+ }
+ if (argCount == 1 && NPVARIANT_IS_STRING(args[0])) {
NPUTF8* urlString = createCStringFromNPVariant(&args[0]);
NPError npErr = browser->geturl(obj->npp, urlString, 0);
free(urlString);
@@ -476,7 +514,7 @@ static bool getURLNotify(PluginObject* obj, const NPVariant* args, uint32_t argC
return false;
NPUTF8* urlString = createCStringFromNPVariant(&args[0]);
- NPUTF8* targetString = (NPVARIANT_IS_STRING(args[1]) ? createCStringFromNPVariant(&args[1]) : NULL);
+ NPUTF8* targetString = (NPVARIANT_IS_STRING(args[1]) ? createCStringFromNPVariant(&args[1]) : 0);
NPUTF8* callbackString = createCStringFromNPVariant(&args[2]);
NPIdentifier callbackIdentifier = browser->getstringidentifier(callbackString);
@@ -495,7 +533,7 @@ static bool testInvokeDefault(PluginObject* obj, const NPVariant* args, uint32_t
if (!NPVARIANT_IS_OBJECT(args[0]))
return false;
- NPObject *callback = NPVARIANT_TO_OBJECT(args[0]);
+ NPObject* callback = NPVARIANT_TO_OBJECT(args[0]);
NPVariant invokeArgs[1];
NPVariant browserResult;
@@ -568,10 +606,10 @@ static bool testGetIntIdentifier(PluginObject*, const NPVariant* args, uint32_t
static bool testGetProperty(PluginObject* obj, const NPVariant* args, uint32_t argCount, NPVariant* result)
{
- if (argCount == 0)
+ if (!argCount)
return false;
- NPObject *object;
+ NPObject* object;
browser->getvalue(obj->npp, NPNVWindowNPObject, &object);
for (uint32_t i = 0; i < argCount; i++) {
@@ -730,7 +768,7 @@ bool testDocumentOpen(NPP npp)
NPIdentifier documentId = browser->getstringidentifier("document");
NPIdentifier openId = browser->getstringidentifier("open");
- NPObject *windowObject = NULL;
+ NPObject* windowObject = 0;
browser->getvalue(npp, NPNVWindowNPObject, &windowObject);
if (!windowObject)
return false;
@@ -742,7 +780,7 @@ bool testDocumentOpen(NPP npp)
return false;
}
- NPObject *documentObject = NPVARIANT_TO_OBJECT(docVariant);
+ NPObject* documentObject = NPVARIANT_TO_OBJECT(docVariant);
NPVariant openArgs[2];
STRINGZ_TO_NPVARIANT("text/html", openArgs[0]);
@@ -774,7 +812,7 @@ bool testWindowOpen(NPP npp)
{
NPIdentifier openId = browser->getstringidentifier("open");
- NPObject *windowObject = NULL;
+ NPObject* windowObject = 0;
browser->getvalue(npp, NPNVWindowNPObject, &windowObject);
if (!windowObject)
return false;
@@ -856,87 +894,100 @@ static bool pluginInvoke(NPObject* header, NPIdentifier name, const NPVariant* a
PluginObject* plugin = reinterpret_cast<PluginObject*>(header);
if (name == pluginMethodIdentifiers[ID_TEST_CALLBACK_METHOD])
return testCallback(plugin, args, argCount, result);
- else if (name == pluginMethodIdentifiers[ID_TEST_GETURL])
+ if (name == pluginMethodIdentifiers[ID_TEST_GETURL])
return getURL(plugin, args, argCount, result);
- else if (name == pluginMethodIdentifiers[ID_TEST_DOM_ACCESS])
+ if (name == pluginMethodIdentifiers[ID_TEST_DOM_ACCESS])
return testDOMAccess(plugin, args, argCount, result);
- else if (name == pluginMethodIdentifiers[ID_TEST_GET_URL_NOTIFY])
+ if (name == pluginMethodIdentifiers[ID_TEST_GET_URL_NOTIFY])
return getURLNotify(plugin, args, argCount, result);
- else if (name == pluginMethodIdentifiers[ID_TEST_INVOKE_DEFAULT])
+ if (name == pluginMethodIdentifiers[ID_TEST_INVOKE_DEFAULT])
return testInvokeDefault(plugin, args, argCount, result);
- else if (name == pluginMethodIdentifiers[ID_TEST_ENUMERATE])
+ if (name == pluginMethodIdentifiers[ID_TEST_ENUMERATE])
return testEnumerate(plugin, args, argCount, result);
- else if (name == pluginMethodIdentifiers[ID_DESTROY_STREAM])
+ if (name == pluginMethodIdentifiers[ID_DESTROY_STREAM])
return destroyStream(plugin, args, argCount, result);
- else if (name == pluginMethodIdentifiers[ID_TEST_GETINTIDENTIFIER])
+ if (name == pluginMethodIdentifiers[ID_TEST_GETINTIDENTIFIER])
return testGetIntIdentifier(plugin, args, argCount, result);
- else if (name == pluginMethodIdentifiers[ID_TEST_EVALUATE])
+ if (name == pluginMethodIdentifiers[ID_TEST_EVALUATE])
return testEvaluate(plugin, args, argCount, result);
- else if (name == pluginMethodIdentifiers[ID_TEST_GET_PROPERTY])
+ if (name == pluginMethodIdentifiers[ID_TEST_GET_PROPERTY])
return testGetProperty(plugin, args, argCount, result);
- else if (name == pluginMethodIdentifiers[ID_TEST_GET_PROPERTY_RETURN_VALUE])
+ if (name == pluginMethodIdentifiers[ID_TEST_GET_PROPERTY_RETURN_VALUE])
return testGetPropertyReturnValue(plugin, args, argCount, result);
- else if (name == pluginMethodIdentifiers[ID_TEST_HAS_PROPERTY])
+ if (name == pluginMethodIdentifiers[ID_TEST_HAS_PROPERTY])
return testHasProperty(plugin, args, argCount, result);
- else if (name == pluginMethodIdentifiers[ID_TEST_HAS_METHOD])
+ if (name == pluginMethodIdentifiers[ID_TEST_HAS_METHOD])
return testHasMethod(plugin, args, argCount, result);
- else if (name == pluginMethodIdentifiers[ID_TEST_IDENTIFIER_TO_STRING])
+ if (name == pluginMethodIdentifiers[ID_TEST_IDENTIFIER_TO_STRING])
return testIdentifierToString(plugin, args, argCount, result);
- else if (name == pluginMethodIdentifiers[ID_TEST_IDENTIFIER_TO_INT])
+ if (name == pluginMethodIdentifiers[ID_TEST_IDENTIFIER_TO_INT])
return testIdentifierToInt(plugin, args, argCount, result);
- else if (name == pluginMethodIdentifiers[ID_TEST_POSTURL_FILE])
+ if (name == pluginMethodIdentifiers[ID_TEST_PASS_TEST_OBJECT])
+ return testPassTestObject(plugin, args, argCount, result);
+ if (name == pluginMethodIdentifiers[ID_TEST_POSTURL_FILE])
return testPostURLFile(plugin, args, argCount, result);
- else if (name == pluginMethodIdentifiers[ID_TEST_CONSTRUCT])
+ if (name == pluginMethodIdentifiers[ID_TEST_CONSTRUCT])
return testConstruct(plugin, args, argCount, result);
- else if (name == pluginMethodIdentifiers[ID_TEST_THROW_EXCEPTION_METHOD]) {
+ if (name == pluginMethodIdentifiers[ID_TEST_THROW_EXCEPTION_METHOD]) {
browser->setexception(header, "plugin object testThrowException SUCCESS");
return true;
- } else if (name == pluginMethodIdentifiers[ID_TEST_FAIL_METHOD]) {
+ }
+ if (name == pluginMethodIdentifiers[ID_TEST_FAIL_METHOD]) {
NPObject* windowScriptObject;
browser->getvalue(plugin->npp, NPNVWindowNPObject, &windowScriptObject);
browser->invoke(plugin->npp, windowScriptObject, name, args, argCount, result);
- } else if (name == pluginMethodIdentifiers[ID_DESTROY_NULL_STREAM])
+ return false;
+ }
+ if (name == pluginMethodIdentifiers[ID_DESTROY_NULL_STREAM])
return destroyNullStream(plugin, args, argCount, result);
- else if (name == pluginMethodIdentifiers[ID_TEST_RELOAD_PLUGINS_NO_PAGES]) {
+ if (name == pluginMethodIdentifiers[ID_TEST_RELOAD_PLUGINS_NO_PAGES]) {
browser->reloadplugins(false);
return true;
- } else if (name == pluginMethodIdentifiers[ID_TEST_RELOAD_PLUGINS_AND_PAGES]) {
+ }
+ if (name == pluginMethodIdentifiers[ID_TEST_RELOAD_PLUGINS_AND_PAGES]) {
browser->reloadplugins(true);
return true;
- } else if (name == pluginMethodIdentifiers[ID_TEST_GET_BROWSER_PROPERTY]) {
+ }
+ if (name == pluginMethodIdentifiers[ID_TEST_GET_BROWSER_PROPERTY]) {
browser->getproperty(plugin->npp, NPVARIANT_TO_OBJECT(args[0]), stringVariantToIdentifier(args[1]), result);
return true;
- } else if (name == pluginMethodIdentifiers[ID_TEST_SET_BROWSER_PROPERTY]) {
+ }
+ if (name == pluginMethodIdentifiers[ID_TEST_SET_BROWSER_PROPERTY]) {
browser->setproperty(plugin->npp, NPVARIANT_TO_OBJECT(args[0]), stringVariantToIdentifier(args[1]), &args[2]);
return true;
- } else if (name == pluginMethodIdentifiers[ID_REMEMBER]) {
+ }
+ if (name == pluginMethodIdentifiers[ID_REMEMBER]) {
if (plugin->rememberedObject)
browser->releaseobject(plugin->rememberedObject);
plugin->rememberedObject = NPVARIANT_TO_OBJECT(args[0]);
browser->retainobject(plugin->rememberedObject);
VOID_TO_NPVARIANT(*result);
return true;
- } else if (name == pluginMethodIdentifiers[ID_GET_REMEMBERED_OBJECT]) {
+ }
+ if (name == pluginMethodIdentifiers[ID_GET_REMEMBERED_OBJECT]) {
assert(plugin->rememberedObject);
browser->retainobject(plugin->rememberedObject);
OBJECT_TO_NPVARIANT(plugin->rememberedObject, *result);
return true;
- } else if (name == pluginMethodIdentifiers[ID_GET_AND_FORGET_REMEMBERED_OBJECT]) {
+ }
+ if (name == pluginMethodIdentifiers[ID_GET_AND_FORGET_REMEMBERED_OBJECT]) {
assert(plugin->rememberedObject);
OBJECT_TO_NPVARIANT(plugin->rememberedObject, *result);
plugin->rememberedObject = 0;
return true;
- } else if (name == pluginMethodIdentifiers[ID_REF_COUNT]) {
+ }
+ if (name == pluginMethodIdentifiers[ID_REF_COUNT]) {
uint32_t refCount = NPVARIANT_TO_OBJECT(args[0])->referenceCount;
INT32_TO_NPVARIANT(refCount, *result);
return true;
- } else if (name == pluginMethodIdentifiers[ID_SET_STATUS])
+ }
+ if (name == pluginMethodIdentifiers[ID_SET_STATUS])
return testSetStatus(plugin, args, argCount, result);
- else if (name == pluginMethodIdentifiers[ID_RESIZE_TO])
+ if (name == pluginMethodIdentifiers[ID_RESIZE_TO])
return testResizeTo(plugin, args, argCount, result);
- else if (name == pluginMethodIdentifiers[ID_NORMALIZE])
+ if (name == pluginMethodIdentifiers[ID_NORMALIZE])
return normalizeOverride(plugin, args, argCount, result);
-
+
return false;
}
@@ -990,6 +1041,7 @@ static NPObject *pluginAllocate(NPP npp, NPClass *theClass)
static void pluginDeallocate(NPObject* header)
{
PluginObject* plugin = reinterpret_cast<PluginObject*>(header);
+ delete plugin->pluginTest;
if (plugin->testObject)
browser->releaseobject(plugin->testObject);
if (plugin->rememberedObject)
@@ -1008,14 +1060,14 @@ void handleCallback(PluginObject* object, const char *url, NPReason reason, void
NPVariant args[2];
- NPObject *windowScriptObject;
+ NPObject* windowScriptObject;
browser->getvalue(object->npp, NPNVWindowNPObject, &windowScriptObject);
NPIdentifier callbackIdentifier = notifyData;
INT32_TO_NPVARIANT(reason, args[0]);
- char *strHdr = NULL;
+ char* strHdr = 0;
if (object->firstUrl && object->firstHeaders && object->lastUrl && object->lastHeaders) {
// Format expected by JavaScript validator: four fields separated by \n\n:
// First URL; first header block; last URL; last header block.
@@ -1040,7 +1092,7 @@ void handleCallback(PluginObject* object, const char *url, NPReason reason, void
void notifyStream(PluginObject* object, const char *url, const char *headers)
{
- if (object->firstUrl == NULL) {
+ if (!object->firstUrl) {
if (url)
object->firstUrl = strdup(url);
if (headers)
@@ -1048,8 +1100,8 @@ void notifyStream(PluginObject* object, const char *url, const char *headers)
} else {
free(object->lastUrl);
free(object->lastHeaders);
- object->lastUrl = (url ? strdup(url) : NULL);
- object->lastHeaders = (headers ? strdup(headers) : NULL);
+ object->lastUrl = (url ? strdup(url) : 0);
+ object->lastHeaders = (headers ? strdup(headers) : 0);
}
}
diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginObject.h b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginObject.h
index 99d5bf6..def8ad8 100644
--- a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginObject.h
+++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginObject.h
@@ -23,6 +23,9 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#ifndef PluginObject_h
+#define PluginObject_h
+
#include <WebKit/npfunctions.h>
#if defined(XP_MACOSX)
@@ -90,3 +93,4 @@ extern bool testWindowOpen(NPP npp);
extern void* createCoreAnimationLayer();
#endif
+#endif // PluginObject_h
diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginTest.cpp b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginTest.cpp
index e41e6e5..06c9953 100644
--- a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginTest.cpp
+++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginTest.cpp
@@ -101,28 +101,28 @@ bool PluginTest::NPN_RemoveProperty(NPObject* npObject, NPIdentifier propertyNam
return browser->removeproperty(m_npp, npObject, propertyName);
}
-static void executeScript(NPP npp, const char* script)
+void PluginTest::executeScript(const char* script)
{
NPObject* windowScriptObject;
- browser->getvalue(npp, NPNVWindowNPObject, &windowScriptObject);
+ browser->getvalue(m_npp, NPNVWindowNPObject, &windowScriptObject);
NPString npScript;
npScript.UTF8Characters = script;
npScript.UTF8Length = strlen(script);
NPVariant browserResult;
- browser->evaluate(npp, windowScriptObject, &npScript, &browserResult);
+ browser->evaluate(m_npp, windowScriptObject, &npScript, &browserResult);
browser->releasevariantvalue(&browserResult);
}
void PluginTest::waitUntilDone()
{
- executeScript(m_npp, "layoutTestController.waitUntilDone()");
+ executeScript("layoutTestController.waitUntilDone()");
}
void PluginTest::notifyDone()
{
- executeScript(m_npp, "layoutTestController.notifyDone()");
+ executeScript("layoutTestController.notifyDone()");
}
void PluginTest::registerCreateTestFunction(const string& identifier, CreateTestFunction createTestFunction)
diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginTest.h b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginTest.h
index 0497764..ae9bd82 100644
--- a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginTest.h
+++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginTest.h
@@ -68,6 +68,8 @@ public:
NPObject* NPN_CreateObject(NPClass*);
bool NPN_RemoveProperty(NPObject*, NPIdentifier propertyName);
+ void executeScript(const char*);
+
template<typename TestClassTy> class Register {
public:
Register(const std::string& identifier)
diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/TestObject.cpp b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/TestObject.cpp
index 0b32191..8946c0e 100644
--- a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/TestObject.cpp
+++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/TestObject.cpp
@@ -59,18 +59,29 @@ NPClass *getTestClass(void)
return &testClass;
}
-static bool identifiersInitialized = false;
+typedef struct {
+ NPObject header;
+ NPObject* testObject;
+} TestObject;
-#define ID_OBJECT_POINTER 2
+static bool identifiersInitialized = false;
#define NUM_ENUMERATABLE_TEST_IDENTIFIERS 2
-#define NUM_TEST_IDENTIFIERS 3
+
+enum {
+ ID_PROPERTY_FOO = 0,
+ ID_PROPERTY_BAR,
+ ID_PROPERTY_OBJECT_POINTER,
+ ID_PROPERTY_TEST_OBJECT,
+ NUM_TEST_IDENTIFIERS,
+};
static NPIdentifier testIdentifiers[NUM_TEST_IDENTIFIERS];
static const NPUTF8 *testIdentifierNames[NUM_TEST_IDENTIFIERS] = {
"foo",
"bar",
"objectPointer",
+ "testObject",
};
#define ID_THROW_EXCEPTION_METHOD 0
@@ -87,20 +98,24 @@ static void initializeIdentifiers(void)
browser->getstringidentifiers(testMethodIdentifierNames, NUM_METHOD_IDENTIFIERS, testMethodIdentifiers);
}
-static NPObject *testAllocate(NPP /*npp*/, NPClass* /*theClass*/)
+static NPObject* testAllocate(NPP /*npp*/, NPClass* /*theClass*/)
{
- NPObject *newInstance = static_cast<NPObject*>(malloc(sizeof(NPObject)));
-
+ TestObject* newInstance = static_cast<TestObject*>(malloc(sizeof(TestObject)));
+ newInstance->testObject = 0;
+
if (!identifiersInitialized) {
identifiersInitialized = true;
initializeIdentifiers();
}
-
- return newInstance;
+
+ return reinterpret_cast<NPObject*>(newInstance);
}
static void testDeallocate(NPObject *obj)
{
+ TestObject* testObject = reinterpret_cast<TestObject*>(obj);
+ if (testObject->testObject)
+ browser->releaseobject(testObject->testObject);
free(obj);
}
@@ -134,17 +149,30 @@ static bool testHasProperty(NPObject*, NPIdentifier name)
static bool testGetProperty(NPObject* npobj, NPIdentifier name, NPVariant* result)
{
- if (name == testIdentifiers[ID_OBJECT_POINTER]) {
+ if (name == testIdentifiers[ID_PROPERTY_FOO]) {
+ char* mem = static_cast<char*>(browser->memalloc(4));
+ strcpy(mem, "foo");
+ STRINGZ_TO_NPVARIANT(mem, *result);
+ return true;
+ }
+ if (name == testIdentifiers[ID_PROPERTY_OBJECT_POINTER]) {
int32_t objectPointer = static_cast<int32_t>(reinterpret_cast<long long>(npobj));
INT32_TO_NPVARIANT(objectPointer, *result);
return true;
}
+ if (name == testIdentifiers[ID_PROPERTY_TEST_OBJECT]) {
+ TestObject* testObject = reinterpret_cast<TestObject*>(npobj);
+ if (!testObject->testObject)
+ testObject->testObject = browser->createobject(0, &testClass);
+ browser->retainobject(testObject->testObject);
+ OBJECT_TO_NPVARIANT(testObject->testObject, *result);
+ return true;
+ }
return false;
}
-
static bool testEnumerate(NPObject* /*npobj*/, NPIdentifier **value, uint32_t *count)
{
*count = NUM_ENUMERATABLE_TEST_IDENTIFIERS;
@@ -163,5 +191,3 @@ static bool testConstruct(NPObject* npobj, const NPVariant* /*args*/, uint32_t /
OBJECT_TO_NPVARIANT(npobj, *result);
return true;
}
-
-
diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/EvaluateJSAfterRemovingPluginElement.cpp b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/EvaluateJSAfterRemovingPluginElement.cpp
new file mode 100644
index 0000000..4b5d3e0
--- /dev/null
+++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/EvaluateJSAfterRemovingPluginElement.cpp
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "PluginTest.h"
+
+#include "PluginObject.h"
+
+using namespace std;
+
+// Executing JS after removing the plugin element from the document should not crash.
+
+class EvaluateJSAfterRemovingPluginElement : public PluginTest {
+public:
+ EvaluateJSAfterRemovingPluginElement(NPP, const string& identifier);
+
+private:
+ virtual NPError NPP_DestroyStream(NPStream*, NPReason);
+
+ bool m_didExecuteScript;
+};
+
+static PluginTest::Register<EvaluateJSAfterRemovingPluginElement> registrar("evaluate-js-after-removing-plugin-element");
+
+EvaluateJSAfterRemovingPluginElement::EvaluateJSAfterRemovingPluginElement(NPP npp, const string& identifier)
+ : PluginTest(npp, identifier)
+ , m_didExecuteScript(false)
+{
+ waitUntilDone();
+}
+
+NPError EvaluateJSAfterRemovingPluginElement::NPP_DestroyStream(NPStream*, NPReason)
+{
+ if (m_didExecuteScript)
+ return NPERR_NO_ERROR;
+ m_didExecuteScript = true;
+
+ executeScript("var plugin = document.getElementsByTagName('embed')[0]; plugin.parentElement.removeChild(plugin);");
+ executeScript("document.body.appendChild(document.createTextNode('Executing script after removing the plugin element from the document succeeded.'));");
+ notifyDone();
+
+ return NPERR_NO_ERROR;
+}
diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/DrawsGradient.cpp b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/DrawsGradient.cpp
new file mode 100644
index 0000000..2b06198
--- /dev/null
+++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/DrawsGradient.cpp
@@ -0,0 +1,118 @@
+/* Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "WindowedPluginTest.h"
+
+#include "PluginObject.h"
+
+using namespace std;
+
+// Just fills its window with some gradients
+
+class DrawsGradient : public WindowedPluginTest {
+public:
+ DrawsGradient(NPP, const string& identifier);
+
+private:
+ void paint(HDC) const;
+
+ LRESULT onPaint(WPARAM, LPARAM, bool& handled);
+ LRESULT onPrintClient(WPARAM, LPARAM, bool& handled);
+
+ virtual LRESULT wndProc(UINT message, WPARAM, LPARAM, bool& handled);
+};
+
+static PluginTest::Register<DrawsGradient> registrar("draws-gradient");
+
+DrawsGradient::DrawsGradient(NPP npp, const string& identifier)
+ : WindowedPluginTest(npp, identifier)
+{
+}
+
+LRESULT DrawsGradient::wndProc(UINT message, WPARAM wParam, LPARAM lParam, bool& handled)
+{
+ LRESULT result = 0;
+
+ switch (message) {
+ case WM_PAINT:
+ result = onPaint(wParam, lParam, handled);
+ break;
+ case WM_PRINTCLIENT:
+ result = onPrintClient(wParam, lParam, handled);
+ break;
+ default:
+ handled = false;
+ }
+
+ return result;
+}
+
+LRESULT DrawsGradient::onPaint(WPARAM, LPARAM, bool& handled)
+{
+ PAINTSTRUCT paintStruct;
+ HDC dc = ::BeginPaint(window(), &paintStruct);
+ if (!dc)
+ return 0;
+
+ paint(dc);
+ ::EndPaint(window(), &paintStruct);
+
+ handled = true;
+ return 0;
+}
+
+LRESULT DrawsGradient::onPrintClient(WPARAM wParam, LPARAM, bool& handled)
+{
+ paint(reinterpret_cast<HDC>(wParam));
+
+ handled = true;
+ return 0;
+}
+
+void DrawsGradient::paint(HDC dc) const
+{
+ RECT clientRect;
+ if (!::GetClientRect(window(), &clientRect))
+ return;
+
+ TRIVERTEX vertices[] = {
+ // Upper-left: green
+ { clientRect.left, clientRect.top, 0, 0xff00, 0, 0 },
+ // Upper-right: blue
+ { clientRect.right, clientRect.top, 0, 0, 0xff00, 0 },
+ // Lower-left: yellow
+ { clientRect.left, clientRect.bottom, 0xff00, 0xff00, 0, 0 },
+ // Lower-right: red
+ { clientRect.right, clientRect.bottom, 0xff00, 0, 0, 0 },
+ };
+
+ GRADIENT_TRIANGLE mesh[] = {
+ // Upper-left triangle
+ { 0, 1, 2 },
+ // Lower-right triangle
+ { 1, 2, 3 },
+ };
+
+ ::GradientFill(dc, vertices, _countof(vertices), mesh, _countof(mesh), GRADIENT_FILL_TRIANGLE);
+}
diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/NPNInvalidateRectInvalidatesWindow.cpp b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/NPNInvalidateRectInvalidatesWindow.cpp
index 90ea54d..e598c49 100644
--- a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/NPNInvalidateRectInvalidatesWindow.cpp
+++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/NPNInvalidateRectInvalidatesWindow.cpp
@@ -23,7 +23,7 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "PluginTest.h"
+#include "WindowedPluginTest.h"
#include "PluginObject.h"
@@ -69,28 +69,24 @@ TemporaryWindowMover::~TemporaryWindowMover()
::SetWindowPos(m_window, 0, m_savedWindowRect.left, m_savedWindowRect.top, 0, 0, SWP_HIDEWINDOW | standardSetWindowPosFlags);
}
-class NPNInvalidateRectInvalidatesWindow : public PluginTest {
+class NPNInvalidateRectInvalidatesWindow : public WindowedPluginTest {
public:
NPNInvalidateRectInvalidatesWindow(NPP, const string& identifier);
~NPNInvalidateRectInvalidatesWindow();
private:
- static LRESULT CALLBACK wndProc(HWND, UINT message, WPARAM, LPARAM);
+ virtual LRESULT wndProc(UINT message, WPARAM, LPARAM, bool& handled);
void onPaint();
void testInvalidateRect();
virtual NPError NPP_SetWindow(NPP, NPWindow*);
- HWND m_window;
- WNDPROC m_originalWndProc;
TemporaryWindowMover* m_windowMover;
};
NPNInvalidateRectInvalidatesWindow::NPNInvalidateRectInvalidatesWindow(NPP npp, const string& identifier)
- : PluginTest(npp, identifier)
- , m_window(0)
- , m_originalWndProc(0)
+ : WindowedPluginTest(npp, identifier)
, m_windowMover(0)
{
}
@@ -100,30 +96,20 @@ NPNInvalidateRectInvalidatesWindow::~NPNInvalidateRectInvalidatesWindow()
delete m_windowMover;
}
-NPError NPNInvalidateRectInvalidatesWindow::NPP_SetWindow(NPP instance, NPWindow* window)
+NPError NPNInvalidateRectInvalidatesWindow::NPP_SetWindow(NPP instance, NPWindow* npWindow)
{
- HWND newWindow = reinterpret_cast<HWND>(window->window);
- if (newWindow == m_window)
- return NPERR_NO_ERROR;
-
- if (m_window) {
- ::RemovePropW(m_window, instancePointerProperty);
- ::SetWindowLongPtr(m_window, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(m_originalWndProc));
- m_originalWndProc = 0;
- }
+ NPError error = WindowedPluginTest::NPP_SetWindow(instance, npWindow);
+ if (error != NPERR_NO_ERROR)
+ return error;
- m_window = newWindow;
- if (!m_window)
+ if (!window())
return NPERR_NO_ERROR;
- m_originalWndProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtrW(m_window, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(wndProc)));
- ::SetPropW(m_window, instancePointerProperty, this);
-
// The test harness's window (the one that contains the WebView) is off-screen and hidden.
// We need to move it on-screen and make it visible in order for the plugin's window to
// accumulate an update region when the DWM is disabled.
- HWND testHarnessWindow = ::GetAncestor(m_window, GA_ROOT);
+ HWND testHarnessWindow = ::GetAncestor(window(), GA_ROOT);
if (!testHarnessWindow) {
pluginLog(instance, "Failed to get test harness window");
return NPERR_GENERIC_ERROR;
@@ -141,14 +127,13 @@ NPError NPNInvalidateRectInvalidatesWindow::NPP_SetWindow(NPP instance, NPWindow
return NPERR_NO_ERROR;
}
-LRESULT NPNInvalidateRectInvalidatesWindow::wndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
+LRESULT NPNInvalidateRectInvalidatesWindow::wndProc(UINT message, WPARAM wParam, LPARAM lParam, bool& handled)
{
- NPNInvalidateRectInvalidatesWindow* instance = reinterpret_cast<NPNInvalidateRectInvalidatesWindow*>(::GetPropW(hwnd, instancePointerProperty));
-
if (message == WM_PAINT)
- instance->onPaint();
+ onPaint();
- return ::CallWindowProcW(instance->m_originalWndProc, hwnd, message, wParam, lParam);
+ handled = false;
+ return 0;
}
void NPNInvalidateRectInvalidatesWindow::onPaint()
@@ -162,7 +147,7 @@ void NPNInvalidateRectInvalidatesWindow::onPaint()
void NPNInvalidateRectInvalidatesWindow::testInvalidateRect()
{
RECT clientRect;
- if (!::GetClientRect(m_window, &clientRect)) {
+ if (!::GetClientRect(window(), &clientRect)) {
pluginLog(m_npp, "::GetClientRect failed");
return;
}
@@ -173,7 +158,7 @@ void NPNInvalidateRectInvalidatesWindow::testInvalidateRect()
}
// Clear the invalid region.
- if (!::ValidateRect(m_window, 0)) {
+ if (!::ValidateRect(window(), 0)) {
pluginLog(m_npp, "::ValidateRect failed");
return;
}
@@ -187,7 +172,7 @@ void NPNInvalidateRectInvalidatesWindow::testInvalidateRect()
NPN_InvalidateRect(&rectToInvalidate);
RECT invalidRect;
- if (!::GetUpdateRect(m_window, &invalidRect, FALSE)) {
+ if (!::GetUpdateRect(window(), &invalidRect, FALSE)) {
pluginLog(m_npp, "::GetUpdateRect failed");
return;
}
diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/WindowRegionIsSetToClipRect.cpp b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/WindowRegionIsSetToClipRect.cpp
new file mode 100644
index 0000000..975a598
--- /dev/null
+++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/WindowRegionIsSetToClipRect.cpp
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "PluginTest.h"
+
+#include "PluginObject.h"
+
+using namespace std;
+
+// The plugin's window's window region should be set to the plugin's clip rect.
+
+class WindowRegionIsSetToClipRect : public PluginTest {
+public:
+ WindowRegionIsSetToClipRect(NPP, const string& identifier);
+
+private:
+ virtual NPError NPP_SetWindow(NPP, NPWindow*);
+
+ bool m_didReceiveInitialSetWindowCall;
+};
+
+static PluginTest::Register<WindowRegionIsSetToClipRect> registrar("window-region-is-set-to-clip-rect");
+
+WindowRegionIsSetToClipRect::WindowRegionIsSetToClipRect(NPP npp, const string& identifier)
+ : PluginTest(npp, identifier)
+ , m_didReceiveInitialSetWindowCall(false)
+{
+}
+
+NPError WindowRegionIsSetToClipRect::NPP_SetWindow(NPP instance, NPWindow* window)
+{
+ if (m_didReceiveInitialSetWindowCall)
+ return NPERR_NO_ERROR;
+ m_didReceiveInitialSetWindowCall = true;
+
+ if (window->type != NPWindowTypeWindow) {
+ pluginLog(instance, "window->type should be NPWindowTypeWindow but was %d", window->type);
+ return NPERR_GENERIC_ERROR;
+ }
+
+ HWND hwnd = reinterpret_cast<HWND>(window->window);
+
+ RECT regionRect;
+ if (::GetWindowRgnBox(hwnd, &regionRect) == ERROR) {
+ pluginLog(instance, "::GetWindowRgnBox failed with error %u", ::GetLastError());
+ return NPERR_GENERIC_ERROR;
+ }
+
+ // This expected rect is based on the layout of window-region-is-set-to-clip-rect.html.
+ RECT expectedRect = { 50, 50, 100, 100 };
+ if (!::EqualRect(&regionRect, &expectedRect)) {
+ pluginLog(instance, "Expected region rect {left=%u, top=%u, right=%u, bottom=%u}, but got {left=%d, top=%d, right=%d, bottom=%d}", expectedRect.left, expectedRect.top, expectedRect.right, expectedRect.bottom, regionRect.left, regionRect.top, regionRect.right, regionRect.bottom);
+ return NPERR_GENERIC_ERROR;
+ }
+
+ pluginLog(instance, "PASS: Plugin's window's window region has been set as expected");
+
+ // While we're here, check that our window class doesn't have the CS_PARENTDC style, which
+ // defeats clipping by ignoring the window region and always clipping to the parent window.
+ // FIXME: It would be nice to have a pixel test that shows that we're
+ // getting clipped correctly, but unfortunately window regions are ignored
+ // during WM_PRINT (see <http://webkit.org/b/49034>).
+ wchar_t className[512];
+ if (!::GetClassNameW(hwnd, className, _countof(className))) {
+ pluginLog(instance, "::GetClassName failed with error %u", ::GetLastError());
+ return NPERR_GENERIC_ERROR;
+ }
+
+#ifdef DEBUG_ALL
+ const wchar_t webKitDLLName[] = L"WebKit_debug.dll";
+#else
+ const wchar_t webKitDLLName[] = L"WebKit.dll";
+#endif
+ HMODULE webKitModule = ::GetModuleHandleW(webKitDLLName);
+ if (!webKitModule) {
+ pluginLog(instance, "::GetModuleHandleW failed with error %u", ::GetLastError());
+ return NPERR_GENERIC_ERROR;
+ }
+
+ WNDCLASSW wndClass;
+ if (!::GetClassInfoW(webKitModule, className, &wndClass)) {
+ pluginLog(instance, "::GetClassInfoW failed with error %u", ::GetLastError());
+ return NPERR_GENERIC_ERROR;
+ }
+
+ if (wndClass.style & CS_PARENTDC)
+ pluginLog(instance, "FAIL: Plugin's window's class has the CS_PARENTDC style, which will defeat clipping");
+ else
+ pluginLog(instance, "PASS: Plugin's window's class does not have the CS_PARENTDC style");
+
+ return NPERR_NO_ERROR;
+}
diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/main.cpp b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/main.cpp
index e5246c4..2110a8a 100644
--- a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/main.cpp
+++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/main.cpp
@@ -29,6 +29,10 @@
#include <cstdlib>
#include <string>
+#ifdef XP_UNIX
+#include <X11/Xlib.h>
+#endif
+
#if !defined(NP_NO_CARBON) && defined(QD_HEADERS_ARE_PRIVATE) && QD_HEADERS_ARE_PRIVATE
extern "C" void GlobalToLocal(Point*);
#endif
@@ -565,6 +569,54 @@ static int16_t handleEventCocoa(NPP instance, PluginObject* obj, NPCocoaEvent* e
#endif // XP_MACOSX
+#ifdef XP_UNIX
+static int16_t handleEventX11(NPP instance, PluginObject* obj, XEvent* event)
+{
+ XButtonPressedEvent* buttonPressEvent = reinterpret_cast<XButtonPressedEvent*>(event);
+ XButtonReleasedEvent* buttonReleaseEvent = reinterpret_cast<XButtonReleasedEvent*>(event);
+ switch (event->type) {
+ case ButtonPress:
+ pluginLog(instance, "mouseDown at (%d, %d)", buttonPressEvent->x, buttonPressEvent->y);
+ if (obj->evaluateScriptOnMouseDownOrKeyDown && obj->mouseDownForEvaluateScript)
+ executeScript(obj, obj->evaluateScriptOnMouseDownOrKeyDown);
+ break;
+ case ButtonRelease:
+ pluginLog(instance, "mouseUp at (%d, %d)", buttonReleaseEvent->x, buttonReleaseEvent->y);
+ break;
+ case KeyPress:
+ // FIXME: extract key code
+ pluginLog(instance, "NOTIMPLEMENTED: keyDown '%c'", ' ');
+ if (obj->evaluateScriptOnMouseDownOrKeyDown && !obj->mouseDownForEvaluateScript)
+ executeScript(obj, obj->evaluateScriptOnMouseDownOrKeyDown);
+ break;
+ case KeyRelease:
+ // FIXME: extract key code
+ pluginLog(instance, "NOTIMPLEMENTED: keyUp '%c'", ' ');
+ break;
+ case GraphicsExpose:
+ pluginLog(instance, "updateEvt");
+ break;
+ // NPAPI events
+ case FocusIn:
+ pluginLog(instance, "getFocusEvent");
+ break;
+ case FocusOut:
+ pluginLog(instance, "loseFocusEvent");
+ break;
+ case EnterNotify:
+ case LeaveNotify:
+ case MotionNotify:
+ pluginLog(instance, "adjustCursorEvent");
+ break;
+ default:
+ pluginLog(instance, "event %d", event->type);
+ }
+
+ fflush(stdout);
+ return 0;
+}
+#endif // XP_UNIX
+
int16_t NPP_HandleEvent(NPP instance, void *event)
{
PluginObject* obj = static_cast<PluginObject*>(instance->pdata);
@@ -579,6 +631,8 @@ int16_t NPP_HandleEvent(NPP instance, void *event)
assert(obj->eventModel == NPEventModelCocoa);
return handleEventCocoa(instance, obj, static_cast<NPCocoaEvent*>(event));
+#elif defined(XP_UNIX)
+ return handleEventX11(instance, obj, static_cast<XEvent*>(event));
#else
// FIXME: Implement for other platforms.
return 0;
diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/win/TestNetscapePlugin.vcproj b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/win/TestNetscapePlugin.vcproj
index 74042bc..a2e6809 100644
--- a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/win/TestNetscapePlugin.vcproj
+++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/win/TestNetscapePlugin.vcproj
@@ -39,7 +39,7 @@
/>
<Tool
Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="&quot;$(WebKitOutputDir)\Include&quot;;&quot;$(WebKitOutputDir)\Include\JavaScriptCore&quot;;&quot;$(WebKitOutputDir)\Include\WebCore\ForwardingHeaders&quot;;&quot;$(ProjectDir)..\..\TestNetscapePlugin&quot;;&quot;$(WebKitLibrariesDir)\include&quot;"
+ AdditionalIncludeDirectories="&quot;$(ProjectDir)&quot;;&quot;$(ProjectDir)..&quot;;&quot;$(WebKitOutputDir)\Include&quot;;&quot;$(WebKitOutputDir)\Include\JavaScriptCore&quot;;&quot;$(WebKitOutputDir)\Include\WebCore\ForwardingHeaders&quot;;&quot;$(WebKitLibrariesDir)\include&quot;"
PreprocessorDefinitions="_USRDLL;TESTNETSCAPEPLUGIN_EXPORTS;snprintf=_snprintf"
DisableSpecificWarnings="4819"
/>
@@ -55,6 +55,7 @@
/>
<Tool
Name="VCLinkerTool"
+ AdditionalDependencies="Msimg32.lib"
OutputFile="$(OutDir)\$(ProjectName)$(WebKitConfigSuffix)\np$(ProjectName)$(WebKitConfigSuffix).dll"
ModuleDefinitionFile="TestNetscapePlugin$(WebKitConfigSuffix).def"
/>
@@ -109,7 +110,7 @@
/>
<Tool
Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="&quot;$(WebKitOutputDir)\Include&quot;;&quot;$(WebKitOutputDir)\Include\JavaScriptCore&quot;;&quot;$(WebKitOutputDir)\Include\WebCore\ForwardingHeaders&quot;;&quot;$(ProjectDir)..\..\TestNetscapePlugin&quot;;&quot;$(WebKitLibrariesDir)\include&quot;"
+ AdditionalIncludeDirectories="&quot;$(ProjectDir)&quot;;&quot;$(ProjectDir)..&quot;;&quot;$(WebKitOutputDir)\Include&quot;;&quot;$(WebKitOutputDir)\Include\JavaScriptCore&quot;;&quot;$(WebKitOutputDir)\Include\WebCore\ForwardingHeaders&quot;;&quot;$(WebKitLibrariesDir)\include&quot;"
PreprocessorDefinitions="_USRDLL;TESTNETSCAPEPLUGIN_EXPORTS;snprintf=_snprintf"
DisableSpecificWarnings="4819"
/>
@@ -125,6 +126,7 @@
/>
<Tool
Name="VCLinkerTool"
+ AdditionalDependencies="Msimg32.lib"
OutputFile="$(OutDir)\$(ProjectName)$(WebKitConfigSuffix)\np$(ProjectName)$(WebKitConfigSuffix).dll"
ModuleDefinitionFile="TestNetscapePlugin$(WebKitConfigSuffix).def"
/>
@@ -178,7 +180,7 @@
/>
<Tool
Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="&quot;$(WebKitOutputDir)\Include&quot;;&quot;$(WebKitOutputDir)\Include\JavaScriptCore&quot;;&quot;$(WebKitOutputDir)\Include\WebCore\ForwardingHeaders&quot;;&quot;$(ProjectDir)..\..\TestNetscapePlugin&quot;;&quot;$(WebKitLibrariesDir)\include&quot;"
+ AdditionalIncludeDirectories="&quot;$(ProjectDir)&quot;;&quot;$(ProjectDir)..&quot;;&quot;$(WebKitOutputDir)\Include&quot;;&quot;$(WebKitOutputDir)\Include\JavaScriptCore&quot;;&quot;$(WebKitOutputDir)\Include\WebCore\ForwardingHeaders&quot;;&quot;$(WebKitLibrariesDir)\include&quot;"
PreprocessorDefinitions="_USRDLL;TESTNETSCAPEPLUGIN_EXPORTS;snprintf=_snprintf"
RuntimeLibrary="3"
DisableSpecificWarnings="4819"
@@ -195,6 +197,7 @@
/>
<Tool
Name="VCLinkerTool"
+ AdditionalDependencies="Msimg32.lib"
OutputFile="$(OutDir)\$(ProjectName)$(WebKitConfigSuffix)\np$(ProjectName)$(WebKitConfigSuffix).dll"
ModuleDefinitionFile="TestNetscapePlugin$(WebKitConfigSuffix).def"
/>
@@ -248,7 +251,7 @@
/>
<Tool
Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="&quot;$(WebKitOutputDir)\Include&quot;;&quot;$(WebKitOutputDir)\Include\JavaScriptCore&quot;;&quot;$(WebKitOutputDir)\Include\WebCore\ForwardingHeaders&quot;;&quot;$(ProjectDir)..\..\TestNetscapePlugin&quot;;&quot;$(WebKitLibrariesDir)\include&quot;"
+ AdditionalIncludeDirectories="&quot;$(ProjectDir)&quot;;&quot;$(ProjectDir)..&quot;;&quot;$(WebKitOutputDir)\Include&quot;;&quot;$(WebKitOutputDir)\Include\JavaScriptCore&quot;;&quot;$(WebKitOutputDir)\Include\WebCore\ForwardingHeaders&quot;;&quot;$(WebKitLibrariesDir)\include&quot;"
PreprocessorDefinitions="_USRDLL;TESTNETSCAPEPLUGIN_EXPORTS;snprintf=_snprintf"
DisableSpecificWarnings="4819"
/>
@@ -264,6 +267,7 @@
/>
<Tool
Name="VCLinkerTool"
+ AdditionalDependencies="Msimg32.lib"
OutputFile="$(OutDir)\$(ProjectName)$(WebKitConfigSuffix)\np$(ProjectName)$(WebKitConfigSuffix).dll"
ModuleDefinitionFile="TestNetscapePlugin$(WebKitConfigSuffix).def"
/>
@@ -317,7 +321,7 @@
/>
<Tool
Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="&quot;$(WebKitOutputDir)\Include&quot;;&quot;$(WebKitOutputDir)\Include\JavaScriptCore&quot;;&quot;$(WebKitOutputDir)\Include\WebCore\ForwardingHeaders&quot;;&quot;$(ProjectDir)..\..\TestNetscapePlugin&quot;;&quot;$(WebKitLibrariesDir)\include&quot;"
+ AdditionalIncludeDirectories="&quot;$(ProjectDir)&quot;;&quot;$(ProjectDir)..&quot;;&quot;$(WebKitOutputDir)\Include&quot;;&quot;$(WebKitOutputDir)\Include\JavaScriptCore&quot;;&quot;$(WebKitOutputDir)\Include\WebCore\ForwardingHeaders&quot;;&quot;$(WebKitLibrariesDir)\include&quot;"
PreprocessorDefinitions="_USRDLL;TESTNETSCAPEPLUGIN_EXPORTS;snprintf=_snprintf"
RuntimeLibrary="3"
DisableSpecificWarnings="4819"
@@ -334,6 +338,7 @@
/>
<Tool
Name="VCLinkerTool"
+ AdditionalDependencies="Msimg32.lib"
OutputFile="$(OutDir)\$(ProjectName)$(WebKitConfigSuffix)\np$(ProjectName)$(WebKitConfigSuffix).dll"
ModuleDefinitionFile="TestNetscapePlugin$(WebKitConfigSuffix).def"
/>
@@ -375,6 +380,10 @@
>
</File>
<File
+ RelativePath="..\Tests\EvaluateJSAfterRemovingPluginElement.cpp"
+ >
+ </File>
+ <File
RelativePath="..\Tests\NPRuntimeObjectFromDestroyedPlugin.cpp"
>
</File>
@@ -398,6 +407,10 @@
Name="win"
>
<File
+ RelativePath="..\Tests\win\DrawsGradient.cpp"
+ >
+ </File>
+ <File
RelativePath="..\Tests\win\GetValueNetscapeWindow.cpp"
>
</File>
@@ -409,8 +422,24 @@
RelativePath="..\Tests\win\WindowGeometryInitializedBeforeSetWindow.cpp"
>
</File>
+ <File
+ RelativePath="..\Tests\win\WindowRegionIsSetToClipRect.cpp"
+ >
+ </File>
</Filter>
</Filter>
+ <Filter
+ Name="win"
+ >
+ <File
+ RelativePath=".\WindowedPluginTest.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\WindowedPluginTest.h"
+ >
+ </File>
+ </Filter>
<File
RelativePath="..\main.cpp"
>
diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/win/WindowedPluginTest.cpp b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/win/WindowedPluginTest.cpp
new file mode 100644
index 0000000..96b51f8
--- /dev/null
+++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/win/WindowedPluginTest.cpp
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "WindowedPluginTest.h"
+
+using namespace std;
+
+static const wchar_t instancePointerProperty[] = L"org.webkit.TestNetscapePlugin.WindowedPluginTest.InstancePointer";
+
+WindowedPluginTest::WindowedPluginTest(NPP npp, const string& identifier)
+ : PluginTest(npp, identifier)
+ , m_window(0)
+ , m_originalWndProc(0)
+{
+}
+
+NPError WindowedPluginTest::NPP_SetWindow(NPP instance, NPWindow* window)
+{
+ HWND newWindow = reinterpret_cast<HWND>(window->window);
+ if (newWindow == m_window)
+ return NPERR_NO_ERROR;
+
+ if (m_window) {
+ ::RemovePropW(m_window, instancePointerProperty);
+ ::SetWindowLongPtr(m_window, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(m_originalWndProc));
+ m_originalWndProc = 0;
+ }
+
+ m_window = newWindow;
+ if (!m_window)
+ return NPERR_NO_ERROR;
+
+ m_originalWndProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtrW(m_window, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(staticWndProc)));
+ ::SetPropW(m_window, instancePointerProperty, this);
+
+ return NPERR_NO_ERROR;
+}
+
+LRESULT WindowedPluginTest::staticWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ WindowedPluginTest* instance = reinterpret_cast<WindowedPluginTest*>(::GetPropW(hwnd, instancePointerProperty));
+
+ bool handled = false;
+ LRESULT result = instance->wndProc(message, wParam, lParam, handled);
+ if (handled)
+ return result;
+
+ return ::CallWindowProcW(instance->m_originalWndProc, hwnd, message, wParam, lParam);
+}
diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/win/WindowedPluginTest.h b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/win/WindowedPluginTest.h
new file mode 100644
index 0000000..7abc734
--- /dev/null
+++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/win/WindowedPluginTest.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WindowedPluginTest_h
+#define WindowedPluginTest_h
+
+#include "PluginTest.h"
+
+class WindowedPluginTest : public PluginTest {
+protected:
+ WindowedPluginTest(NPP, const std::string& identifier);
+
+ HWND window() const { return m_window; }
+
+ // For derived classes to override
+ virtual LRESULT wndProc(UINT message, WPARAM, LPARAM, bool& handled) = 0;
+
+ // PluginTest
+ virtual NPError NPP_SetWindow(NPP, NPWindow*);
+
+private:
+ static LRESULT CALLBACK staticWndProc(HWND, UINT message, WPARAM, LPARAM);
+
+ HWND m_window;
+ WNDPROC m_originalWndProc;
+};
+
+#endif // WindowedPluginTest_h