summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--webkit/tools/npapi_layout_test_plugin/PluginObject.cpp249
-rw-r--r--webkit/tools/npapi_layout_test_plugin/PluginObject.h54
-rw-r--r--webkit/tools/npapi_layout_test_plugin/TestObject.cpp52
-rw-r--r--webkit/tools/npapi_layout_test_plugin/TestObject.h52
-rw-r--r--webkit/tools/npapi_layout_test_plugin/main.cpp47
5 files changed, 229 insertions, 225 deletions
diff --git a/webkit/tools/npapi_layout_test_plugin/PluginObject.cpp b/webkit/tools/npapi_layout_test_plugin/PluginObject.cpp
index 3c005c3..99699d0 100644
--- a/webkit/tools/npapi_layout_test_plugin/PluginObject.cpp
+++ b/webkit/tools/npapi_layout_test_plugin/PluginObject.cpp
@@ -1,34 +1,26 @@
/*
- IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. ("Apple") in
- consideration of your agreement to the following terms, and your use, installation,
- modification or redistribution of this Apple software constitutes acceptance of these
- terms. If you do not agree with these terms, please do not use, install, modify or
- redistribute this Apple software.
-
- In consideration of your agreement to abide by the following terms, and subject to these
- terms, Apple grants you a personal, non-exclusive license, under Apple’s copyrights in
- this original Apple software (the "Apple Software"), to use, reproduce, modify and
- redistribute the Apple Software, with or without modifications, in source and/or binary
- forms; provided that if you redistribute the Apple Software in its entirety and without
- modifications, you must retain this notice and the following text and disclaimers in all
- such redistributions of the Apple Software. Neither the name, trademarks, service marks
- or logos of Apple Computer, Inc. may be used to endorse or promote products derived from
- the Apple Software without specific prior written permission from Apple. Except as expressly
- stated in this notice, no other rights or licenses, express or implied, are granted by Apple
- herein, including but not limited to any patent rights that may be infringed by your
- derivative works or by other works in which the Apple Software may be incorporated.
-
- The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES,
- EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT,
- MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS
- USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
-
- IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE,
- REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND
- WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR
- OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (C) 2006, 2007, 2008 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. ``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
+ * 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 "PluginObject.h"
@@ -41,22 +33,22 @@
#define snprintf sprintf_s
#endif
-static void pluginInvalidate(NPObject *obj);
-static bool pluginHasProperty(NPObject *obj, NPIdentifier name);
-static bool pluginHasMethod(NPObject *obj, NPIdentifier name);
-static bool pluginGetProperty(NPObject *obj, NPIdentifier name, NPVariant *variant);
-static bool pluginSetProperty(NPObject *obj, NPIdentifier name, const NPVariant *variant);
-static bool pluginInvoke(NPObject *obj, NPIdentifier name, const NPVariant *args, uint32_t argCount, NPVariant *result);
-static bool pluginInvokeDefault(NPObject *obj, const NPVariant *args, uint32_t argCount, NPVariant *result);
-static NPObject *pluginAllocate(NPP npp, NPClass *theClass);
-static void pluginDeallocate(NPObject *obj);
+static void pluginInvalidate(NPObject*);
+static bool pluginHasProperty(NPObject*, NPIdentifier name);
+static bool pluginHasMethod(NPObject*, NPIdentifier name);
+static bool pluginGetProperty(NPObject*, NPIdentifier name, NPVariant*);
+static bool pluginSetProperty(NPObject*, NPIdentifier name, const NPVariant*);
+static bool pluginInvoke(NPObject*, NPIdentifier name, const NPVariant* args, uint32_t argCount, NPVariant* result);
+static bool pluginInvokeDefault(NPObject*, const NPVariant* args, uint32_t argCount, NPVariant* result);
+static NPObject* pluginAllocate(NPP npp, NPClass*);
+static void pluginDeallocate(NPObject*);
-NPNetscapeFuncs *browser;
+NPNetscapeFuncs* browser;
-static NPClass pluginClass = {
+static NPClass pluginClass = {
NP_CLASS_STRUCT_VERSION,
- pluginAllocate,
- pluginDeallocate,
+ pluginAllocate,
+ pluginDeallocate,
pluginInvalidate,
pluginHasMethod,
pluginInvoke,
@@ -65,7 +57,7 @@ static NPClass pluginClass = {
pluginGetProperty,
pluginSetProperty,
};
-
+
NPClass *getPluginClass(void)
{
return &pluginClass;
@@ -73,13 +65,14 @@ NPClass *getPluginClass(void)
static bool identifiersInitialized = false;
-#define ID_PROPERTY_PROPERTY 0
-#define ID_PROPERTY_EVENT_LOGGING 1
-#define ID_PROPERTY_HAS_STREAM 2
-#define ID_PROPERTY_TEST_OBJECT 3
-#define ID_PROPERTY_LOG_DESTROY 4
-#define ID_PROPERTY_TEST_OBJECT_COUNT 5
-#define NUM_PROPERTY_IDENTIFIERS 6
+#define ID_PROPERTY_PROPERTY 0
+#define ID_PROPERTY_EVENT_LOGGING 1
+#define ID_PROPERTY_HAS_STREAM 2
+#define ID_PROPERTY_TEST_OBJECT 3
+#define ID_PROPERTY_LOG_DESTROY 4
+#define ID_PROPERTY_RETURN_ERROR_FROM_NEWSTREAM 5
+#define ID_PROPERTY_TEST_OBJECT_COUNT 6
+#define NUM_PROPERTY_IDENTIFIERS 7
static NPIdentifier pluginPropertyIdentifiers[NUM_PROPERTY_IDENTIFIERS];
static const NPUTF8 *pluginPropertyIdentifierNames[NUM_PROPERTY_IDENTIFIERS] = {
@@ -88,6 +81,7 @@ static const NPUTF8 *pluginPropertyIdentifierNames[NUM_PROPERTY_IDENTIFIERS] = {
"hasStream",
"testObject",
"logDestroy",
+ "returnErrorFromNewStream",
"testObjectCount",
};
@@ -137,7 +131,7 @@ static const NPUTF8 *pluginMethodIdentifierNames[NUM_METHOD_IDENTIFIERS] = {
"testPostURLFile",
};
-static NPUTF8* createCStringFromNPVariant(const NPVariant *variant)
+static NPUTF8* createCStringFromNPVariant(const NPVariant* variant)
{
size_t length = NPVARIANT_TO_STRING(*variant).UTF8Length;
NPUTF8* result = (NPUTF8*)malloc(length + 1);
@@ -168,44 +162,50 @@ static bool pluginHasMethod(NPObject *obj, NPIdentifier name)
return false;
}
-static bool pluginGetProperty(NPObject *obj, NPIdentifier name, NPVariant *variant)
+static bool pluginGetProperty(NPObject* obj, NPIdentifier name, NPVariant* result)
{
+ PluginObject* plugin = reinterpret_cast<PluginObject*>(obj);
if (name == pluginPropertyIdentifiers[ID_PROPERTY_PROPERTY]) {
- char* mem = static_cast<char*>(browser->memalloc(9));
- strcpy(mem, "property");
- STRINGZ_TO_NPVARIANT(mem, *variant);
+ STRINGZ_TO_NPVARIANT("property", *result);
return true;
} else if (name == pluginPropertyIdentifiers[ID_PROPERTY_EVENT_LOGGING]) {
- BOOLEAN_TO_NPVARIANT(((PluginObject *)obj)->eventLogging, *variant);
+ BOOLEAN_TO_NPVARIANT(plugin->eventLogging, *result);
return true;
} else if (name == pluginPropertyIdentifiers[ID_PROPERTY_LOG_DESTROY]) {
- BOOLEAN_TO_NPVARIANT(((PluginObject *)obj)->logDestroy, *variant);
- return true;
+ BOOLEAN_TO_NPVARIANT(plugin->logDestroy, *result);
+ return true;
} else if (name == pluginPropertyIdentifiers[ID_PROPERTY_HAS_STREAM]) {
- BOOLEAN_TO_NPVARIANT(((PluginObject *)obj)->stream != 0, *variant);
+ BOOLEAN_TO_NPVARIANT(plugin->stream != 0, *result);
return true;
} else if (name == pluginPropertyIdentifiers[ID_PROPERTY_TEST_OBJECT]) {
- NPObject *testObject = ((PluginObject *)obj)->testObject;
+ NPObject* testObject = plugin->testObject;
browser->retainobject(testObject);
- OBJECT_TO_NPVARIANT(testObject, *variant);
+ OBJECT_TO_NPVARIANT(testObject, *result);
+ return true;
+ } else if (name == pluginPropertyIdentifiers[ID_PROPERTY_RETURN_ERROR_FROM_NEWSTREAM]) {
+ BOOLEAN_TO_NPVARIANT(plugin->returnErrorFromNewStream, *result);
return true;
} else if (name == pluginPropertyIdentifiers[ID_PROPERTY_TEST_OBJECT_COUNT]) {
- INT32_TO_NPVARIANT(getTestObjectCount(), *variant);
+ INT32_TO_NPVARIANT(getTestObjectCount(), *result);
return true;
}
return false;
}
-static bool pluginSetProperty(NPObject *obj, NPIdentifier name, const NPVariant *variant)
+static bool pluginSetProperty(NPObject* obj, NPIdentifier name, const NPVariant* variant)
{
+ PluginObject* plugin = reinterpret_cast<PluginObject*>(obj);
if (name == pluginPropertyIdentifiers[ID_PROPERTY_EVENT_LOGGING]) {
- ((PluginObject *)obj)->eventLogging = NPVARIANT_TO_BOOLEAN(*variant);
+ plugin->eventLogging = NPVARIANT_TO_BOOLEAN(*variant);
return true;
} else if (name == pluginPropertyIdentifiers[ID_PROPERTY_LOG_DESTROY]) {
- ((PluginObject *)obj)->logDestroy = NPVARIANT_TO_BOOLEAN(*variant);
+ plugin->logDestroy = NPVARIANT_TO_BOOLEAN(*variant);
+ return true;
+ } else if (name == pluginPropertyIdentifiers[ID_PROPERTY_RETURN_ERROR_FROM_NEWSTREAM]) {
+ plugin->returnErrorFromNewStream = NPVARIANT_TO_BOOLEAN(*variant);
return true;
}
-
+
return false;
}
@@ -296,23 +296,22 @@ static bool testIdentifierToInt(PluginObject*, const NPVariant* args, uint32_t a
static bool testCallback(PluginObject* obj, const NPVariant* args, uint32_t argCount, NPVariant* result)
{
- // call whatever method name we're given
- if (argCount > 0 && NPVARIANT_IS_STRING(args[0])) {
- NPObject *windowScriptObject;
- browser->getvalue(obj->npp, NPNVWindowNPObject, &windowScriptObject);
+ if (argCount == 0 || !NPVARIANT_IS_STRING(args[0]))
+ return false;
- NPUTF8* callbackString = createCStringFromNPVariant(&args[0]);
- NPIdentifier callbackIdentifier = browser->getstringidentifier(callbackString);
- free(callbackString);
+ NPObject* windowScriptObject;
+ browser->getvalue(obj->npp, NPNVWindowNPObject, &windowScriptObject);
- NPVariant browserResult;
- browser->invoke(obj->npp, windowScriptObject, callbackIdentifier, 0, 0, &browserResult);
- browser->releasevariantvalue(&browserResult);
+ NPUTF8* callbackString = createCStringFromNPVariant(&args[0]);
+ NPIdentifier callbackIdentifier = browser->getstringidentifier(callbackString);
+ free(callbackString);
- VOID_TO_NPVARIANT(*result);
- return true;
- }
- return false;
+ NPVariant browserResult;
+ browser->invoke(obj->npp, windowScriptObject, callbackIdentifier, 0, 0, &browserResult);
+ browser->releasevariantvalue(&browserResult);
+
+ VOID_TO_NPVARIANT(*result);
+ return true;
}
static bool getURL(PluginObject* obj, const NPVariant* args, uint32_t argCount, NPVariant* result)
@@ -320,18 +319,18 @@ static bool getURL(PluginObject* obj, const NPVariant* args, uint32_t argCount,
if (argCount == 2 && NPVARIANT_IS_STRING(args[0]) && NPVARIANT_IS_STRING(args[1])) {
NPUTF8* urlString = createCStringFromNPVariant(&args[0]);
NPUTF8* targetString = createCStringFromNPVariant(&args[1]);
- browser->geturl(obj->npp, urlString, targetString);
+ NPError npErr = browser->geturl(obj->npp, urlString, targetString);
free(urlString);
free(targetString);
- VOID_TO_NPVARIANT(*result);
+ INT32_TO_NPVARIANT(npErr, *result);
return true;
} else if (argCount == 1 && NPVARIANT_IS_STRING(args[0])) {
NPUTF8* urlString = createCStringFromNPVariant(&args[0]);
- browser->geturl(obj->npp, urlString, 0);
+ NPError npErr = browser->geturl(obj->npp, urlString, 0);
free(urlString);
- VOID_TO_NPVARIANT(*result);
+ INT32_TO_NPVARIANT(npErr, *result);
return true;
}
return false;
@@ -346,25 +345,24 @@ static bool removeDefaultMethod(PluginObject*, const NPVariant* args, uint32_t a
static bool getURLNotify(PluginObject* obj, const NPVariant* args, uint32_t argCount, NPVariant* result)
{
- if (argCount == 3
- && NPVARIANT_IS_STRING(args[0])
- && (NPVARIANT_IS_STRING(args[1]) || NPVARIANT_IS_NULL(args[1]))
- && NPVARIANT_IS_STRING(args[2])) {
- NPUTF8* urlString = createCStringFromNPVariant(&args[0]);
- NPUTF8* targetString = (NPVARIANT_IS_STRING(args[1]) ? createCStringFromNPVariant(&args[1]) : NULL);
- NPUTF8* callbackString = createCStringFromNPVariant(&args[2]);
-
- NPIdentifier callbackIdentifier = browser->getstringidentifier(callbackString);
- browser->geturlnotify(obj->npp, urlString, targetString, callbackIdentifier);
+ if (argCount != 3 || !NPVARIANT_IS_STRING(args[0])
+ || (!NPVARIANT_IS_STRING(args[1]) && !NPVARIANT_IS_NULL(args[1]))
+ || !NPVARIANT_IS_STRING(args[2]))
+ return false;
- free(urlString);
- free(targetString);
- free(callbackString);
-
- VOID_TO_NPVARIANT(*result);
- return true;
- }
- return false;
+ NPUTF8* urlString = createCStringFromNPVariant(&args[0]);
+ NPUTF8* targetString = (NPVARIANT_IS_STRING(args[1]) ? createCStringFromNPVariant(&args[1]) : NULL);
+ NPUTF8* callbackString = createCStringFromNPVariant(&args[2]);
+
+ NPIdentifier callbackIdentifier = browser->getstringidentifier(callbackString);
+ browser->geturlnotify(obj->npp, urlString, targetString, callbackIdentifier);
+
+ free(urlString);
+ free(targetString);
+ free(callbackString);
+
+ VOID_TO_NPVARIANT(*result);
+ return true;
}
static bool testInvokeDefault(PluginObject* obj, const NPVariant* args, uint32_t argCount, NPVariant* result)
@@ -391,7 +389,7 @@ static bool destroyStream(PluginObject* obj, const NPVariant* args, uint32_t arg
{
NPError npError = browser->destroystream(obj->npp, obj->stream, NPRES_USER_BREAK);
INT32_TO_NPVARIANT(npError, *result);
- return true;
+ return true;
}
static bool testEnumerate(PluginObject* obj, const NPVariant* args, uint32_t argCount, NPVariant* result)
@@ -545,7 +543,7 @@ static bool testPostURLFile(PluginObject* obj, const NPVariant* args, uint32_t a
return true;
}
-static bool pluginInvoke(NPObject *header, NPIdentifier name, const NPVariant *args, uint32_t argCount, NPVariant *result)
+static bool pluginInvoke(NPObject* header, NPIdentifier name, const NPVariant* args, uint32_t argCount, NPVariant* result)
{
PluginObject* plugin = reinterpret_cast<PluginObject*>(header);
if (name == pluginMethodIdentifiers[ID_TEST_CALLBACK_METHOD])
@@ -704,20 +702,20 @@ static bool pluginInvoke(NPObject *header, NPIdentifier name, const NPVariant *a
return false;
}
-static bool pluginInvokeDefault(NPObject *obj, const NPVariant *args, uint32_t argCount, NPVariant *result)
+static bool pluginInvokeDefault(NPObject* obj, const NPVariant* args, uint32_t argCount, NPVariant* result)
{
INT32_TO_NPVARIANT(1, *result);
return true;
}
-static void pluginInvalidate(NPObject *obj)
+static void pluginInvalidate(NPObject* obj)
{
}
static NPObject *pluginAllocate(NPP npp, NPClass *theClass)
{
- PluginObject *newInstance = (PluginObject*)malloc(sizeof(PluginObject));
-
+ PluginObject* newInstance = (PluginObject*)malloc(sizeof(PluginObject));
+
if (!identifiersInitialized) {
identifiersInitialized = true;
initializeIdentifiers();
@@ -726,42 +724,43 @@ static NPObject *pluginAllocate(NPP npp, NPClass *theClass)
newInstance->npp = npp;
newInstance->testObject = browser->createobject(npp, getTestClass());
newInstance->eventLogging = FALSE;
+ newInstance->onStreamLoad = 0;
+ newInstance->onStreamDestroy = 0;
+ newInstance->onURLNotify = 0;
newInstance->logDestroy = FALSE;
newInstance->logSetWindow = FALSE;
newInstance->returnErrorFromNewStream = FALSE;
newInstance->stream = 0;
-
+
newInstance->firstUrl = NULL;
newInstance->firstHeaders = NULL;
newInstance->lastUrl = NULL;
newInstance->lastHeaders = NULL;
-
- return (NPObject *)newInstance;
+
+ return (NPObject*)newInstance;
}
-static void pluginDeallocate(NPObject *header)
+static void pluginDeallocate(NPObject* header)
{
- PluginObject* obj = (PluginObject*)header;
-
- browser->releaseobject(obj->testObject);
-
- free(obj->firstUrl);
- free(obj->firstHeaders);
- free(obj->lastUrl);
- free(obj->lastHeaders);
+ PluginObject* plugin = reinterpret_cast<PluginObject*>(header);
+ browser->releaseobject(plugin->testObject);
- free(obj);
+ free(plugin->firstUrl);
+ free(plugin->firstHeaders);
+ free(plugin->lastUrl);
+ free(plugin->lastHeaders);
+ free(plugin);
}
void handleCallback(PluginObject* object, const char *url, NPReason reason, void *notifyData)
{
assert(object);
-
+
NPVariant args[2];
-
+
NPObject *windowScriptObject;
browser->getvalue(object->npp, NPNVWindowNPObject, &windowScriptObject);
-
+
NPIdentifier callbackIdentifier = notifyData;
INT32_TO_NPVARIANT(reason, args[0]);
diff --git a/webkit/tools/npapi_layout_test_plugin/PluginObject.h b/webkit/tools/npapi_layout_test_plugin/PluginObject.h
index cacfe41..f344a36 100644
--- a/webkit/tools/npapi_layout_test_plugin/PluginObject.h
+++ b/webkit/tools/npapi_layout_test_plugin/PluginObject.h
@@ -1,34 +1,26 @@
/*
- IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. ("Apple") in
- consideration of your agreement to the following terms, and your use, installation,
- modification or redistribution of this Apple software constitutes acceptance of these
- terms. If you do not agree with these terms, please do not use, install, modify or
- redistribute this Apple software.
-
- In consideration of your agreement to abide by the following terms, and subject to these
- terms, Apple grants you a personal, non-exclusive license, under AppleŐs copyrights in
- this original Apple software (the "Apple Software"), to use, reproduce, modify and
- redistribute the Apple Software, with or without modifications, in source and/or binary
- forms; provided that if you redistribute the Apple Software in its entirety and without
- modifications, you must retain this notice and the following text and disclaimers in all
- such redistributions of the Apple Software. Neither the name, trademarks, service marks
- or logos of Apple Computer, Inc. may be used to endorse or promote products derived from
- the Apple Software without specific prior written permission from Apple. Except as expressly
- stated in this notice, no other rights or licenses, express or implied, are granted by Apple
- herein, including but not limited to any patent rights that may be infringed by your
- derivative works or by other works in which the Apple Software may be incorporated.
-
- The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES,
- EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT,
- MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS
- USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
-
- IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE,
- REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND
- WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR
- OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (C) 2006, 2007 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. ``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
+ * 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 "webkit/glue/plugins/nphostapi.h"
@@ -45,6 +37,8 @@ typedef struct {
NPObject* testObject;
NPStream* stream;
char* onStreamLoad;
+ char* onStreamDestroy;
+ char* onURLNotify;
char* firstUrl;
char* firstHeaders;
char* lastUrl;
diff --git a/webkit/tools/npapi_layout_test_plugin/TestObject.cpp b/webkit/tools/npapi_layout_test_plugin/TestObject.cpp
index 141061d2..e82ba13 100644
--- a/webkit/tools/npapi_layout_test_plugin/TestObject.cpp
+++ b/webkit/tools/npapi_layout_test_plugin/TestObject.cpp
@@ -1,34 +1,26 @@
/*
- IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. ("Apple") in
- consideration of your agreement to the following terms, and your use, installation,
- modification or redistribution of this Apple software constitutes acceptance of these
- terms. If you do not agree with these terms, please do not use, install, modify or
- redistribute this Apple software.
-
- In consideration of your agreement to abide by the following terms, and subject to these
- terms, Apple grants you a personal, non-exclusive license, under Apple’s copyrights in
- this original Apple software (the "Apple Software"), to use, reproduce, modify and
- redistribute the Apple Software, with or without modifications, in source and/or binary
- forms; provided that if you redistribute the Apple Software in its entirety and without
- modifications, you must retain this notice and the following text and disclaimers in all
- such redistributions of the Apple Software. Neither the name, trademarks, service marks
- or logos of Apple Computer, Inc. may be used to endorse or promote products derived from
- the Apple Software without specific prior written permission from Apple. Except as expressly
- stated in this notice, no other rights or licenses, express or implied, are granted by Apple
- herein, including but not limited to any patent rights that may be infringed by your
- derivative works or by other works in which the Apple Software may be incorporated.
-
- The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES,
- EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT,
- MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS
- USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
-
- IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE,
- REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND
- WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR
- OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (C) 2007 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. ``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
+ * 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 "TestObject.h"
diff --git a/webkit/tools/npapi_layout_test_plugin/TestObject.h b/webkit/tools/npapi_layout_test_plugin/TestObject.h
index 8959453..2babaaf 100644
--- a/webkit/tools/npapi_layout_test_plugin/TestObject.h
+++ b/webkit/tools/npapi_layout_test_plugin/TestObject.h
@@ -1,34 +1,26 @@
/*
- IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. ("Apple") in
- consideration of your agreement to the following terms, and your use, installation,
- modification or redistribution of this Apple software constitutes acceptance of these
- terms. If you do not agree with these terms, please do not use, install, modify or
- redistribute this Apple software.
-
- In consideration of your agreement to abide by the following terms, and subject to these
- terms, Apple grants you a personal, non-exclusive license, under Apple’s copyrights in
- this original Apple software (the "Apple Software"), to use, reproduce, modify and
- redistribute the Apple Software, with or without modifications, in source and/or binary
- forms; provided that if you redistribute the Apple Software in its entirety and without
- modifications, you must retain this notice and the following text and disclaimers in all
- such redistributions of the Apple Software. Neither the name, trademarks, service marks
- or logos of Apple Computer, Inc. may be used to endorse or promote products derived from
- the Apple Software without specific prior written permission from Apple. Except as expressly
- stated in this notice, no other rights or licenses, express or implied, are granted by Apple
- herein, including but not limited to any patent rights that may be infringed by your
- derivative works or by other works in which the Apple Software may be incorporated.
-
- The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES,
- EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT,
- MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS
- USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
-
- IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE,
- REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND
- WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR
- OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Copyright (C) 2007 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. ``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
+ * 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 "third_party/npapi/bindings/npapi.h"
diff --git a/webkit/tools/npapi_layout_test_plugin/main.cpp b/webkit/tools/npapi_layout_test_plugin/main.cpp
index 3feaa1d..ccfe2aa 100644
--- a/webkit/tools/npapi_layout_test_plugin/main.cpp
+++ b/webkit/tools/npapi_layout_test_plugin/main.cpp
@@ -94,14 +94,13 @@ NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, ch
if (browser->version >= 14) {
PluginObject* obj = (PluginObject*)browser->createobject(instance, getPluginClass());
- obj->onStreamLoad = NULL;
-
for (int i = 0; i < argc; i++) {
if (strcasecmp(argn[i], "onstreamload") == 0 && !obj->onStreamLoad)
obj->onStreamLoad = strdup(argv[i]);
- 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], "onStreamDestroy") == 0 && !obj->onStreamDestroy)
+ obj->onStreamDestroy = strdup(argv[i]);
+ else if (strcasecmp(argn[i], "onURLNotify") == 0 && !obj->onURLNotify)
+ obj->onURLNotify = strdup(argv[i]);
else if (strcasecmp(argn[i], "logfirstsetwindow") == 0)
obj->logSetWindow = TRUE;
}
@@ -119,7 +118,13 @@ NPError NPP_Destroy(NPP instance, NPSavedData **save)
if (obj) {
if (obj->onStreamLoad)
free(obj->onStreamLoad);
-
+
+ if (obj->onURLNotify)
+ free(obj->onURLNotify);
+
+ if (obj->onStreamDestroy)
+ free(obj->onStreamDestroy);
+
if (obj->logDestroy)
printf("PLUGIN: NPP_Destroy\n");
@@ -149,15 +154,33 @@ NPError NPP_SetWindow(NPP instance, NPWindow *window)
return NPERR_NO_ERROR;
}
+static void executeScript(const PluginObject* obj, const char* script)
+{
+ NPObject *windowScriptObject;
+ browser->getvalue(obj->npp, NPNVWindowNPObject, &windowScriptObject);
+
+ NPString npScript;
+ npScript.UTF8Characters = script;
+ npScript.UTF8Length = strlen(script);
+
+ NPVariant browserResult;
+ browser->evaluate(obj->npp, windowScriptObject, &npScript, &browserResult);
+ browser->releasevariantvalue(&browserResult);
+}
+
NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream *stream, NPBool seekable, uint16 *stype)
{
PluginObject* obj = static_cast<PluginObject*>(instance->pdata);
- obj->stream = stream;
- *stype = NP_ASFILEONLY;
if (obj->returnErrorFromNewStream)
return NPERR_GENERIC_ERROR;
-
+
+ obj->stream = stream;
+ *stype = NP_ASFILEONLY;
+
+ if (obj->onStreamLoad)
+ executeScript(obj, obj->onStreamLoad);
+
if (browser->version >= NPVERS_HAS_RESPONSE_HEADERS)
notifyStream(obj, stream->url, stream->headers);
@@ -180,6 +203,8 @@ NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream *stream, NPBool se
NPError NPP_DestroyStream(NPP instance, NPStream *stream, NPReason reason)
{
PluginObject* obj = static_cast<PluginObject*>(instance->pdata);
+ if (obj->onStreamDestroy)
+ executeScript(obj, obj->onStreamDestroy);
obj->stream = 0;
return NPERR_NO_ERROR;
@@ -373,7 +398,9 @@ int16 NPP_HandleEvent(NPP instance, void *event)
void NPP_URLNotify(NPP instance, const char *url, NPReason reason, void *notifyData)
{
PluginObject* obj = static_cast<PluginObject*>(instance->pdata);
-
+ if (obj->onURLNotify)
+ executeScript(obj, obj->onURLNotify);
+
handleCallback(obj, url, reason, notifyData);
}