Diff
Modified: trunk/LayoutTests/ChangeLog (88678 => 88679)
--- trunk/LayoutTests/ChangeLog 2011-06-13 20:16:20 UTC (rev 88678)
+++ trunk/LayoutTests/ChangeLog 2011-06-13 20:19:07 UTC (rev 88679)
@@ -1,3 +1,13 @@
+2011-06-13 Nate Chapin <[email protected]>
+
+ Reviewed by Darin Fisher.
+
+ Test for https://bugs.webkit.org/show_bug.cgi?id=61482,
+ mostly written by Kelly Norton ([email protected]).
+
+ * plugins/npruntime/embed-property-equality-expected.txt: Added.
+ * plugins/npruntime/embed-property-equality.html: Added.
+
2011-06-13 Julien Chaffraix <[email protected]>
Reviewed by Alexey Proskuryakov.
Added: trunk/LayoutTests/plugins/npruntime/embed-property-equality-expected.txt (0 => 88679)
--- trunk/LayoutTests/plugins/npruntime/embed-property-equality-expected.txt (rev 0)
+++ trunk/LayoutTests/plugins/npruntime/embed-property-equality-expected.txt 2011-06-13 20:19:07 UTC (rev 88679)
@@ -0,0 +1,4 @@
+Test equality of plugin object properties.
+
+
+Send two references of a _javascript_ object to the plugin for identity comparison in C++ PASS
Added: trunk/LayoutTests/plugins/npruntime/embed-property-equality.html (0 => 88679)
--- trunk/LayoutTests/plugins/npruntime/embed-property-equality.html (rev 0)
+++ trunk/LayoutTests/plugins/npruntime/embed-property-equality.html 2011-06-13 20:19:07 UTC (rev 88679)
@@ -0,0 +1,18 @@
+<body _onload_="test()">
+<p>Test equality of plugin object properties.</p>
+<div id=div>
+<embed id="plugin" type="application/x-webkit-test-netscape">
+</div>
+<script>
+if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+window._onload_ = function() {
+ var plugin = document.getElementById('plugin');
+ var div = document.createElement('div');
+ div.textContent = "Send two references of a _javascript_ object to the plugin for identity comparison in C++ "
+ + (plugin.objectsAreSame(document, document) ? "PASS" : "FAIL");
+ document.body.appendChild(div);
+}
+</script>
+</body>
Modified: trunk/Source/WebCore/ChangeLog (88678 => 88679)
--- trunk/Source/WebCore/ChangeLog 2011-06-13 20:16:20 UTC (rev 88678)
+++ trunk/Source/WebCore/ChangeLog 2011-06-13 20:19:07 UTC (rev 88679)
@@ -1,3 +1,17 @@
+2011-06-13 Nate Chapin <[email protected]>
+
+ Reviewed by Darin Fisher.
+
+ [V8] Cache V8NPObjects so that we don't create multiple
+ NPObjects for the same v8::Object.
+ https://bugs.webkit.org/show_bug.cgi?id=61482
+
+ Test: plugins/npruntime/embed-property-equality.html
+
+ * bindings/v8/NPV8Object.cpp:
+ (WebCore::freeV8NPObject):
+ (WebCore::npCreateV8ScriptObject):
+
2011-06-13 Xan Lopez <[email protected]>
Reviewed by Martin Robinson.
Modified: trunk/Source/WebCore/bindings/v8/NPV8Object.cpp (88678 => 88679)
--- trunk/Source/WebCore/bindings/v8/NPV8Object.cpp 2011-06-13 20:16:20 UTC (rev 88678)
+++ trunk/Source/WebCore/bindings/v8/NPV8Object.cpp 2011-06-13 20:19:07 UTC (rev 88679)
@@ -61,6 +61,14 @@
return &typeInfo;
}
+typedef HashMap<int, V8NPObject*> V8NPObjectMap;
+
+static V8NPObjectMap* staticV8NPObjectMap()
+{
+ DEFINE_STATIC_LOCAL(V8NPObjectMap, v8npObjectMap, ());
+ return &v8npObjectMap;
+}
+
// FIXME: Comments on why use malloc and free.
static NPObject* allocV8NPObject(NPP, NPClass*)
{
@@ -70,6 +78,14 @@
static void freeV8NPObject(NPObject* npObject)
{
V8NPObject* v8NpObject = reinterpret_cast<V8NPObject*>(npObject);
+ if (int v8ObjectHash = v8NpObject->v8Object->GetIdentityHash()) {
+ ASSERT(staticV8NPObjectMap()->contains(v8ObjectHash));
+ staticV8NPObjectMap()->remove(v8ObjectHash);
+ } else {
+ ASSERT(!v8::Context::InContext());
+ staticV8NPObjectMap()->clear();
+ }
+
#ifndef NDEBUG
V8GCController::unregisterGlobalHandle(v8NpObject, v8NpObject->v8Object);
#endif
@@ -125,12 +141,24 @@
}
}
+ int v8ObjectHash = object->GetIdentityHash();
+ ASSERT(v8ObjectHash);
+ if (staticV8NPObjectMap()->contains(v8ObjectHash)) {
+ V8NPObject* v8npObject = staticV8NPObjectMap()->get(v8ObjectHash);
+ ASSERT(v8npObject->v8Object == object);
+ _NPN_RetainObject(&v8npObject->object);
+ return reinterpret_cast<NPObject*>(v8npObject);
+ }
+
V8NPObject* v8npObject = reinterpret_cast<V8NPObject*>(_NPN_CreateObject(npp, &V8NPObjectClass));
v8npObject->v8Object = v8::Persistent<v8::Object>::New(object);
#ifndef NDEBUG
V8GCController::registerGlobalHandle(NPOBJECT, v8npObject, v8npObject->v8Object);
#endif
v8npObject->rootObject = root;
+
+ staticV8NPObjectMap()->set(v8ObjectHash, v8npObject);
+
return reinterpret_cast<NPObject*>(v8npObject);
}
Modified: trunk/Tools/ChangeLog (88678 => 88679)
--- trunk/Tools/ChangeLog 2011-06-13 20:16:20 UTC (rev 88678)
+++ trunk/Tools/ChangeLog 2011-06-13 20:19:07 UTC (rev 88679)
@@ -1,3 +1,11 @@
+2011-06-13 Nate Chapin <[email protected]>
+
+ Reviewed by Darin Fisher.
+
+ New test method on TestNetscapePlugin for https://bugs.webkit.org/show_bug.cgi?id=61482.
+
+ * DumpRenderTree/TestNetscapePlugIn/PluginObject.cpp:
+
2011-06-13 Dirk Pranke <[email protected]>
Reviewed by Tony Chang.
Modified: trunk/Tools/DumpRenderTree/TestNetscapePlugIn/PluginObject.cpp (88678 => 88679)
--- trunk/Tools/DumpRenderTree/TestNetscapePlugIn/PluginObject.cpp 2011-06-13 20:16:20 UTC (rev 88678)
+++ trunk/Tools/DumpRenderTree/TestNetscapePlugIn/PluginObject.cpp 2011-06-13 20:19:07 UTC (rev 88679)
@@ -205,6 +205,7 @@
ID_RESIZE_TO,
ID_NORMALIZE,
ID_INVALIDATE_RECT,
+ ID_OBJECTS_ARE_SAME,
NUM_METHOD_IDENTIFIERS
};
@@ -246,7 +247,8 @@
"setStatus",
"resizeTo",
"normalize",
- "invalidateRect"
+ "invalidateRect",
+ "objectsAreSame"
};
static NPUTF8* createCStringFromNPVariant(const NPVariant* variant)
@@ -1008,6 +1010,15 @@
return true;
}
+static bool objectsAreSame(PluginObject* obj, const NPVariant* args, uint32_t argCount, NPVariant* result)
+{
+ if (argCount != 2 || !NPVARIANT_IS_OBJECT(args[0]) || !NPVARIANT_IS_OBJECT(args[1]))
+ return false;
+
+ BOOLEAN_TO_NPVARIANT(NPVARIANT_TO_OBJECT(args[0]) == NPVARIANT_TO_OBJECT(args[1]), *result);
+ return true;
+}
+
static bool pluginInvoke(NPObject* header, NPIdentifier name, const NPVariant* args, uint32_t argCount, NPVariant* result)
{
PluginObject* plugin = reinterpret_cast<PluginObject*>(header);
@@ -1124,6 +1135,8 @@
return normalizeOverride(plugin, args, argCount, result);
if (name == pluginMethodIdentifiers[ID_INVALIDATE_RECT])
return invalidateRect(plugin, args, argCount, result);
+ if (name == pluginMethodIdentifiers[ID_OBJECTS_ARE_SAME])
+ return objectsAreSame(plugin, args, argCount, result);
return false;
}