diff options
Diffstat (limited to 'WebKitTools/DumpRenderTree')
32 files changed, 808 insertions, 162 deletions
diff --git a/WebKitTools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj b/WebKitTools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj index bf0aebf..b2eb8e9 100644 --- a/WebKitTools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj +++ b/WebKitTools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj @@ -132,6 +132,7 @@ BCD08B710E1059D200A7D0C1 /* AccessibilityControllerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BCD08B700E1059D200A7D0C1 /* AccessibilityControllerMac.mm */; }; BCF6C6500C98E9C000AC063E /* GCController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCF6C64F0C98E9C000AC063E /* GCController.cpp */; }; C06F9ABC1267A7060058E1F6 /* PassDifferentNPPStruct.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C06F9ABB1267A7060058E1F6 /* PassDifferentNPPStruct.cpp */; }; + C0E720751281C828004EF533 /* EvaluateJSAfterRemovingPluginElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C0E720741281C828004EF533 /* EvaluateJSAfterRemovingPluginElement.cpp */; }; C0EC3C9C12787F0500939164 /* NullNPPGetValuePointer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C0EC3C9B12787F0500939164 /* NullNPPGetValuePointer.cpp */; }; E1B7816511AF31B7007E1BC2 /* MockGeolocationProvider.mm in Sources */ = {isa = PBXBuildFile; fileRef = E1B7808711AF1669007E1BC2 /* MockGeolocationProvider.mm */; }; E1B7816711AF31C3007E1BC2 /* MockGeolocationProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = E1B7808511AF1643007E1BC2 /* MockGeolocationProvider.h */; }; @@ -307,6 +308,7 @@ BCD08B700E1059D200A7D0C1 /* AccessibilityControllerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = AccessibilityControllerMac.mm; path = mac/AccessibilityControllerMac.mm; sourceTree = "<group>"; }; BCF6C64F0C98E9C000AC063E /* GCController.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = GCController.cpp; sourceTree = "<group>"; }; C06F9ABB1267A7060058E1F6 /* PassDifferentNPPStruct.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PassDifferentNPPStruct.cpp; sourceTree = "<group>"; }; + C0E720741281C828004EF533 /* EvaluateJSAfterRemovingPluginElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EvaluateJSAfterRemovingPluginElement.cpp; sourceTree = "<group>"; }; C0EC3C9B12787F0500939164 /* NullNPPGetValuePointer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NullNPPGetValuePointer.cpp; sourceTree = "<group>"; }; E1B7808511AF1643007E1BC2 /* MockGeolocationProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MockGeolocationProvider.h; path = mac/MockGeolocationProvider.h; sourceTree = "<group>"; }; E1B7808711AF1669007E1BC2 /* MockGeolocationProvider.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MockGeolocationProvider.mm; path = mac/MockGeolocationProvider.mm; sourceTree = "<group>"; }; @@ -462,6 +464,7 @@ isa = PBXGroup; children = ( 1A215A7511F26072008AD0F5 /* DocumentOpenInDestroyStream.cpp */, + C0E720741281C828004EF533 /* EvaluateJSAfterRemovingPluginElement.cpp */, 1A24BAA8120734EE00FBB059 /* NPRuntimeObjectFromDestroyedPlugin.cpp */, 1AC77DCE120605B6005C19EF /* NPRuntimeRemoveProperty.cpp */, C0EC3C9B12787F0500939164 /* NullNPPGetValuePointer.cpp */, @@ -751,6 +754,7 @@ 1A24BAA9120734EE00FBB059 /* NPRuntimeObjectFromDestroyedPlugin.cpp in Sources */, C06F9ABC1267A7060058E1F6 /* PassDifferentNPPStruct.cpp in Sources */, C0EC3C9C12787F0500939164 /* NullNPPGetValuePointer.cpp in Sources */, + C0E720751281C828004EF533 /* EvaluateJSAfterRemovingPluginElement.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; 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, ®ionRect) == 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(®ionRect, &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=""$(WebKitOutputDir)\Include";"$(WebKitOutputDir)\Include\JavaScriptCore";"$(WebKitOutputDir)\Include\WebCore\ForwardingHeaders";"$(ProjectDir)..\..\TestNetscapePlugin";"$(WebKitLibrariesDir)\include""
+ AdditionalIncludeDirectories=""$(ProjectDir)";"$(ProjectDir)..";"$(WebKitOutputDir)\Include";"$(WebKitOutputDir)\Include\JavaScriptCore";"$(WebKitOutputDir)\Include\WebCore\ForwardingHeaders";"$(WebKitLibrariesDir)\include""
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=""$(WebKitOutputDir)\Include";"$(WebKitOutputDir)\Include\JavaScriptCore";"$(WebKitOutputDir)\Include\WebCore\ForwardingHeaders";"$(ProjectDir)..\..\TestNetscapePlugin";"$(WebKitLibrariesDir)\include""
+ AdditionalIncludeDirectories=""$(ProjectDir)";"$(ProjectDir)..";"$(WebKitOutputDir)\Include";"$(WebKitOutputDir)\Include\JavaScriptCore";"$(WebKitOutputDir)\Include\WebCore\ForwardingHeaders";"$(WebKitLibrariesDir)\include""
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=""$(WebKitOutputDir)\Include";"$(WebKitOutputDir)\Include\JavaScriptCore";"$(WebKitOutputDir)\Include\WebCore\ForwardingHeaders";"$(ProjectDir)..\..\TestNetscapePlugin";"$(WebKitLibrariesDir)\include""
+ AdditionalIncludeDirectories=""$(ProjectDir)";"$(ProjectDir)..";"$(WebKitOutputDir)\Include";"$(WebKitOutputDir)\Include\JavaScriptCore";"$(WebKitOutputDir)\Include\WebCore\ForwardingHeaders";"$(WebKitLibrariesDir)\include""
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=""$(WebKitOutputDir)\Include";"$(WebKitOutputDir)\Include\JavaScriptCore";"$(WebKitOutputDir)\Include\WebCore\ForwardingHeaders";"$(ProjectDir)..\..\TestNetscapePlugin";"$(WebKitLibrariesDir)\include""
+ AdditionalIncludeDirectories=""$(ProjectDir)";"$(ProjectDir)..";"$(WebKitOutputDir)\Include";"$(WebKitOutputDir)\Include\JavaScriptCore";"$(WebKitOutputDir)\Include\WebCore\ForwardingHeaders";"$(WebKitLibrariesDir)\include""
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=""$(WebKitOutputDir)\Include";"$(WebKitOutputDir)\Include\JavaScriptCore";"$(WebKitOutputDir)\Include\WebCore\ForwardingHeaders";"$(ProjectDir)..\..\TestNetscapePlugin";"$(WebKitLibrariesDir)\include""
+ AdditionalIncludeDirectories=""$(ProjectDir)";"$(ProjectDir)..";"$(WebKitOutputDir)\Include";"$(WebKitOutputDir)\Include\JavaScriptCore";"$(WebKitOutputDir)\Include\WebCore\ForwardingHeaders";"$(WebKitLibrariesDir)\include""
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 diff --git a/WebKitTools/DumpRenderTree/chromium/EventSender.cpp b/WebKitTools/DumpRenderTree/chromium/EventSender.cpp index e250dfc..ec16cf7 100644 --- a/WebKitTools/DumpRenderTree/chromium/EventSender.cpp +++ b/WebKitTools/DumpRenderTree/chromium/EventSender.cpp @@ -873,6 +873,7 @@ void EventSender::sendCurrentTouchEvent(const WebInputEvent::Type type) WebTouchEvent touchEvent; touchEvent.type = type; touchEvent.modifiers = touchModifiers; + touchEvent.timeStampSeconds = getCurrentEventTimeSec(); touchEvent.touchPointsLength = touchPoints.size(); for (unsigned i = 0; i < touchPoints.size(); ++i) touchEvent.touchPoints[i] = touchPoints[i]; diff --git a/WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp b/WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp index d713b04..5b0c844 100644 --- a/WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp +++ b/WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp @@ -71,6 +71,8 @@ using namespace std; LayoutTestController::LayoutTestController(TestShell* shell) : m_shell(shell) + , m_closeRemainingWindows(false) + , m_deferMainResourceDataLoad(false) , m_workQueue(this) { @@ -1486,6 +1488,9 @@ void LayoutTestController::setEditingBehavior(const CppArgumentList& arguments, } else if (key == "win") { m_shell->preferences()->editingBehavior = WebSettings::EditingBehaviorWin; m_shell->applyPreferences(); + } else if (key == "unix") { + m_shell->preferences()->editingBehavior = WebSettings::EditingBehaviorUnix; + m_shell->applyPreferences(); } else logErrorToConsole("Passed invalid editing behavior. Should be 'mac' or 'win'."); } diff --git a/WebKitTools/DumpRenderTree/chromium/TestShell.h b/WebKitTools/DumpRenderTree/chromium/TestShell.h index ca06812..06e77cc 100644 --- a/WebKitTools/DumpRenderTree/chromium/TestShell.h +++ b/WebKitTools/DumpRenderTree/chromium/TestShell.h @@ -144,7 +144,7 @@ public: // The JavaScript flags are specified as a vector of strings. Each element of the vector is full flags string // which can contain multiple flags (e.g. "--xxx --yyy"). With multiple load testing it is possible to specify // separate sets of flags to each load. - std::string javaScriptFlagsForLoad(size_t load) { return (load >= 0 && load < m_javaScriptFlags.size()) ? m_javaScriptFlags[load] : ""; } + std::string javaScriptFlagsForLoad(size_t load) { return (load < m_javaScriptFlags.size()) ? m_javaScriptFlags[load] : ""; } void setJavaScriptFlags(Vector<std::string> javaScriptFlags) { m_javaScriptFlags = javaScriptFlags; } // Set whether to dump when the loaded page has finished processing. This is used with multiple load diff --git a/WebKitTools/DumpRenderTree/chromium/WebViewHost.cpp b/WebKitTools/DumpRenderTree/chromium/WebViewHost.cpp index 847e7dc..2f9bdfb 100644 --- a/WebKitTools/DumpRenderTree/chromium/WebViewHost.cpp +++ b/WebKitTools/DumpRenderTree/chromium/WebViewHost.cpp @@ -940,11 +940,16 @@ void WebViewHost::didChangeLocationWithinPage(WebFrame* frame) void WebViewHost::assignIdentifierToRequest(WebFrame*, unsigned identifier, const WebURLRequest& request) { - if (!m_shell->shouldDumpResourceLoadCallbacks()) - return; + ASSERT(!m_resourceIdentifierMap.contains(identifier)); m_resourceIdentifierMap.set(identifier, descriptionSuitableForTestResult(request.url().spec())); } +void WebViewHost::removeIdentifierForRequest(unsigned identifier) +{ + ASSERT(m_resourceIdentifierMap.contains(identifier)); + m_resourceIdentifierMap.remove(identifier); +} + void WebViewHost::willSendRequest(WebFrame*, unsigned identifier, WebURLRequest& request, const WebURLResponse& redirectResponse) { // Need to use GURL for host() and SchemeIs() @@ -1022,7 +1027,7 @@ void WebViewHost::didFinishResourceLoad(WebFrame*, unsigned identifier) printResourceDescription(identifier); fputs(" - didFinishLoading\n", stdout); } - m_resourceIdentifierMap.remove(identifier); + removeIdentifierForRequest(identifier); } void WebViewHost::didFailResourceLoad(WebFrame*, unsigned identifier, const WebURLError& error) @@ -1033,7 +1038,7 @@ void WebViewHost::didFailResourceLoad(WebFrame*, unsigned identifier, const WebU fputs(webkit_support::MakeURLErrorDescription(error).c_str(), stdout); fputs("\n", stdout); } - m_resourceIdentifierMap.remove(identifier); + removeIdentifierForRequest(identifier); } void WebViewHost::didDisplayInsecureContent(WebFrame*) diff --git a/WebKitTools/DumpRenderTree/chromium/WebViewHost.h b/WebKitTools/DumpRenderTree/chromium/WebViewHost.h index 1380ebd..f21e663 100644 --- a/WebKitTools/DumpRenderTree/chromium/WebViewHost.h +++ b/WebKitTools/DumpRenderTree/chromium/WebViewHost.h @@ -185,6 +185,7 @@ class WebViewHost : public WebKit::WebViewClient, public WebKit::WebFrameClient, virtual void didNavigateWithinPage(WebKit::WebFrame*, bool isNewNavigation); virtual void didChangeLocationWithinPage(WebKit::WebFrame*); virtual void assignIdentifierToRequest(WebKit::WebFrame*, unsigned identifier, const WebKit::WebURLRequest&); + virtual void removeIdentifierForRequest(unsigned identifier); virtual void willSendRequest(WebKit::WebFrame*, unsigned identifier, WebKit::WebURLRequest&, const WebKit::WebURLResponse&); virtual void didReceiveResponse(WebKit::WebFrame*, unsigned identifier, const WebKit::WebURLResponse&); virtual void didFinishResourceLoad(WebKit::WebFrame*, unsigned identifier); diff --git a/WebKitTools/DumpRenderTree/gtk/DumpRenderTree.cpp b/WebKitTools/DumpRenderTree/gtk/DumpRenderTree.cpp index 1c851d7..54acc49 100644 --- a/WebKitTools/DumpRenderTree/gtk/DumpRenderTree.cpp +++ b/WebKitTools/DumpRenderTree/gtk/DumpRenderTree.cpp @@ -137,10 +137,9 @@ static void initializeGtkFontSettings(const char* testURL) GtkSettings* settings = gtk_settings_get_default(); if (!settings) return; - g_object_set(settings, "gtk-xft-antialias", 1, NULL); - g_object_set(settings, "gtk-xft-hinting", 1, NULL); - g_object_set(settings, "gtk-xft-hintstyle", "hintfull", NULL); - g_object_set(settings, "gtk-font-name", "Liberation Sans 16", NULL); + g_object_set(settings, "gtk-xft-antialias", 1, + "gtk-xft-hinting", 0, + "gtk-font-name", "Liberation Sans 16", NULL); // One test needs subpixel anti-aliasing turned on, but generally we // want all text in other tests to use to grayscale anti-aliasing. diff --git a/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp b/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp index 688b3f8..ab70a3e 100644 --- a/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp +++ b/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp @@ -813,8 +813,10 @@ void LayoutTestController::setEditingBehavior(const char* editingBehavior) if (!strcmp(editingBehavior, "win")) g_object_set(G_OBJECT(settings), "editing-behavior", WEBKIT_EDITING_BEHAVIOR_WINDOWS, NULL); - if (!strcmp(editingBehavior, "mac")) + else if (!strcmp(editingBehavior, "mac")) g_object_set(G_OBJECT(settings), "editing-behavior", WEBKIT_EDITING_BEHAVIOR_MAC, NULL); + else if (!strcmp(editingBehavior, "unix")) + g_object_set(G_OBJECT(settings), "editing-behavior", WEBKIT_EDITING_BEHAVIOR_UNIX, NULL); } void LayoutTestController::abortModal() diff --git a/WebKitTools/DumpRenderTree/gtk/fonts/fonts.conf b/WebKitTools/DumpRenderTree/gtk/fonts/fonts.conf index 6eb057e..2d9af17 100644 --- a/WebKitTools/DumpRenderTree/gtk/fonts/fonts.conf +++ b/WebKitTools/DumpRenderTree/gtk/fonts/fonts.conf @@ -2,6 +2,19 @@ <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> + <!-- Due to patent (http://freetype.sourceforge.net/patents.html) + issues hinting gives different results depending on the + freetype version of the linux distribution, avoiding hinting + gives more consistent results. When all the distributions + release freetype the 2.4, which enables by default the + hinting method that was patented, we could undo this change + and try the hinting again. --> + <match target="font"> + <edit name="hinting" mode="assign"> + <bool>false</bool> + </edit> + </match> + <!-- The sans-serif font should be Liberation Serif --> <match target="pattern"> <test qual="any" name="family"> @@ -158,6 +171,9 @@ <edit name="family" mode="assign"> <string>Liberation Serif</string> </edit> + <edit name="hinting" mode="assign"> + <bool>true</bool> + </edit> <edit name="hintstyle" mode="assign"> <const>hintslight</const> </edit> @@ -175,7 +191,7 @@ <edit name="hintstyle" mode="assign"> <const>hintfull</const> </edit> - <edit name="hinting" mode="assign"> + <edit name="hinting" mode="assign"> <bool>false</bool> </edit> </match> @@ -187,6 +203,9 @@ <edit name="family" mode="assign"> <string>Liberation Serif</string> </edit> + <edit name="hinting" mode="assign"> + <bool>true</bool> + </edit> <edit name="autohint" mode="assign"> <bool>true</bool> </edit> @@ -202,6 +221,9 @@ <edit name="family" mode="assign"> <string>Liberation Serif</string> </edit> + <edit name="hinting" mode="assign"> + <bool>true</bool> + </edit> <edit name="autohint" mode="assign"> <bool>false</bool> </edit> @@ -217,6 +239,9 @@ <edit name="family" mode="assign"> <string>Liberation Serif</string> </edit> + <edit name="hinting" mode="assign"> + <bool>true</bool> + </edit> <edit name="autohint" mode="assign"> <bool>true</bool> </edit> diff --git a/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm b/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm index 150b6f9..431d4e9 100644 --- a/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm +++ b/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm @@ -935,8 +935,10 @@ void LayoutTestController::setEditingBehavior(const char* editingBehavior) NSString* editingBehaviorNS = [[NSString alloc] initWithUTF8String:editingBehavior]; if ([editingBehaviorNS isEqualToString:@"mac"]) [[WebPreferences standardPreferences] setEditingBehavior:WebKitEditingMacBehavior]; - if ([editingBehaviorNS isEqualToString:@"win"]) + else if ([editingBehaviorNS isEqualToString:@"win"]) [[WebPreferences standardPreferences] setEditingBehavior:WebKitEditingWinBehavior]; + else if ([editingBehaviorNS isEqualToString:@"unix"]) + [[WebPreferences standardPreferences] setEditingBehavior:WebKitEditingUnixBehavior]; [editingBehaviorNS release]; } diff --git a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp index f99ec4f..3e50e06 100644 --- a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp +++ b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp @@ -810,5 +810,10 @@ bool LayoutTestController::hasSpellingMarker(int, int) return false; } +QVariantList LayoutTestController::nodesFromRect(const QWebElement& document, int x, int y, unsigned top, unsigned right, unsigned bottom, unsigned left, bool ignoreClipping) +{ + return DumpRenderTreeSupportQt::nodesFromRect(document, x, y, top, right, bottom, left, ignoreClipping); +} + const unsigned LayoutTestController::maxViewWidth = 800; const unsigned LayoutTestController::maxViewHeight = 600; diff --git a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h index 11d72e4..dfb12fe 100644 --- a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h +++ b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h @@ -222,6 +222,8 @@ public slots: void abortModal() {} bool hasSpellingMarker(int from, int length); + QVariantList nodesFromRect(const QWebElement& document, int x, int y, unsigned top, unsigned right, unsigned bottom, unsigned left, bool ignoreClipping); + /* Policy values: 'on', 'auto' or 'off'. Orientation values: 'vertical' or 'horizontal'. diff --git a/WebKitTools/DumpRenderTree/qt/TestNetscapePlugin/TestNetscapePlugin.pro b/WebKitTools/DumpRenderTree/qt/TestNetscapePlugin/TestNetscapePlugin.pro index b958025..1d460d7 100644 --- a/WebKitTools/DumpRenderTree/qt/TestNetscapePlugin/TestNetscapePlugin.pro +++ b/WebKitTools/DumpRenderTree/qt/TestNetscapePlugin/TestNetscapePlugin.pro @@ -29,6 +29,7 @@ SOURCES = PluginObject.cpp \ PluginTest.cpp \ TestObject.cpp \ Tests/DocumentOpenInDestroyStream.cpp \ + Tests/EvaluateJSAfterRemovingPluginElement.cpp \ Tests/NPRuntimeObjectFromDestroyedPlugin.cpp \ Tests/NPRuntimeRemoveProperty.cpp \ Tests/NullNPPGetValuePointer.cpp \ diff --git a/WebKitTools/DumpRenderTree/unix/TestNetscapePlugin/TestNetscapePlugin.cpp b/WebKitTools/DumpRenderTree/unix/TestNetscapePlugin/TestNetscapePlugin.cpp index 14bb8ef..2298ef1 100644 --- a/WebKitTools/DumpRenderTree/unix/TestNetscapePlugin/TestNetscapePlugin.cpp +++ b/WebKitTools/DumpRenderTree/unix/TestNetscapePlugin/TestNetscapePlugin.cpp @@ -372,7 +372,9 @@ webkit_test_plugin_set_value(NPP instance, NPNVariable variable, void* value) char * NP_GetMIMEDescription(void) { - return const_cast<char*>("application/x-webkit-test-netscape:testnetscape:test netscape content"); + // We sentence-case the mime-type here to ensure that ports are not + // case-sensitive when loading plugins. See https://webkit.org/b/36815 + return const_cast<char*>("application/x-Webkit-Test-Netscape:testnetscape:test netscape content"); } NPError diff --git a/WebKitTools/DumpRenderTree/win/DumpRenderTree.cpp b/WebKitTools/DumpRenderTree/win/DumpRenderTree.cpp index 5138562..7c3d9b3 100644 --- a/WebKitTools/DumpRenderTree/win/DumpRenderTree.cpp +++ b/WebKitTools/DumpRenderTree/win/DumpRenderTree.cpp @@ -98,7 +98,6 @@ PolicyDelegate* policyDelegate; COMPtr<FrameLoadDelegate> sharedFrameLoadDelegate; COMPtr<UIDelegate> sharedUIDelegate; COMPtr<EditingDelegate> sharedEditingDelegate; -COMPtr<ResourceLoadDelegate> sharedResourceLoadDelegate; COMPtr<HistoryDelegate> sharedHistoryDelegate; IWebFrame* frame; @@ -1201,7 +1200,10 @@ IWebView* createWebViewAndOffscreenWindow(HWND* webViewWindow) if (FAILED(viewEditing->setEditingDelegate(sharedEditingDelegate.get()))) return 0; - if (FAILED(webView->setResourceLoadDelegate(sharedResourceLoadDelegate.get()))) + ResourceLoadDelegate* resourceLoadDelegate = new ResourceLoadDelegate(); + HRESULT result = webView->setResourceLoadDelegate(resourceLoadDelegate); + resourceLoadDelegate->Release(); // The delegate is owned by the WebView, so release our reference to it. + if (FAILED(result)) return 0; openWindows().append(hostWindow); @@ -1285,7 +1287,6 @@ int main(int argc, char* argv[]) sharedFrameLoadDelegate.adoptRef(new FrameLoadDelegate); sharedUIDelegate.adoptRef(new UIDelegate); sharedEditingDelegate.adoptRef(new EditingDelegate); - sharedResourceLoadDelegate.adoptRef(new ResourceLoadDelegate); sharedHistoryDelegate.adoptRef(new HistoryDelegate); // FIXME - need to make DRT pass with Windows native controls <http://bugs.webkit.org/show_bug.cgi?id=25592> diff --git a/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp b/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp index d7c41e0..386f118 100644 --- a/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp +++ b/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp @@ -1383,8 +1383,10 @@ void LayoutTestController::setEditingBehavior(const char* editingBehavior) string behaviorString(editingBehavior); if (behaviorString == "mac") preferences->setEditingBehavior(WebKitEditingMacBehavior); - if (behaviorString == "win") + else if (behaviorString == "win") preferences->setEditingBehavior(WebKitEditingWinBehavior); + else if (behaviorString == "unix") + preferences->setEditingBehavior(WebKitEditingUnixBehavior); } void LayoutTestController::abortModal() diff --git a/WebKitTools/DumpRenderTree/win/PixelDumpSupportWin.cpp b/WebKitTools/DumpRenderTree/win/PixelDumpSupportWin.cpp index b0c76d6..752cc39 100644 --- a/WebKitTools/DumpRenderTree/win/PixelDumpSupportWin.cpp +++ b/WebKitTools/DumpRenderTree/win/PixelDumpSupportWin.cpp @@ -63,7 +63,7 @@ PassRefPtr<BitmapContext> createBitmapContextFromWebView(bool onscreen, bool inc HDC memoryDC = CreateCompatibleDC(0); SelectObject(memoryDC, bitmap); - SendMessage(webViewWindow, WM_PRINTCLIENT, reinterpret_cast<WPARAM>(memoryDC), PRF_CLIENT | PRF_CHILDREN | PRF_OWNED); + SendMessage(webViewWindow, WM_PRINT, reinterpret_cast<WPARAM>(memoryDC), PRF_CLIENT | PRF_CHILDREN | PRF_OWNED); DeleteDC(memoryDC); BITMAP info = {0}; @@ -73,7 +73,7 @@ PassRefPtr<BitmapContext> createBitmapContextFromWebView(bool onscreen, bool inc #if PLATFORM(CG) RetainPtr<CGColorSpaceRef> colorSpace(AdoptCF, CGColorSpaceCreateDeviceRGB()); CGContextRef context = CGBitmapContextCreate(info.bmBits, info.bmWidth, info.bmHeight, 8, - info.bmWidthBytes, colorSpace.get(), kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst); + info.bmWidthBytes, colorSpace.get(), kCGBitmapByteOrder32Host | kCGImageAlphaPremultipliedFirst); #elif PLATFORM(CAIRO) cairo_surface_t* image = cairo_image_surface_create_for_data((unsigned char*)info.bmBits, CAIRO_FORMAT_ARGB32, info.bmWidth, info.bmHeight, info.bmWidthBytes); diff --git a/WebKitTools/DumpRenderTree/win/ResourceLoadDelegate.cpp b/WebKitTools/DumpRenderTree/win/ResourceLoadDelegate.cpp index 825366a..09b07d6 100644 --- a/WebKitTools/DumpRenderTree/win/ResourceLoadDelegate.cpp +++ b/WebKitTools/DumpRenderTree/win/ResourceLoadDelegate.cpp @@ -35,7 +35,6 @@ #include <comutil.h> #include <sstream> #include <tchar.h> -#include <wtf/HashMap.h> #include <wtf/Vector.h> using namespace std; @@ -60,26 +59,17 @@ static inline BSTR BSTRFromString(const string& str) return result; } -typedef HashMap<unsigned long, wstring> IdentifierMap; - -IdentifierMap& urlMap() -{ - static IdentifierMap urlMap; - - return urlMap; -} - -static wstring descriptionSuitableForTestResult(unsigned long identifier) +wstring ResourceLoadDelegate::descriptionSuitableForTestResult(unsigned long identifier) const { - IdentifierMap::iterator it = urlMap().find(identifier); + IdentifierMap::const_iterator it = m_urlMap.find(identifier); - if (it == urlMap().end()) + if (it == m_urlMap.end()) return L"<unknown>"; return urlSuitableForTestResult(it->second); } -static wstring descriptionSuitableForTestResult(IWebURLRequest* request) +wstring ResourceLoadDelegate::descriptionSuitableForTestResult(IWebURLRequest* request) { if (!request) return L"(null)"; @@ -108,7 +98,7 @@ static wstring descriptionSuitableForTestResult(IWebURLRequest* request) return L"<NSURLRequest URL " + url + L", main document URL " + mainDocumentURL + L", http method " + httpMethod + L">"; } -static wstring descriptionSuitableForTestResult(IWebURLResponse* response) +wstring ResourceLoadDelegate::descriptionSuitableForTestResult(IWebURLResponse* response) { if (!response) return L"(null)"; @@ -128,7 +118,7 @@ static wstring descriptionSuitableForTestResult(IWebURLResponse* response) return L"<NSURLResponse " + url + L", http status code " + wstringFromInt(statusCode) + L">"; } -static wstring descriptionSuitableForTestResult(IWebError* error, unsigned long identifier) +wstring ResourceLoadDelegate::descriptionSuitableForTestResult(IWebError* error, unsigned long identifier) const { wstring result = L"<NSError "; @@ -197,6 +187,8 @@ HRESULT STDMETHODCALLTYPE ResourceLoadDelegate::QueryInterface(REFIID riid, void *ppvObject = static_cast<IWebResourceLoadDelegate*>(this); else if (IsEqualGUID(riid, IID_IWebResourceLoadDelegate)) *ppvObject = static_cast<IWebResourceLoadDelegate*>(this); + else if (IsEqualGUID(riid, IID_IWebResourceLoadDelegatePrivate2)) + *ppvObject = static_cast<IWebResourceLoadDelegatePrivate2*>(this); else return E_NOINTERFACE; @@ -229,12 +221,22 @@ HRESULT STDMETHODCALLTYPE ResourceLoadDelegate::identifierForInitialRequest( if (FAILED(request->URL(&urlStr))) return E_FAIL; + ASSERT(!urlMap().contains(identifier)); urlMap().set(identifier, wstringFromBSTR(urlStr)); } return S_OK; } +HRESULT STDMETHODCALLTYPE ResourceLoadDelegate::removeIdentifierForRequest( + /* [in] */ IWebView* webView, + /* [in] */ unsigned long identifier) +{ + urlMap().remove(identifier); + + return S_OK; +} + HRESULT STDMETHODCALLTYPE ResourceLoadDelegate::willSendRequest( /* [in] */ IWebView* webView, /* [in] */ unsigned long identifier, @@ -351,11 +353,12 @@ HRESULT STDMETHODCALLTYPE ResourceLoadDelegate::didFinishLoadingFromDataSource( { if (!done && gLayoutTestController->dumpResourceLoadCallbacks()) { printf("%S - didFinishLoading\n", - descriptionSuitableForTestResult(identifier).c_str()), - urlMap().remove(identifier); + descriptionSuitableForTestResult(identifier).c_str()); } - return S_OK; + removeIdentifierForRequest(webView, identifier); + + return S_OK; } HRESULT STDMETHODCALLTYPE ResourceLoadDelegate::didFailLoadingWithError( @@ -368,8 +371,9 @@ HRESULT STDMETHODCALLTYPE ResourceLoadDelegate::didFailLoadingWithError( printf("%S - didFailLoadingWithError: %S\n", descriptionSuitableForTestResult(identifier).c_str(), descriptionSuitableForTestResult(error, identifier).c_str()); - urlMap().remove(identifier); } + removeIdentifierForRequest(webView, identifier); + return S_OK; } diff --git a/WebKitTools/DumpRenderTree/win/ResourceLoadDelegate.h b/WebKitTools/DumpRenderTree/win/ResourceLoadDelegate.h index 924727b..3f20f47 100644 --- a/WebKitTools/DumpRenderTree/win/ResourceLoadDelegate.h +++ b/WebKitTools/DumpRenderTree/win/ResourceLoadDelegate.h @@ -30,8 +30,10 @@ #define ResourceLoadDelegate_h #include <WebKit/WebKit.h> +#include <string> +#include <wtf/HashMap.h> -class ResourceLoadDelegate : public IWebResourceLoadDelegate { +class ResourceLoadDelegate : public IWebResourceLoadDelegate, public IWebResourceLoadDelegatePrivate2 { public: ResourceLoadDelegate(); virtual ~ResourceLoadDelegate(); @@ -95,8 +97,22 @@ public: /* [in] */ IWebView *webView, /* [in] */ IWebError *error, /* [in] */ IWebDataSource *dataSource) { return E_NOTIMPL; } + + // IWebResourceLoadDelegatePrivate2 + virtual HRESULT STDMETHODCALLTYPE removeIdentifierForRequest( + /* [in] */ IWebView *webView, + /* [in] */ unsigned long identifier); -protected: +private: + static std::wstring descriptionSuitableForTestResult(IWebURLRequest*); + static std::wstring descriptionSuitableForTestResult(IWebURLResponse*); + std::wstring descriptionSuitableForTestResult(unsigned long) const; + std::wstring descriptionSuitableForTestResult(IWebError*, unsigned long) const; + + typedef HashMap<unsigned long, std::wstring> IdentifierMap; + IdentifierMap& urlMap() { return m_urlMap; } + IdentifierMap m_urlMap; + ULONG m_refCount; }; |