[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

andersca at apple.com andersca at apple.com
Wed Dec 22 11:38:53 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 21fcac31efe3971fa5bbbeb4ac44aace5c7ce393
Author: andersca at apple.com <andersca at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Aug 2 18:28:07 2010 +0000

    Cache JSNPObjects and fix bugs in the object map
    https://bugs.webkit.org/show_bug.cgi?id=43368
    
    Reviewed by Sam Weinig.
    
    WebKit2:
    
    * WebProcess/Plugins/JSNPObject.cpp:
    (WebKit::JSNPObject::JSNPObject):
    Assert that we're not trying to wrap an NPJSObject.
    
    (WebKit::JSNPObject::~JSNPObject):
    Tell the object map that we're gone.
    
    (WebKit::JSNPObject::invalidate):
    Release the NPObject and null out the pointer.
    
    * WebProcess/Plugins/NPJSObject.cpp:
    (WebKit::NPJSObject::create):
    Assert that we're not trying to wrap a JSNPObject.
    
    * WebProcess/Plugins/NPRuntimeObjectMap.cpp:
    (WebKit::NPRuntimeObjectMap::getOrCreateNPObject):
    If we're passed a JSNPObject, just extract its NPObject.
    
    (WebKit::NPRuntimeObjectMap::getOrCreateJSObject):
    If we're passed an NPJSObject, just extract its JSObject. Otherwise, check if we already have
    a JSObject for this NPObject and return it.
    
    (WebKit::NPRuntimeObjectMap::jsNPObjectDestroyed):
    Remove the object from the map.
    
    (WebKit::NPRuntimeObjectMap::convertNPVariantToJSValue):
    getOrCreateJSObject now checks for wrapped objects.
    
    (WebKit::NPRuntimeObjectMap::convertJSValueToNPVariant):
    getOrCreateNPObject now checks for wrapped objects.
    
    (WebKit::NPRuntimeObjectMap::invalidate):
    Invalidate JSNPObjects as well.
    
    WebKitTools:
    
    Test that we correctly throw exceptions when trying to do things to a JSObject that used to
    wrap an NPObject that came from a plug-in that is now destroyed.
    
    * DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
    * DumpRenderTree/TestNetscapePlugIn/PluginTest.h:
    (PluginTest::Object::getProperty):
    (PluginTest::Object::NP_GetProperty):
    (PluginTest::Object::npClass):
    * DumpRenderTree/TestNetscapePlugIn/Tests/NPRuntimeObjectFromDestroyedPlugin.cpp: Added.
    (NPRuntimeObjectFromDestroyedPlugin::NPRuntimeObjectFromDestroyedPlugin):
    (NPRuntimeObjectFromDestroyedPlugin::ScriptableObject::hasProperty):
    (NPRuntimeObjectFromDestroyedPlugin::ScriptableObject::getProperty):
    (NPRuntimeObjectFromDestroyedPlugin::NPP_GetValue):
    * DumpRenderTree/TestNetscapePlugIn/win/TestNetscapePlugin.vcproj:
    * DumpRenderTree/qt/TestNetscapePlugin/TestNetscapePlugin.pro:
    * GNUmakefile.am:
    
    LayoutTests:
    
    * plugins/npruntime/object-from-destroyed-plugin-expected.txt: Added.
    * plugins/npruntime/object-from-destroyed-plugin.html: Added.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64479 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index dc8988e..bf2c6b0 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,13 @@
+2010-08-02  Anders Carlsson  <andersca at apple.com>
+
+        Reviewed by Sam Weinig.
+
+        Cache JSNPObjects and fix bugs in the object map
+        https://bugs.webkit.org/show_bug.cgi?id=43368
+
+        * plugins/npruntime/object-from-destroyed-plugin-expected.txt: Added.
+        * plugins/npruntime/object-from-destroyed-plugin.html: Added.
+
 2010-08-02  Chris Fleizach  <cfleizach at apple.com>
 
         AX: Support methods for web apps to interact with the native accessibility APIs
diff --git a/LayoutTests/plugins/npruntime/object-from-destroyed-plugin-expected.txt b/LayoutTests/plugins/npruntime/object-from-destroyed-plugin-expected.txt
new file mode 100644
index 0000000..f227f2f
--- /dev/null
+++ b/LayoutTests/plugins/npruntime/object-from-destroyed-plugin-expected.txt
@@ -0,0 +1,10 @@
+Test various operation on an NPObject whose plug-in has been destroyed
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS testObject.gettingProperty threw exception ReferenceError: Trying to access object from destroyed plug-in..
+PASS testObject.settingProperty = 10 threw exception ReferenceError: Trying to access object from destroyed plug-in..
+PASS testObject() threw exception TypeError: Result of expression 'testObject' [] is not a function..
+PASS new testObject(); threw exception TypeError: Result of expression 'testObject' [] is not a constructor..
+
diff --git a/LayoutTests/plugins/npruntime/object-from-destroyed-plugin.html b/LayoutTests/plugins/npruntime/object-from-destroyed-plugin.html
new file mode 100644
index 0000000..67f0d67
--- /dev/null
+++ b/LayoutTests/plugins/npruntime/object-from-destroyed-plugin.html
@@ -0,0 +1,30 @@
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<script>
+function runTest() {
+    plugin = document.getElementById('plugin');
+    
+    // Get our test object.
+    testObject = plugin.testObject;
+    
+    // Now destroy the plug-in. 
+    plugin.parentNode.removeChild(plugin);
+
+    // testObject is now a dangling object and every operation on it should throw.
+    shouldThrow('testObject.gettingProperty');
+    shouldThrow('testObject.settingProperty = 10');
+    shouldThrow('testObject()');
+    shouldThrow('new testObject();')
+}
+</script>
+<body onLoad="runTest()">
+<embed id="plugin" type="application/x-webkit-test-netscape" test="npruntime-object-from-destroyed-plugin"></embed>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test various operation on an NPObject whose plug-in has been destroyed");
+
+successfullyParsed = true;
+</script>
diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index 58d01d0..b328c24 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,44 @@
+2010-08-02  Anders Carlsson  <andersca at apple.com>
+
+        Reviewed by Sam Weinig.
+
+        Cache JSNPObjects and fix bugs in the object map
+        https://bugs.webkit.org/show_bug.cgi?id=43368
+
+        * WebProcess/Plugins/JSNPObject.cpp:
+        (WebKit::JSNPObject::JSNPObject):
+        Assert that we're not trying to wrap an NPJSObject.
+
+        (WebKit::JSNPObject::~JSNPObject):
+        Tell the object map that we're gone.
+
+        (WebKit::JSNPObject::invalidate):
+        Release the NPObject and null out the pointer.
+
+        * WebProcess/Plugins/NPJSObject.cpp:
+        (WebKit::NPJSObject::create):
+        Assert that we're not trying to wrap a JSNPObject.
+
+        * WebProcess/Plugins/NPRuntimeObjectMap.cpp:
+        (WebKit::NPRuntimeObjectMap::getOrCreateNPObject):
+        If we're passed a JSNPObject, just extract its NPObject.
+
+        (WebKit::NPRuntimeObjectMap::getOrCreateJSObject):
+        If we're passed an NPJSObject, just extract its JSObject. Otherwise, check if we already have
+        a JSObject for this NPObject and return it.
+
+        (WebKit::NPRuntimeObjectMap::jsNPObjectDestroyed):
+        Remove the object from the map.
+
+        (WebKit::NPRuntimeObjectMap::convertNPVariantToJSValue):
+        getOrCreateJSObject now checks for wrapped objects.
+
+        (WebKit::NPRuntimeObjectMap::convertJSValueToNPVariant):
+        getOrCreateNPObject now checks for wrapped objects.
+
+        (WebKit::NPRuntimeObjectMap::invalidate):
+        Invalidate JSNPObjects as well.
+
 2010-08-02  Jeremy Orlow  <jorlow at chromium.org>
 
         Speculative revert of 64425 due to Chromium instability
diff --git a/WebKit2/WebProcess/Plugins/JSNPObject.cpp b/WebKit2/WebProcess/Plugins/JSNPObject.cpp
index 56df30f..e13e920 100644
--- a/WebKit2/WebProcess/Plugins/JSNPObject.cpp
+++ b/WebKit2/WebProcess/Plugins/JSNPObject.cpp
@@ -26,6 +26,7 @@
 #include "JSNPObject.h"
 
 #include "JSNPMethod.h"
+#include "NPJSObject.h"
 #include "NPRuntimeObjectMap.h"
 #include "NPRuntimeUtilities.h"
 #include <JavaScriptCore/Error.h>
@@ -35,8 +36,8 @@
 #include <WebCore/IdentifierRep.h>
 #include <WebCore/PlatformString.h>
 
-using namespace WebCore;
 using namespace JSC;
+using namespace WebCore;
 
 namespace WebKit {
 
@@ -52,12 +53,27 @@ JSNPObject::JSNPObject(JSGlobalObject* globalObject, NPRuntimeObjectMap* objectM
     , m_objectMap(objectMap)
     , m_npObject(npObject)
 {
+    // We should never have an NPJSObject inside a JSNPObject.
+    ASSERT(!NPJSObject::isNPJSObject(m_npObject));
+
     retainNPObject(m_npObject);
 }
 
 JSNPObject::~JSNPObject()
 {
-    // FIXME: Implement.
+    if (!m_npObject)
+        return;
+
+    m_objectMap->jsNPObjectDestroyed(this);
+    releaseNPObject(m_npObject);
+}
+
+void JSNPObject::invalidate()
+{
+    ASSERT(m_npObject);
+
+    releaseNPObject(m_npObject);
+    m_npObject = 0;
 }
 
 JSValue JSNPObject::callMethod(ExecState* exec, NPIdentifier methodName)
diff --git a/WebKit2/WebProcess/Plugins/JSNPObject.h b/WebKit2/WebProcess/Plugins/JSNPObject.h
index 2916823..af1369a 100644
--- a/WebKit2/WebProcess/Plugins/JSNPObject.h
+++ b/WebKit2/WebProcess/Plugins/JSNPObject.h
@@ -42,6 +42,8 @@ public:
     JSNPObject(JSC::JSGlobalObject*, NPRuntimeObjectMap* objectMap, NPObject* npObject);
     ~JSNPObject();
 
+    void invalidate();
+
     JSC::JSValue callMethod(JSC::ExecState*, NPIdentifier methodName);
     JSC::JSValue callObject(JSC::ExecState*);
     JSC::JSValue callConstructor(JSC::ExecState*);
diff --git a/WebKit2/WebProcess/Plugins/NPJSObject.cpp b/WebKit2/WebProcess/Plugins/NPJSObject.cpp
index 922ca63..2fbb225 100644
--- a/WebKit2/WebProcess/Plugins/NPJSObject.cpp
+++ b/WebKit2/WebProcess/Plugins/NPJSObject.cpp
@@ -25,6 +25,7 @@
 
 #include "NPJSObject.h"
 
+#include "JSNPObject.h"
 #include "NPRuntimeObjectMap.h"
 #include "NPRuntimeUtilities.h"
 #include "NotImplemented.h"
@@ -42,6 +43,9 @@ namespace WebKit {
 
 NPJSObject* NPJSObject::create(NPRuntimeObjectMap* objectMap, JSObject* jsObject)
 {
+    // We should never have a JSNPObject inside an NPJSObject.
+    ASSERT(!jsObject->inherits(&JSNPObject::s_info));
+
     NPJSObject* npJSObject = toNPJSObject(createNPObject(0, npClass()));
     npJSObject->initialize(objectMap, jsObject);
 
diff --git a/WebKit2/WebProcess/Plugins/NPRuntimeObjectMap.cpp b/WebKit2/WebProcess/Plugins/NPRuntimeObjectMap.cpp
index e1ac9ef..bc61b44 100644
--- a/WebKit2/WebProcess/Plugins/NPRuntimeObjectMap.cpp
+++ b/WebKit2/WebProcess/Plugins/NPRuntimeObjectMap.cpp
@@ -48,14 +48,23 @@ NPRuntimeObjectMap::NPRuntimeObjectMap(PluginView* pluginView)
 
 NPObject* NPRuntimeObjectMap::getOrCreateNPObject(JSObject* jsObject)
 {
+    // If this is a JSNPObject, we can just get its underlying NPObject.
+    if (jsObject->classInfo() == &JSNPObject::s_info) {
+        JSNPObject* jsNPObject = static_cast<JSNPObject*>(jsObject);
+        NPObject* npObject = jsNPObject->npObject();
+        
+        retainNPObject(npObject);
+        return npObject;
+    }
+    
     // First, check if we already know about this object.
-    if (NPJSObject* npJSObject = m_objects.get(jsObject)) {
+    if (NPJSObject* npJSObject = m_npJSObjects.get(jsObject)) {
         retainNPObject(npJSObject);
         return npJSObject;
     }
 
     NPJSObject* npJSObject = NPJSObject::create(this, jsObject);
-    m_objects.set(jsObject, npJSObject);
+    m_npJSObjects.set(jsObject, npJSObject);
 
     return npJSObject;
 }
@@ -63,19 +72,30 @@ NPObject* NPRuntimeObjectMap::getOrCreateNPObject(JSObject* jsObject)
 void NPRuntimeObjectMap::npJSObjectDestroyed(NPJSObject* npJSObject)
 {
     // Remove the object from the map.
-    ASSERT(m_objects.contains(npJSObject->jsObject()));
-    m_objects.remove(npJSObject->jsObject());
+    ASSERT(m_npJSObjects.contains(npJSObject->jsObject()));
+    m_npJSObjects.remove(npJSObject->jsObject());
 }
 
 JSObject* NPRuntimeObjectMap::getOrCreateJSObject(JSGlobalObject* globalObject, NPObject* npObject)
 {
-    // FIXME: Check if we already have a wrapper for this NPObject!
-    return new (globalObject->globalData()) JSNPObject(globalObject, this, npObject);
+    // If this is an NPJSObject, we can just get the JSObject that it's wrapping.
+    if (NPJSObject::isNPJSObject(npObject))
+        return NPJSObject::toNPJSObject(npObject)->jsObject();
+    
+    if (JSNPObject* jsNPObject = m_jsNPObjects.get(npObject))
+        return jsNPObject;
+
+    JSNPObject* jsNPObject = new (globalObject->globalData()) JSNPObject(globalObject, this, npObject);
+    m_jsNPObjects.set(npObject, jsNPObject);
+
+    return jsNPObject;
 }
 
 void NPRuntimeObjectMap::jsNPObjectDestroyed(JSNPObject* jsNPObject)
 {
-    // FIXME: Implement.
+    // Remove the object from the map.
+    ASSERT(m_jsNPObjects.contains(jsNPObject->npObject()));
+    m_jsNPObjects.remove(jsNPObject->npObject());
 }
 
 JSValue NPRuntimeObjectMap::convertNPVariantToJSValue(JSC::ExecState* exec, JSC::JSGlobalObject* globalObject, const NPVariant& variant)
@@ -99,17 +119,8 @@ JSValue NPRuntimeObjectMap::convertNPVariantToJSValue(JSC::ExecState* exec, JSC:
     case NPVariantType_String:
         return jsString(exec, String::fromUTF8WithLatin1Fallback(variant.value.stringValue.UTF8Characters, 
                                                                  variant.value.stringValue.UTF8Length));
-    case NPVariantType_Object: {
-        NPObject* npObject = variant.value.objectValue;
-
-        // Just get the object from the NPJSObject.
-        if (NPJSObject::isNPJSObject(npObject))
-            return NPJSObject::toNPJSObject(npObject)->jsObject();
-
-        ASSERT(globalObject);
-
-        return getOrCreateJSObject(globalObject, npObject);
-    }
+    case NPVariantType_Object:
+        return getOrCreateJSObject(globalObject, variant.value.objectValue);
     }
 
     ASSERT_NOT_REACHED();
@@ -154,18 +165,7 @@ void NPRuntimeObjectMap::convertJSValueToNPVariant(ExecState* exec, JSValue valu
     }
 
     if (value.isObject()) {
-        JSObject* jsObject = asObject(value);
-
-        if (jsObject->classInfo() == &JSNPObject::s_info) {
-            JSNPObject* jsNPObject = static_cast<JSNPObject*>(jsObject);
-            NPObject* npObject = jsNPObject->npObject();
-
-            retainNPObject(npObject);
-            OBJECT_TO_NPVARIANT(npObject, variant);
-            return;
-        }
-
-        NPObject* npObject = getOrCreateNPObject(jsObject);
+        NPObject* npObject = getOrCreateNPObject(asObject(value));
         OBJECT_TO_NPVARIANT(npObject, variant);
         return;
     }
@@ -207,14 +207,23 @@ bool NPRuntimeObjectMap::evaluate(NPObject* npObject, const String&scriptString,
 void NPRuntimeObjectMap::invalidate()
 {
     Vector<NPJSObject*> npJSObjects;
-    copyValuesToVector(m_objects, npJSObjects);
+    copyValuesToVector(m_npJSObjects, npJSObjects);
 
     // Deallocate all the object wrappers so we won't leak any JavaScript objects.
     for (size_t i = 0; i < npJSObjects.size(); ++i)
         deallocateNPObject(npJSObjects[i]);
     
-    // We shouldn't have any objects left now.
-    ASSERT(m_objects.isEmpty());
+    // We shouldn't have any NPJSObjects left now.
+    ASSERT(m_npJSObjects.isEmpty());
+
+    Vector<JSNPObject*> jsNPObjects;
+    copyValuesToVector(m_jsNPObjects, jsNPObjects);
+
+    // Invalidate all the JSObjects that wrap NPObjects.
+    for (size_t i = 0; i < jsNPObjects.size(); ++i)
+        jsNPObjects[i]->invalidate();
+
+    m_jsNPObjects.clear();
 }
 
 JSGlobalObject* NPRuntimeObjectMap::globalObject() const
diff --git a/WebKit2/WebProcess/Plugins/NPRuntimeObjectMap.h b/WebKit2/WebProcess/Plugins/NPRuntimeObjectMap.h
index ed064a6..51bd0c6 100644
--- a/WebKit2/WebProcess/Plugins/NPRuntimeObjectMap.h
+++ b/WebKit2/WebProcess/Plugins/NPRuntimeObjectMap.h
@@ -79,7 +79,8 @@ public:
 private:
     PluginView* m_pluginView;
 
-    HashMap<JSC::JSObject*, NPJSObject*> m_objects;
+    HashMap<JSC::JSObject*, NPJSObject*> m_npJSObjects;
+    HashMap<NPObject*, JSNPObject*> m_jsNPObjects;
 };
 
 } // namespace WebKit
diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 8dc3f6b..0e069ae 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,27 @@
+2010-08-02  Anders Carlsson  <andersca at apple.com>
+
+        Reviewed by Sam Weinig.
+
+        Cache JSNPObjects and fix bugs in the object map
+        https://bugs.webkit.org/show_bug.cgi?id=43368
+
+        Test that we correctly throw exceptions when trying to do things to a JSObject that used to
+        wrap an NPObject that came from a plug-in that is now destroyed.
+
+        * DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
+        * DumpRenderTree/TestNetscapePlugIn/PluginTest.h:
+        (PluginTest::Object::getProperty):
+        (PluginTest::Object::NP_GetProperty):
+        (PluginTest::Object::npClass):
+        * DumpRenderTree/TestNetscapePlugIn/Tests/NPRuntimeObjectFromDestroyedPlugin.cpp: Added.
+        (NPRuntimeObjectFromDestroyedPlugin::NPRuntimeObjectFromDestroyedPlugin):
+        (NPRuntimeObjectFromDestroyedPlugin::ScriptableObject::hasProperty):
+        (NPRuntimeObjectFromDestroyedPlugin::ScriptableObject::getProperty):
+        (NPRuntimeObjectFromDestroyedPlugin::NPP_GetValue):
+        * DumpRenderTree/TestNetscapePlugIn/win/TestNetscapePlugin.vcproj:
+        * DumpRenderTree/qt/TestNetscapePlugin/TestNetscapePlugin.pro:
+        * GNUmakefile.am:
+
 2010-08-02  Martin Robinson  <mrobinson at igalia.com>
 
         Reviewed by Xan Lopez.
diff --git a/WebKitTools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj b/WebKitTools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj
index 9d8b27b..c92c704 100644
--- a/WebKitTools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj
+++ b/WebKitTools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj
@@ -35,6 +35,7 @@
 		1A215A8111F2609C008AD0F5 /* PluginTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A215A7F11F2609C008AD0F5 /* PluginTest.cpp */; };
 		1A215A8211F2609C008AD0F5 /* PluginTest.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A215A8011F2609C008AD0F5 /* PluginTest.h */; };
 		1A215BE711F27658008AD0F5 /* DocumentOpenInDestroyStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A215A7511F26072008AD0F5 /* DocumentOpenInDestroyStream.cpp */; };
+		1A24BAA9120734EE00FBB059 /* NPRuntimeObjectFromDestroyedPlugin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A24BAA8120734EE00FBB059 /* NPRuntimeObjectFromDestroyedPlugin.cpp */; };
 		1A8F02E80BB9B4EC008CFA34 /* TestObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8F024C0BB9B056008CFA34 /* TestObject.h */; };
 		1AC6C8490D07638600CD3161 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AC6C77F0D07589B00CD3161 /* main.cpp */; };
 		1AC6C84A0D07638600CD3161 /* PluginObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AC6C7800D07589B00CD3161 /* PluginObject.cpp */; };
@@ -193,6 +194,7 @@
 		1A215A7511F26072008AD0F5 /* DocumentOpenInDestroyStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentOpenInDestroyStream.cpp; sourceTree = "<group>"; };
 		1A215A7F11F2609C008AD0F5 /* PluginTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PluginTest.cpp; sourceTree = "<group>"; };
 		1A215A8011F2609C008AD0F5 /* PluginTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginTest.h; sourceTree = "<group>"; };
+		1A24BAA8120734EE00FBB059 /* NPRuntimeObjectFromDestroyedPlugin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NPRuntimeObjectFromDestroyedPlugin.cpp; sourceTree = "<group>"; };
 		1A8F024C0BB9B056008CFA34 /* TestObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestObject.h; sourceTree = "<group>"; };
 		1AC6C77F0D07589B00CD3161 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; };
 		1AC6C7800D07589B00CD3161 /* PluginObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PluginObject.cpp; sourceTree = "<group>"; };
@@ -438,6 +440,7 @@
 			isa = PBXGroup;
 			children = (
 				1A215A7511F26072008AD0F5 /* DocumentOpenInDestroyStream.cpp */,
+				1A24BAA8120734EE00FBB059 /* NPRuntimeObjectFromDestroyedPlugin.cpp */,
 				1AC77DCE120605B6005C19EF /* NPRuntimeRemoveProperty.cpp */,
 				1AD9D2FD12028409001A70D1 /* PluginScriptableNPObjectInvokeDefault.cpp */,
 			);
@@ -712,6 +715,7 @@
 				1A215BE711F27658008AD0F5 /* DocumentOpenInDestroyStream.cpp in Sources */,
 				1AD9D2FE12028409001A70D1 /* PluginScriptableNPObjectInvokeDefault.cpp in Sources */,
 				1AC77DCF120605B6005C19EF /* NPRuntimeRemoveProperty.cpp in Sources */,
+				1A24BAA9120734EE00FBB059 /* NPRuntimeObjectFromDestroyedPlugin.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginTest.h b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginTest.h
index 01d49a6..ecc0185 100644
--- a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginTest.h
+++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginTest.h
@@ -47,6 +47,7 @@ DEFINE_HAS_MEMBER_CHECK(hasMethod, bool, (NPIdentifier methodName));
 DEFINE_HAS_MEMBER_CHECK(invoke, bool, (NPIdentifier methodName, const NPVariant*, uint32_t, NPVariant* result));
 DEFINE_HAS_MEMBER_CHECK(invokeDefault, bool, (const NPVariant*, uint32_t, NPVariant* result));
 DEFINE_HAS_MEMBER_CHECK(hasProperty, bool, (NPIdentifier propertyName));
+DEFINE_HAS_MEMBER_CHECK(getProperty, bool, (NPIdentifier propertyName, NPVariant* result));
 
 class PluginTest {
 public:
@@ -121,6 +122,12 @@ protected:
             return false;
         }
 
+        bool getProperty(NPIdentifier propertyName, NPVariant* result)
+        {
+            assert(false);
+            return false;
+        }
+
     protected:
         Object()
             : m_pluginTest(0)
@@ -163,7 +170,12 @@ protected:
         {
             return static_cast<T*>(npObject)->hasProperty(propertyName);
         }
-        
+
+        static bool NP_GetProperty(NPObject* npObject, NPIdentifier propertyName, NPVariant* result)
+        {
+            return static_cast<T*>(npObject)->getProperty(propertyName, result);
+        }
+
         static NPClass* npClass()
         {
             static NPClass npClass = {
@@ -175,7 +187,7 @@ protected:
                 has_member_invoke<T>::value ? NP_Invoke : 0,
                 has_member_invokeDefault<T>::value ? NP_InvokeDefault : 0,
                 has_member_hasProperty<T>::value ? NP_HasProperty : 0,
-                0, // NPClass::getProperty
+                has_member_getProperty<T>::value ? NP_GetProperty : 0,
                 0, // NPClass::setProperty
                 0, // NPClass::removeProperty
                 0, // NPClass::enumerate
diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/NPRuntimeObjectFromDestroyedPlugin.cpp b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/NPRuntimeObjectFromDestroyedPlugin.cpp
new file mode 100644
index 0000000..38236e3
--- /dev/null
+++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/NPRuntimeObjectFromDestroyedPlugin.cpp
@@ -0,0 +1,72 @@
+/*
+ * 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"
+
+using namespace std;
+
+class NPRuntimeObjectFromDestroyedPlugin : public PluginTest {
+public:
+    NPRuntimeObjectFromDestroyedPlugin(NPP npp, const string& identifier)
+        : PluginTest(npp, identifier)
+    {
+    }
+
+private:
+    // This is the test object.
+    class TestObject : public Object<TestObject> { };
+
+    // This is the scriptable object. It has a single "testObject" property.
+    class ScriptableObject : public Object<ScriptableObject> { 
+    public:
+        bool hasProperty(NPIdentifier propertyName)
+        {
+            return propertyName == pluginTest()->NPN_GetStringIdentifier("testObject");
+        }
+
+        bool getProperty(NPIdentifier propertyName, NPVariant* result)
+        {
+            if (propertyName != pluginTest()->NPN_GetStringIdentifier("testObject"))
+                return false;
+
+            NPObject* testObject = TestObject::create(pluginTest());
+            OBJECT_TO_NPVARIANT(testObject, *result);
+            return true;
+        }
+    };
+
+    virtual NPError NPP_GetValue(NPPVariable variable, void *value)
+    {
+        if (variable != NPPVpluginScriptableNPObject)
+            return NPERR_GENERIC_ERROR;
+        
+        *(NPObject**)value = ScriptableObject::create(this);
+        
+        return NPERR_NO_ERROR;
+    }
+};
+
+static PluginTest::Register<NPRuntimeObjectFromDestroyedPlugin> npRuntimeObjectFromDestroyedPlugin("npruntime-object-from-destroyed-plugin");
+
diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/win/TestNetscapePlugin.vcproj b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/win/TestNetscapePlugin.vcproj
index e83ab0b..c36666f 100644
--- a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/win/TestNetscapePlugin.vcproj
+++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/win/TestNetscapePlugin.vcproj
@@ -463,6 +463,10 @@
     		  RelativePath="..\Tests\DocumentOpenInDestroyStream.cpp"
     		>
     	  </File>
+    	  <File
+    		  RelativePath="..\Tests\NPRuntimeObjectFromDestroyedPlugin.cpp"
+    		>
+    	  </File>
 		  <File
     		  RelativePath="..\Tests\NPRuntimeRemoveProperty.cpp"
     		>
diff --git a/WebKitTools/DumpRenderTree/qt/TestNetscapePlugin/TestNetscapePlugin.pro b/WebKitTools/DumpRenderTree/qt/TestNetscapePlugin/TestNetscapePlugin.pro
index 47721f9..e48b035 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/NPRuntimeObjectFromDestroyedPlugin.cpp \
           Tests/NPRuntimeRemoveProperty.cpp \
           Tests/PluginScriptableNPObjectInvokeDefault.cpp
 
diff --git a/WebKitTools/GNUmakefile.am b/WebKitTools/GNUmakefile.am
index 2649407..33d4614 100644
--- a/WebKitTools/GNUmakefile.am
+++ b/WebKitTools/GNUmakefile.am
@@ -159,6 +159,7 @@ TestNetscapePlugin_libtestnetscapeplugin_la_SOURCES = \
 	WebKitTools/DumpRenderTree/unix/TestNetscapePlugin/ForwardingHeaders/WebKit/npruntime.h \
 	WebKitTools/DumpRenderTree/unix/TestNetscapePlugin/TestNetscapePlugin.cpp \
 	WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/DocumentOpenInDestroyStream.cpp \
+	WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/NPRuntimeObjectFromDestroyedPlugin.cpp \
 	WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/NPRuntimeRemoveProperty.cpp \
 	WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/PluginScriptableNPObjectInvokeDefault.cpp \
 	WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginTest.cpp \

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list