summaryrefslogtreecommitdiffstats
path: root/WebKitTools/DumpRenderTree/TestNetscapePlugIn
diff options
context:
space:
mode:
Diffstat (limited to 'WebKitTools/DumpRenderTree/TestNetscapePlugIn')
-rw-r--r--WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginTest.cpp5
-rw-r--r--WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginTest.h1
-rw-r--r--WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/PassDifferentNPPStruct.cpp70
-rw-r--r--WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/GetValueNetscapeWindow.cpp73
-rw-r--r--WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/WindowGeometryInitializedBeforeSetWindow.cpp9
-rw-r--r--WebKitTools/DumpRenderTree/TestNetscapePlugIn/main.cpp24
-rw-r--r--WebKitTools/DumpRenderTree/TestNetscapePlugIn/win/TestNetscapePlugin.vcproj8
7 files changed, 177 insertions, 13 deletions
diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginTest.cpp b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginTest.cpp
index 83eda3a..d435a2e 100644
--- a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginTest.cpp
+++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginTest.cpp
@@ -75,6 +75,11 @@ NPIdentifier PluginTest::NPN_GetIntIdentifier(int32_t intid)
return browser->getintidentifier(intid);
}
+NPError PluginTest::NPN_GetValue(NPNVariable variable, void* value)
+{
+ return browser->getvalue(m_npp, variable, value);
+}
+
NPObject* PluginTest::NPN_CreateObject(NPClass* npClass)
{
return browser->createobject(m_npp, npClass);
diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginTest.h b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginTest.h
index 2e896a6..cbc7934 100644
--- a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginTest.h
+++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginTest.h
@@ -62,6 +62,7 @@ public:
// NPN functions.
NPIdentifier NPN_GetStringIdentifier(const NPUTF8* name);
NPIdentifier NPN_GetIntIdentifier(int32_t intid);
+ NPError NPN_GetValue(NPNVariable, void* value);
NPObject* NPN_CreateObject(NPClass*);
bool NPN_RemoveProperty(NPObject*, NPIdentifier propertyName);
diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/PassDifferentNPPStruct.cpp b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/PassDifferentNPPStruct.cpp
new file mode 100644
index 0000000..e464996
--- /dev/null
+++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/PassDifferentNPPStruct.cpp
@@ -0,0 +1,70 @@
+/*
+ * 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;
+
+// Passing a different NPP struct that has the same ndata value as the one passed to NPP_New should
+// not trigger an assertion failure.
+
+class PassDifferentNPPStruct : public PluginTest {
+public:
+ PassDifferentNPPStruct(NPP npp, const string& identifier)
+ : PluginTest(npp, identifier)
+ , m_didReceiveInitialSetWindowCall(false)
+ {
+ }
+
+private:
+ virtual NPError NPP_SetWindow(NPP instance, NPWindow* window)
+ {
+ if (m_didReceiveInitialSetWindowCall)
+ return NPERR_NO_ERROR;
+ m_didReceiveInitialSetWindowCall = true;
+
+ NPP oldNPP = m_npp;
+ NPP_t differentNPP = *m_npp;
+ m_npp = &differentNPP;
+
+ NPBool privateMode;
+ NPError error = NPN_GetValue(NPNVprivateModeBool, &privateMode);
+
+ m_npp = oldNPP;
+
+ if (error != NPERR_NO_ERROR) {
+ pluginLog(instance, "NPN_GetValue(NPNVprivateModeBool) with a different NPP struct failed with error %d", error);
+ return NPERR_GENERIC_ERROR;
+ }
+ pluginLog(instance, "NPN_GetValue(NPNVprivateModeBool) with a different NPP struct succeeded");
+ return NPERR_NO_ERROR;
+ }
+
+ bool m_didReceiveInitialSetWindowCall;
+};
+
+static PluginTest::Register<PassDifferentNPPStruct> getValueNetscapeWindow("pass-different-npp-struct");
diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/GetValueNetscapeWindow.cpp b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/GetValueNetscapeWindow.cpp
new file mode 100644
index 0000000..32fd99b
--- /dev/null
+++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/GetValueNetscapeWindow.cpp
@@ -0,0 +1,73 @@
+/*
+ * 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;
+
+// NPN_GetValue(NPNVnetscapeWindow) should return a valid HWND.
+
+class GetValueNetscapeWindow : public PluginTest {
+public:
+ GetValueNetscapeWindow(NPP npp, const string& identifier)
+ : PluginTest(npp, identifier)
+ , m_didReceiveInitialSetWindowCall(false)
+ {
+ }
+
+private:
+ virtual NPError NPP_SetWindow(NPP instance, NPWindow* window)
+ {
+ if (m_didReceiveInitialSetWindowCall)
+ return NPERR_NO_ERROR;
+ m_didReceiveInitialSetWindowCall = true;
+
+ HWND hwnd;
+ NPError error = NPN_GetValue(NPNVnetscapeWindow, &hwnd);
+ if (error != NPERR_NO_ERROR) {
+ pluginLog(instance, "NPN_GetValue(NPNVnetscapeWindow) failed with error %d", error);
+ return NPERR_GENERIC_ERROR;
+ }
+
+ if (!::IsWindow(hwnd)) {
+ pluginLog(instance, "::IsWindow returned FALSE");
+ return NPERR_GENERIC_ERROR;
+ }
+
+ if (hwnd == window->window) {
+ pluginLog(instance, "NPN_GetValue(NPNVnetscapeWindow) returned the same value as NPWindow::window");
+ return NPERR_GENERIC_ERROR;
+ }
+
+ pluginLog(instance, "NPN_GetValue(NPNVnetscapeWindow) succeeded");
+ return NPERR_NO_ERROR;
+ }
+
+ bool m_didReceiveInitialSetWindowCall;
+};
+
+static PluginTest::Register<GetValueNetscapeWindow> getValueNetscapeWindow("get-value-netscape-window");
diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/WindowGeometryInitializedBeforeSetWindow.cpp b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/WindowGeometryInitializedBeforeSetWindow.cpp
index 40bceb9..8054497 100644
--- a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/WindowGeometryInitializedBeforeSetWindow.cpp
+++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/WindowGeometryInitializedBeforeSetWindow.cpp
@@ -35,12 +35,17 @@ class WindowGeometryInitializedBeforeSetWindow : public PluginTest {
public:
WindowGeometryInitializedBeforeSetWindow(NPP npp, const string& identifier)
: PluginTest(npp, identifier)
+ , m_didReceiveInitialSetWindowCall(false)
{
}
private:
virtual NPError 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;
@@ -77,7 +82,9 @@ private:
pluginLog(instance, "Plugin's HWND has been sized and positioned before NPP_SetWindow was called");
return NPERR_NO_ERROR;
- }
+ }
+
+ bool m_didReceiveInitialSetWindowCall;
};
static PluginTest::Register<WindowGeometryInitializedBeforeSetWindow> windowGeometryInitializedBeforeSetWindow("window-geometry-initialized-before-set-window");
diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/main.cpp b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/main.cpp
index dd894f4..e240c42 100644
--- a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/main.cpp
+++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/main.cpp
@@ -75,7 +75,7 @@ NPError STDCALL NP_GetEntryPoints(NPPluginFuncs *pluginFuncs)
{
getEntryPointsWasCalled = true;
-#if XP_MACOSX
+#ifdef XP_MACOSX
// Simulate Silverlight's behavior of crashing when NP_GetEntryPoints is called before NP_Initialize.
if (!initializeWasCalled)
CRASH();
@@ -111,7 +111,7 @@ NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc
{
bool forceCarbon = false;
-#if XP_MACOSX
+#ifdef XP_MACOSX
NPEventModel eventModel;
// Always turn on the CG model
@@ -158,7 +158,7 @@ NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc
PluginObject* obj = (PluginObject*)browser->createobject(instance, getPluginClass());
instance->pdata = obj;
-#if XP_MACOSX
+#ifdef XP_MACOSX
obj->eventModel = eventModel;
#if !defined(BUILDING_ON_TIGER)
obj->coreAnimationLayer = 0;
@@ -198,7 +198,7 @@ NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc
else if (strcasecmp(argn[i], "testwindowopen") == 0)
obj->testWindowOpen = TRUE;
else if (strcasecmp(argn[i], "drawingmodel") == 0) {
-#if XP_MACOSX && !defined(BUILDING_ON_TIGER)
+#if defined(XP_MACOSX) && !defined(BUILDING_ON_TIGER)
const char* value = argv[i];
if (strcasecmp(value, "coreanimation") == 0) {
if (supportsCoreAnimation)
@@ -234,7 +234,7 @@ NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc
}
}
-#if XP_MACOSX
+#ifdef XP_MACOSX
browser->setvalue(instance, NPPVpluginDrawingModel, (void *)drawingModelToUse);
#if !defined(BUILDING_ON_TIGER)
if (drawingModelToUse == NPDrawingModelCoreAnimation)
@@ -276,7 +276,7 @@ NPError NPP_Destroy(NPP instance, NPSavedData **save)
if (obj->logDestroy)
pluginLog(instance, "NPP_Destroy");
-#if XP_MACOSX && !defined(BUILDING_ON_TIGER)
+#if defined(XP_MACOSX) && !defined(BUILDING_ON_TIGER)
if (obj->coreAnimationLayer)
CFRelease(obj->coreAnimationLayer);
#endif
@@ -400,7 +400,7 @@ void NPP_Print(NPP instance, NPPrint *platformPrint)
{
}
-#if XP_MACOSX
+#ifdef XP_MACOSX
#ifndef NP_NO_CARBON
static int16_t handleEventCarbon(NPP instance, PluginObject* obj, EventRecord* event)
{
@@ -462,13 +462,13 @@ static int16_t handleEventCarbon(NPP instance, PluginObject* obj, EventRecord* e
pluginLog(instance, "kHighLevelEvent");
break;
// NPAPI events
- case getFocusEvent:
+ case NPEventType_GetFocusEvent:
pluginLog(instance, "getFocusEvent");
break;
- case loseFocusEvent:
+ case NPEventType_LoseFocusEvent:
pluginLog(instance, "loseFocusEvent");
break;
- case adjustCursorEvent:
+ case NPEventType_AdjustCursorEvent:
pluginLog(instance, "adjustCursorEvent");
break;
default:
@@ -548,7 +548,7 @@ int16_t NPP_HandleEvent(NPP instance, void *event)
if (!obj->eventLogging)
return 0;
-#if XP_MACOSX
+#ifdef XP_MACOSX
#ifndef NP_NO_CARBON
if (obj->eventModel == NPEventModelCarbon)
return handleEventCarbon(instance, obj, static_cast<EventRecord*>(event));
@@ -588,7 +588,7 @@ NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value)
return NPERR_NO_ERROR;
}
-#if XP_MACOSX && !defined(BUILDING_ON_TIGER)
+#if defined(XP_MACOSX) && !defined(BUILDING_ON_TIGER)
if (variable == NPPVpluginCoreAnimationLayer) {
if (!obj->coreAnimationLayer)
return NPERR_GENERIC_ERROR;
diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/win/TestNetscapePlugin.vcproj b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/win/TestNetscapePlugin.vcproj
index 5ffb832..cdd7729 100644
--- a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/win/TestNetscapePlugin.vcproj
+++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/win/TestNetscapePlugin.vcproj
@@ -383,6 +383,10 @@
>
</File>
<File
+ RelativePath="..\Tests\PassDifferentNPPStruct.cpp"
+ >
+ </File>
+ <File
RelativePath="..\Tests\PluginScriptableNPObjectInvokeDefault.cpp"
>
</File>
@@ -390,6 +394,10 @@
Name="win"
>
<File
+ RelativePath="..\Tests\win\GetValueNetscapeWindow.cpp"
+ >
+ </File>
+ <File
RelativePath="..\Tests\win\WindowGeometryInitializedBeforeSetWindow.cpp"
>
</File>