Diff
Modified: trunk/LayoutTests/ChangeLog (90371 => 90372)
--- trunk/LayoutTests/ChangeLog 2011-07-04 19:26:05 UTC (rev 90371)
+++ trunk/LayoutTests/ChangeLog 2011-07-04 19:58:56 UTC (rev 90372)
@@ -1,3 +1,17 @@
+2011-07-04 Anders Carlsson <[email protected]>
+
+ NP_RemoveProperty is not called back by Safari when delete npObject.prop is encountered in _javascript_
+ https://bugs.webkit.org/show_bug.cgi?id=63915
+ <rdar://problem/7124300>
+
+ Reviewed by Sam Weinig.
+
+ Add a test. I made this Mac-WebKit2 specific for now since no other plug-in implementations support this,
+ and there doesn't seem to be a way to make a WebKit2 specific test.
+
+ * platform/mac-wk2/plugins/npruntime/remove-property-from-_javascript_-expected.txt: Added.
+ * platform/mac-wk2/plugins/npruntime/remove-property-from-_javascript_.html: Added.
+
2011-07-04 Stephen White <[email protected]>
Unreviewed; chromium test expectations change.
Added: trunk/LayoutTests/platform/mac-wk2/plugins/npruntime/remove-property-from-_javascript_-expected.txt (0 => 90372)
--- trunk/LayoutTests/platform/mac-wk2/plugins/npruntime/remove-property-from-_javascript_-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/mac-wk2/plugins/npruntime/remove-property-from-_javascript_-expected.txt 2011-07-04 19:58:56 UTC (rev 90372)
@@ -0,0 +1,9 @@
+
+Test that 'delete object.property' ends up calling NP_RemoveProperty
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS testObject.lastRemovedProperty is 'testProperty'
+PASS testObject.lastRemovedProperty is 242
+
Added: trunk/LayoutTests/platform/mac-wk2/plugins/npruntime/remove-property-from-_javascript_.html (0 => 90372)
--- trunk/LayoutTests/platform/mac-wk2/plugins/npruntime/remove-property-from-_javascript_.html (rev 0)
+++ trunk/LayoutTests/platform/mac-wk2/plugins/npruntime/remove-property-from-_javascript_.html 2011-07-04 19:58:56 UTC (rev 90372)
@@ -0,0 +1,25 @@
+<link rel="stylesheet" href=""
+<script src=""
+</head>
+<script>
+function runTest() {
+ plugin = document.getElementById('plugin');
+
+ testObject = plugin.testObject;
+ delete testObject.testProperty;
+ shouldBe("testObject.lastRemovedProperty", "'testProperty'")
+
+ delete testObject[242];
+ shouldBe("testObject.lastRemovedProperty", "242");
+}
+</script>
+<body _onLoad_="runTest()">
+<embed id="plugin" type="application/x-webkit-test-netscape" test="npruntime-remove-property"></embed>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test that 'delete object.property' ends up calling NP_RemoveProperty");
+
+successfullyParsed = true;
+</script>
Modified: trunk/Source/WebKit2/ChangeLog (90371 => 90372)
--- trunk/Source/WebKit2/ChangeLog 2011-07-04 19:26:05 UTC (rev 90371)
+++ trunk/Source/WebKit2/ChangeLog 2011-07-04 19:58:56 UTC (rev 90372)
@@ -1,3 +1,18 @@
+2011-07-04 Anders Carlsson <[email protected]>
+
+ NP_RemoveProperty is not called back by Safari when delete npObject.prop is encountered in _javascript_
+ https://bugs.webkit.org/show_bug.cgi?id=63915
+ <rdar://problem/7124300>
+
+ Reviewed by Sam Weinig.
+
+ * WebProcess/Plugins/Netscape/JSNPObject.cpp:
+ (WebKit::JSNPObject::deleteProperty):
+ Call NP_RemoveProperty on the NPObject.
+
+ * WebProcess/Plugins/Netscape/JSNPObject.h:
+ Add deleteProperty.
+
2011-06-23 Robert Hogan <[email protected]>
Reviewed by Simon Hausmann.
Modified: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.cpp (90371 => 90372)
--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.cpp 2011-07-04 19:26:05 UTC (rev 90371)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.cpp 2011-07-04 19:58:56 UTC (rev 90372)
@@ -321,6 +321,47 @@
releaseNPVariantValue(&variant);
}
+bool JSNPObject::deleteProperty(ExecState* exec, const Identifier& propertyName)
+{
+ return deleteProperty(exec, npIdentifierFromIdentifier(propertyName));
+}
+
+bool JSNPObject::deleteProperty(ExecState* exec, unsigned propertyName)
+{
+ return deleteProperty(exec, static_cast<NPIdentifier>(IdentifierRep::get(propertyName)));
+}
+
+bool JSNPObject::deleteProperty(ExecState* exec, NPIdentifier propertyName)
+{
+ ASSERT_GC_OBJECT_INHERITS(this, &s_info);
+ if (!m_npObject) {
+ throwInvalidAccessError(exec);
+ return false;
+ }
+
+ if (!m_npObject->_class->removeProperty) {
+ // FIXME: Should we throw an exception here?
+ return false;
+ }
+
+ // Calling NPClass::setProperty will call into plug-in code, and there's no telling what the plug-in can do.
+ // (including destroying the plug-in). Because of this, we make sure to keep the plug-in alive until
+ // the call has finished.
+ NPRuntimeObjectMap::PluginProtector protector(m_objectMap);
+
+ {
+ JSLock::DropAllLocks dropAllLocks(SilenceAssertionsOnly);
+
+ // FIXME: Should we throw an exception if removeProperty returns false?
+ if (!m_npObject->_class->removeProperty(m_npObject, propertyName))
+ return false;
+
+ NPRuntimeObjectMap::moveGlobalExceptionToExecState(exec);
+ }
+
+ return true;
+}
+
void JSNPObject::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNameArray, EnumerationMode mode)
{
ASSERT_GC_OBJECT_INHERITS(this, &s_info);
Modified: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.h (90371 => 90372)
--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.h 2011-07-04 19:26:05 UTC (rev 90371)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.h 2011-07-04 19:58:56 UTC (rev 90372)
@@ -67,6 +67,11 @@
virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&);
virtual void put(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSValue, JSC::PutPropertySlot&);
+ virtual bool deleteProperty(JSC::ExecState*, const JSC::Identifier& propertyName);
+ virtual bool deleteProperty(JSC::ExecState*, unsigned propertyName);
+
+ bool deleteProperty(JSC::ExecState*, NPIdentifier propertyName);
+
virtual void getOwnPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&, JSC::EnumerationMode mode = JSC::ExcludeDontEnumProperties);
static JSC::JSValue propertyGetter(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&);
Modified: trunk/Tools/ChangeLog (90371 => 90372)
--- trunk/Tools/ChangeLog 2011-07-04 19:26:05 UTC (rev 90371)
+++ trunk/Tools/ChangeLog 2011-07-04 19:58:56 UTC (rev 90372)
@@ -1,3 +1,37 @@
+2011-07-04 Anders Carlsson <[email protected]>
+
+ NP_RemoveProperty is not called back by Safari when delete npObject.prop is encountered in _javascript_
+ https://bugs.webkit.org/show_bug.cgi?id=63915
+ <rdar://problem/7124300>
+
+ Reviewed by Sam Weinig.
+
+ Extend the NPRuntimeRemoveProperty to handle delete object.property from _javascript_.
+
+ * DumpRenderTree/TestNetscapePlugIn/PluginTest.cpp:
+ (PluginTest::NPN_IdentifierIsString):
+ (PluginTest::NPN_UTF8FromIdentifier):
+ (PluginTest::NPN_IntFromIdentifier):
+ (PluginTest::NPN_RetainObject):
+ (PluginTest::NPN_ReleaseObject):
+ * DumpRenderTree/TestNetscapePlugIn/PluginTest.h:
+ (PluginTest::Object::removeProperty):
+ (PluginTest::Object::identifierIs):
+ (PluginTest::Object::NP_RemoveProperty):
+ (PluginTest::Object::npClass):
+ * DumpRenderTree/TestNetscapePlugIn/Tests/NPRuntimeRemoveProperty.cpp:
+ (NPRuntimeRemoveProperty::TestObject::TestObject):
+ (NPRuntimeRemoveProperty::TestObject::hasProperty):
+ (NPRuntimeRemoveProperty::TestObject::getProperty):
+ (NPRuntimeRemoveProperty::TestObject::removeProperty):
+ (NPRuntimeRemoveProperty::PluginObject::PluginObject):
+ (NPRuntimeRemoveProperty::PluginObject::~PluginObject):
+ (NPRuntimeRemoveProperty::PluginObject::hasMethod):
+ (NPRuntimeRemoveProperty::PluginObject::invoke):
+ (NPRuntimeRemoveProperty::PluginObject::hasProperty):
+ (NPRuntimeRemoveProperty::PluginObject::getProperty):
+ (NPRuntimeRemoveProperty::NPP_GetValue):
+
2011-07-04 Leandro Pereira <[email protected]>
Reviewed by Kent Tamura.
Modified: trunk/Tools/DumpRenderTree/TestNetscapePlugIn/PluginTest.cpp (90371 => 90372)
--- trunk/Tools/DumpRenderTree/TestNetscapePlugIn/PluginTest.cpp 2011-07-04 19:26:05 UTC (rev 90371)
+++ trunk/Tools/DumpRenderTree/TestNetscapePlugIn/PluginTest.cpp 2011-07-04 19:58:56 UTC (rev 90372)
@@ -169,11 +169,36 @@
return browser->getintidentifier(intid);
}
+bool PluginTest::NPN_IdentifierIsString(NPIdentifier npIdentifier)
+{
+ return browser->identifierisstring(npIdentifier);
+}
+
+NPUTF8* PluginTest::NPN_UTF8FromIdentifier(NPIdentifier npIdentifier)
+{
+ return browser->utf8fromidentifier(npIdentifier);
+}
+
+int32_t PluginTest::NPN_IntFromIdentifier(NPIdentifier npIdentifier)
+{
+ return browser->intfromidentifier(npIdentifier);
+}
+
NPObject* PluginTest::NPN_CreateObject(NPClass* npClass)
{
return browser->createobject(m_npp, npClass);
}
+NPObject* PluginTest::NPN_RetainObject(NPObject* npObject)
+{
+ return browser->retainobject(npObject);
+}
+
+void PluginTest::NPN_ReleaseObject(NPObject* npObject)
+{
+ browser->releaseobject(npObject);
+}
+
bool PluginTest::NPN_RemoveProperty(NPObject* npObject, NPIdentifier propertyName)
{
return browser->removeproperty(m_npp, npObject, propertyName);
Modified: trunk/Tools/DumpRenderTree/TestNetscapePlugIn/PluginTest.h (90371 => 90372)
--- trunk/Tools/DumpRenderTree/TestNetscapePlugIn/PluginTest.h 2011-07-04 19:26:05 UTC (rev 90371)
+++ trunk/Tools/DumpRenderTree/TestNetscapePlugIn/PluginTest.h 2011-07-04 19:58:56 UTC (rev 90372)
@@ -48,6 +48,7 @@
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));
+DEFINE_HAS_MEMBER_CHECK(removeProperty, bool, (NPIdentifier propertyName));
class PluginTest {
public:
@@ -78,7 +79,13 @@
// NPRuntime NPN functions.
NPIdentifier NPN_GetStringIdentifier(const NPUTF8* name);
NPIdentifier NPN_GetIntIdentifier(int32_t intid);
+ bool NPN_IdentifierIsString(NPIdentifier);
+ NPUTF8* NPN_UTF8FromIdentifier(NPIdentifier);
+ int32_t NPN_IntFromIdentifier(NPIdentifier);
+
NPObject* NPN_CreateObject(NPClass*);
+ NPObject* NPN_RetainObject(NPObject*);
+ void NPN_ReleaseObject(NPObject*);
bool NPN_RemoveProperty(NPObject*, NPIdentifier propertyName);
#ifdef XP_MACOSX
@@ -159,6 +166,18 @@
return false;
}
+ bool removeProperty(NPIdentifier propertyName)
+ {
+ assert(false);
+ return false;
+ }
+
+ // Helper functions.
+ bool identifierIs(NPIdentifier identifier, const char* value)
+ {
+ return pluginTest()->NPN_GetStringIdentifier(value) == identifier;
+ }
+
protected:
Object()
: m_pluginTest(0)
@@ -207,6 +226,11 @@
return static_cast<T*>(npObject)->getProperty(propertyName, result);
}
+ static bool NP_RemoveProperty(NPObject* npObject, NPIdentifier propertyName)
+ {
+ return static_cast<T*>(npObject)->removeProperty(propertyName);
+ }
+
static NPClass* npClass()
{
static NPClass npClass = {
@@ -220,7 +244,7 @@
has_member_hasProperty<T>::value ? NP_HasProperty : 0,
has_member_getProperty<T>::value ? NP_GetProperty : 0,
0, // NPClass::setProperty
- 0, // NPClass::removeProperty
+ has_member_removeProperty<T>::value ? NP_RemoveProperty : 0,
0, // NPClass::enumerate
0 // NPClass::construct
};
Modified: trunk/Tools/DumpRenderTree/TestNetscapePlugIn/Tests/NPRuntimeRemoveProperty.cpp (90371 => 90372)
--- trunk/Tools/DumpRenderTree/TestNetscapePlugIn/Tests/NPRuntimeRemoveProperty.cpp 2011-07-04 19:26:05 UTC (rev 90371)
+++ trunk/Tools/DumpRenderTree/TestNetscapePlugIn/Tests/NPRuntimeRemoveProperty.cpp 2011-07-04 19:58:56 UTC (rev 90372)
@@ -36,16 +36,74 @@
}
private:
- struct TestObject : Object<TestObject> {
+ struct TestObject : Object<TestObject> {
public:
+ TestObject()
+ : m_lastRemovedProperty(0)
+ {
+ }
+
+ bool hasProperty(NPIdentifier propertyName)
+ {
+ if (identifierIs(propertyName, "lastRemovedProperty"))
+ return true;
+
+ return false;
+ }
+
+ bool getProperty(NPIdentifier propertyName, NPVariant* result)
+ {
+ assert(identifierIs(propertyName, "lastRemovedProperty"));
+
+ if (!m_lastRemovedProperty)
+ return false;
+
+ if (pluginTest()->NPN_IdentifierIsString(m_lastRemovedProperty)) {
+ char* lastRemovedPropertyName = pluginTest()->NPN_UTF8FromIdentifier(m_lastRemovedProperty);
+
+ STRINGZ_TO_NPVARIANT(lastRemovedPropertyName, *result);
+ return true;
+ }
+
+ int intIdentifier = pluginTest()->NPN_IntFromIdentifier(m_lastRemovedProperty);
+ DOUBLE_TO_NPVARIANT(intIdentifier, *result);
+ return true;
+ }
+
+ bool removeProperty(NPIdentifier propertyName)
+ {
+ m_lastRemovedProperty = propertyName;
+ return true;
+ }
+
+ private:
+ NPIdentifier m_lastRemovedProperty;
+ };
+
+ struct PluginObject : Object<PluginObject> {
+ public:
+ PluginObject()
+ : m_testObject(0)
+ {
+ }
+
+ ~PluginObject()
+ {
+ if (m_testObject)
+ pluginTest()->NPN_ReleaseObject(m_testObject);
+ }
+
bool hasMethod(NPIdentifier methodName)
{
- return methodName == pluginTest()->NPN_GetStringIdentifier("testRemoveProperty");
+ if (identifierIs(methodName, "testRemoveProperty"))
+ return true;
+
+ return false;
}
bool invoke(NPIdentifier methodName, const NPVariant* arguments, uint32_t argumentCount, NPVariant* result)
{
- assert(methodName == pluginTest()->NPN_GetStringIdentifier("testRemoveProperty"));
+ assert(identifierIs(methodName, "testRemoveProperty"));
if (argumentCount != 2)
return false;
@@ -72,6 +130,28 @@
VOID_TO_NPVARIANT(*result);
return true;
}
+
+ bool hasProperty(NPIdentifier propertyName)
+ {
+ if (identifierIs(propertyName, "testObject"))
+ return true;
+
+ return false;
+ }
+
+ bool getProperty(NPIdentifier propertyName, NPVariant* result)
+ {
+ assert(identifierIs(propertyName, "testObject"));
+
+ if (!m_testObject)
+ m_testObject = TestObject::create(pluginTest());
+
+ OBJECT_TO_NPVARIANT(pluginTest()->NPN_RetainObject(m_testObject), *result);
+ return true;
+ }
+
+ private:
+ NPObject* m_testObject;
};
virtual NPError NPP_GetValue(NPPVariable variable, void *value)
@@ -79,7 +159,7 @@
if (variable != NPPVpluginScriptableNPObject)
return NPERR_GENERIC_ERROR;
- *(NPObject**)value = TestObject::create(this);
+ *(NPObject**)value = PluginObject::create(this);
return NPERR_NO_ERROR;
}