Changeset 90372 in webkit


Ignore:
Timestamp:
Jul 4, 2011 12:58:56 PM (13 years ago)
Author:
andersca@apple.com
Message:

2011-07-04 Anders Carlsson <andersca@apple.com>

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-07-04 Anders Carlsson <andersca@apple.com>

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 Anders Carlsson <andersca@apple.com>

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):
Location:
trunk
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r90370 r90372  
     12011-07-04  Anders Carlsson  <andersca@apple.com>
     2
     3        NP_RemoveProperty is not called back by Safari when delete npObject.prop is encountered in JavaScript
     4        https://bugs.webkit.org/show_bug.cgi?id=63915
     5        <rdar://problem/7124300>
     6
     7        Reviewed by Sam Weinig.
     8
     9        Add a test. I made this Mac-WebKit2 specific for now since no other plug-in implementations support this,
     10        and there doesn't seem to be a way to make a WebKit2 specific test.
     11
     12        * platform/mac-wk2/plugins/npruntime/remove-property-from-javascript-expected.txt: Added.
     13        * platform/mac-wk2/plugins/npruntime/remove-property-from-javascript.html: Added.
     14
    1152011-07-04  Stephen White  <senorblanco@chromium.org>
    216
  • trunk/Source/WebKit2/ChangeLog

    r90338 r90372  
     12011-07-04  Anders Carlsson  <andersca@apple.com>
     2
     3        NP_RemoveProperty is not called back by Safari when delete npObject.prop is encountered in JavaScript
     4        https://bugs.webkit.org/show_bug.cgi?id=63915
     5        <rdar://problem/7124300>
     6
     7        Reviewed by Sam Weinig.
     8
     9        * WebProcess/Plugins/Netscape/JSNPObject.cpp:
     10        (WebKit::JSNPObject::deleteProperty):
     11        Call NP_RemoveProperty on the NPObject.
     12
     13        * WebProcess/Plugins/Netscape/JSNPObject.h:
     14        Add deleteProperty.
     15
    1162011-06-23  Robert Hogan  <robert@webkit.org>
    217
  • trunk/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.cpp

    r87179 r90372  
    322322}
    323323
     324bool JSNPObject::deleteProperty(ExecState* exec, const Identifier& propertyName)
     325{
     326    return deleteProperty(exec, npIdentifierFromIdentifier(propertyName));
     327}
     328
     329bool JSNPObject::deleteProperty(ExecState* exec, unsigned propertyName)
     330{
     331    return deleteProperty(exec, static_cast<NPIdentifier>(IdentifierRep::get(propertyName)));
     332}
     333
     334bool JSNPObject::deleteProperty(ExecState* exec, NPIdentifier propertyName)
     335{
     336    ASSERT_GC_OBJECT_INHERITS(this, &s_info);
     337    if (!m_npObject) {
     338        throwInvalidAccessError(exec);
     339        return false;
     340    }
     341
     342    if (!m_npObject->_class->removeProperty) {
     343        // FIXME: Should we throw an exception here?
     344        return false;
     345    }
     346
     347    // Calling NPClass::setProperty will call into plug-in code, and there's no telling what the plug-in can do.
     348    // (including destroying the plug-in). Because of this, we make sure to keep the plug-in alive until
     349    // the call has finished.
     350    NPRuntimeObjectMap::PluginProtector protector(m_objectMap);
     351
     352    {
     353        JSLock::DropAllLocks dropAllLocks(SilenceAssertionsOnly);
     354
     355        // FIXME: Should we throw an exception if removeProperty returns false?
     356        if (!m_npObject->_class->removeProperty(m_npObject, propertyName))
     357            return false;
     358
     359        NPRuntimeObjectMap::moveGlobalExceptionToExecState(exec);
     360    }
     361
     362    return true;
     363}
     364
    324365void JSNPObject::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNameArray, EnumerationMode mode)
    325366{
  • trunk/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.h

    r84052 r90372  
    6868    virtual void put(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSValue, JSC::PutPropertySlot&);
    6969
     70    virtual bool deleteProperty(JSC::ExecState*, const JSC::Identifier& propertyName);
     71    virtual bool deleteProperty(JSC::ExecState*, unsigned propertyName);
     72
     73    bool deleteProperty(JSC::ExecState*, NPIdentifier propertyName);
     74
    7075    virtual void getOwnPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&, JSC::EnumerationMode mode = JSC::ExcludeDontEnumProperties);
    7176
  • trunk/Tools/ChangeLog

    r90361 r90372  
     12011-07-04  Anders Carlsson  <andersca@apple.com>
     2
     3        NP_RemoveProperty is not called back by Safari when delete npObject.prop is encountered in JavaScript
     4        https://bugs.webkit.org/show_bug.cgi?id=63915
     5        <rdar://problem/7124300>
     6
     7        Reviewed by Sam Weinig.
     8
     9        Extend the NPRuntimeRemoveProperty to handle delete object.property from JavaScript.
     10
     11        * DumpRenderTree/TestNetscapePlugIn/PluginTest.cpp:
     12        (PluginTest::NPN_IdentifierIsString):
     13        (PluginTest::NPN_UTF8FromIdentifier):
     14        (PluginTest::NPN_IntFromIdentifier):
     15        (PluginTest::NPN_RetainObject):
     16        (PluginTest::NPN_ReleaseObject):
     17        * DumpRenderTree/TestNetscapePlugIn/PluginTest.h:
     18        (PluginTest::Object::removeProperty):
     19        (PluginTest::Object::identifierIs):
     20        (PluginTest::Object::NP_RemoveProperty):
     21        (PluginTest::Object::npClass):
     22        * DumpRenderTree/TestNetscapePlugIn/Tests/NPRuntimeRemoveProperty.cpp:
     23        (NPRuntimeRemoveProperty::TestObject::TestObject):
     24        (NPRuntimeRemoveProperty::TestObject::hasProperty):
     25        (NPRuntimeRemoveProperty::TestObject::getProperty):
     26        (NPRuntimeRemoveProperty::TestObject::removeProperty):
     27        (NPRuntimeRemoveProperty::PluginObject::PluginObject):
     28        (NPRuntimeRemoveProperty::PluginObject::~PluginObject):
     29        (NPRuntimeRemoveProperty::PluginObject::hasMethod):
     30        (NPRuntimeRemoveProperty::PluginObject::invoke):
     31        (NPRuntimeRemoveProperty::PluginObject::hasProperty):
     32        (NPRuntimeRemoveProperty::PluginObject::getProperty):
     33        (NPRuntimeRemoveProperty::NPP_GetValue):
     34
    1352011-07-04  Leandro Pereira  <leandro@profusion.mobi>
    236
  • trunk/Tools/DumpRenderTree/TestNetscapePlugIn/PluginTest.cpp

    r86467 r90372  
    170170}
    171171
     172bool PluginTest::NPN_IdentifierIsString(NPIdentifier npIdentifier)
     173{
     174    return browser->identifierisstring(npIdentifier);
     175}
     176
     177NPUTF8* PluginTest::NPN_UTF8FromIdentifier(NPIdentifier npIdentifier)
     178{
     179    return browser->utf8fromidentifier(npIdentifier);
     180}
     181
     182int32_t PluginTest::NPN_IntFromIdentifier(NPIdentifier npIdentifier)
     183{
     184    return browser->intfromidentifier(npIdentifier);
     185}
     186
    172187NPObject* PluginTest::NPN_CreateObject(NPClass* npClass)
    173188{
    174189    return browser->createobject(m_npp, npClass);
    175190}                                 
     191
     192NPObject* PluginTest::NPN_RetainObject(NPObject* npObject)
     193{
     194    return browser->retainobject(npObject);
     195}
     196
     197void PluginTest::NPN_ReleaseObject(NPObject* npObject)
     198{
     199    browser->releaseobject(npObject);
     200}
    176201
    177202bool PluginTest::NPN_RemoveProperty(NPObject* npObject, NPIdentifier propertyName)
  • trunk/Tools/DumpRenderTree/TestNetscapePlugIn/PluginTest.h

    r86467 r90372  
    4949DEFINE_HAS_MEMBER_CHECK(hasProperty, bool, (NPIdentifier propertyName));
    5050DEFINE_HAS_MEMBER_CHECK(getProperty, bool, (NPIdentifier propertyName, NPVariant* result));
     51DEFINE_HAS_MEMBER_CHECK(removeProperty, bool, (NPIdentifier propertyName));
    5152
    5253class PluginTest {
     
    7980    NPIdentifier NPN_GetStringIdentifier(const NPUTF8* name);
    8081    NPIdentifier NPN_GetIntIdentifier(int32_t intid);
     82    bool NPN_IdentifierIsString(NPIdentifier);
     83    NPUTF8* NPN_UTF8FromIdentifier(NPIdentifier);
     84    int32_t NPN_IntFromIdentifier(NPIdentifier);
     85
    8186    NPObject* NPN_CreateObject(NPClass*);
     87    NPObject* NPN_RetainObject(NPObject*);
     88    void NPN_ReleaseObject(NPObject*);
    8289    bool NPN_RemoveProperty(NPObject*, NPIdentifier propertyName);
    8390
     
    160167        }
    161168
     169        bool removeProperty(NPIdentifier propertyName)
     170        {
     171            assert(false);
     172            return false;
     173        }
     174
     175        // Helper functions.
     176        bool identifierIs(NPIdentifier identifier, const char* value)
     177        {
     178            return pluginTest()->NPN_GetStringIdentifier(value) == identifier;
     179        }
     180
    162181    protected:
    163182        Object()
     
    206225        {
    207226            return static_cast<T*>(npObject)->getProperty(propertyName, result);
     227        }
     228
     229        static bool NP_RemoveProperty(NPObject* npObject, NPIdentifier propertyName)
     230        {
     231            return static_cast<T*>(npObject)->removeProperty(propertyName);
    208232        }
    209233
     
    221245                has_member_getProperty<T>::value ? NP_GetProperty : 0,
    222246                0, // NPClass::setProperty
    223                 0, // NPClass::removeProperty
     247                has_member_removeProperty<T>::value ? NP_RemoveProperty : 0,
    224248                0, // NPClass::enumerate
    225249                0  // NPClass::construct
  • trunk/Tools/DumpRenderTree/TestNetscapePlugIn/Tests/NPRuntimeRemoveProperty.cpp

    r89202 r90372  
    3737   
    3838private:
    39     struct TestObject : Object<TestObject> { 
     39    struct TestObject : Object<TestObject> {
    4040    public:
     41        TestObject()
     42            : m_lastRemovedProperty(0)
     43        {
     44        }
     45
     46        bool hasProperty(NPIdentifier propertyName)
     47        {
     48            if (identifierIs(propertyName, "lastRemovedProperty"))
     49                return true;
     50           
     51            return false;
     52        }
     53
     54        bool getProperty(NPIdentifier propertyName, NPVariant* result)
     55        {
     56            assert(identifierIs(propertyName, "lastRemovedProperty"));
     57
     58            if (!m_lastRemovedProperty)
     59                return false;
     60
     61            if (pluginTest()->NPN_IdentifierIsString(m_lastRemovedProperty)) {
     62                char* lastRemovedPropertyName = pluginTest()->NPN_UTF8FromIdentifier(m_lastRemovedProperty);
     63               
     64                STRINGZ_TO_NPVARIANT(lastRemovedPropertyName, *result);
     65                return true;
     66            }
     67
     68            int intIdentifier = pluginTest()->NPN_IntFromIdentifier(m_lastRemovedProperty);
     69            DOUBLE_TO_NPVARIANT(intIdentifier, *result);
     70            return true;
     71        }
     72
     73        bool removeProperty(NPIdentifier propertyName)
     74        {
     75            m_lastRemovedProperty = propertyName;
     76            return true;
     77        }
     78
     79    private:
     80        NPIdentifier m_lastRemovedProperty;
     81    };
     82
     83    struct PluginObject : Object<PluginObject> {
     84    public:
     85        PluginObject()
     86            : m_testObject(0)
     87        {
     88        }
     89
     90        ~PluginObject()
     91        {
     92            if (m_testObject)
     93                pluginTest()->NPN_ReleaseObject(m_testObject);
     94        }
     95
    4196        bool hasMethod(NPIdentifier methodName)
    4297        {
    43             return methodName == pluginTest()->NPN_GetStringIdentifier("testRemoveProperty");
     98            if (identifierIs(methodName, "testRemoveProperty"))
     99                return true;
     100
     101            return false;
    44102        }
    45103
    46104        bool invoke(NPIdentifier methodName, const NPVariant* arguments, uint32_t argumentCount, NPVariant* result)
    47105        {
    48             assert(methodName == pluginTest()->NPN_GetStringIdentifier("testRemoveProperty"));
     106            assert(identifierIs(methodName, "testRemoveProperty"));
    49107
    50108            if (argumentCount != 2)
     
    73131            return true;
    74132        }
     133
     134        bool hasProperty(NPIdentifier propertyName)
     135        {
     136            if (identifierIs(propertyName, "testObject"))
     137                return true;
     138
     139            return false;
     140        }
     141
     142        bool getProperty(NPIdentifier propertyName, NPVariant* result)
     143        {
     144            assert(identifierIs(propertyName, "testObject"));
     145
     146            if (!m_testObject)
     147                m_testObject = TestObject::create(pluginTest());
     148
     149            OBJECT_TO_NPVARIANT(pluginTest()->NPN_RetainObject(m_testObject), *result);
     150            return true;
     151        }
     152
     153    private:
     154        NPObject* m_testObject;
    75155    };
    76156   
     
    80160            return NPERR_GENERIC_ERROR;
    81161       
    82         *(NPObject**)value = TestObject::create(this);
     162        *(NPObject**)value = PluginObject::create(this);
    83163       
    84164        return NPERR_NO_ERROR;
Note: See TracChangeset for help on using the changeset viewer.