Changeset 147956 in webkit


Ignore:
Timestamp:
Apr 8, 2013 3:05:24 PM (11 years ago)
Author:
andersca@apple.com
Message:

Call Netscape Plugin's toString() and valueOf() instead of providing default implementation
https://bugs.webkit.org/show_bug.cgi?id=113139

Patch by Arunprasad Rajkumar <arunprasadr@nds.com> on 2013-04-08
Reviewed by Anders Carlsson.

Source/WebCore:

Tests: plugins/npruntime/tostring.html

plugins/npruntime/valueof.html

  • bridge/c/c_instance.cpp:

(JSC::Bindings::CInstance::~CInstance):
(JSC::Bindings::CInstance::invokeMethod):
(JSC::Bindings::CInstance::invokeDefaultMethod):
(Bindings):
(JSC::Bindings::CInstance::invokeConstruct):
(JSC::Bindings::CInstance::stringValue):
(JSC::Bindings::CInstance::booleanValue):
(JSC::Bindings::CInstance::valueOf):
(JSC::Bindings::CInstance::toJSPrimitive):

  • bridge/c/c_instance.h:

(CInstance):

Tools:

  • DumpRenderTree/DumpRenderTree.vcxproj/TestNetscapePlugin/TestNetscapePlugin.vcxproj:
  • DumpRenderTree/DumpRenderTree.vcxproj/TestNetscapePlugin/TestNetscapePlugin.vcxproj.filters:
  • DumpRenderTree/TestNetscapePlugIn/CMakeLists.txt:
  • DumpRenderTree/TestNetscapePlugIn/Tests/ToStringAndValueOfObject.cpp: Added.

(ToStringAndValueOfObject):
(ToStringAndValueOfObject::ToStringAndValueOfObject):
(ScriptableObject):
(ToStringAndValueOfObject::ScriptableObject::hasMethod):
(ToStringAndValueOfObject::ScriptableObject::invoke):
(ToStringAndValueOfObject::ScriptableObject::pluginTest):
(ToStringAndValueOfObject::NPP_GetValue):

  • DumpRenderTree/TestNetscapePlugIn/win/TestNetscapePlugin.vcproj:
  • DumpRenderTree/qt/TestNetscapePlugin/TestNetscapePlugin.pro:
  • GNUmakefile.am:

LayoutTests:

  • platform/qt-mac/TestExpectations:
  • platform/wk2/TestExpectations:
  • plugins/npruntime/tostring-expected.txt: Added.
  • plugins/npruntime/tostring.html: Added.
  • plugins/npruntime/valueof-expected.txt: Added.
  • plugins/npruntime/valueof.html: Added.
Location:
trunk
Files:
5 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r147955 r147956  
     12013-04-08  Arunprasad Rajkumar  <arunprasadr@nds.com>
     2
     3        Call Netscape Plugin's toString() and valueOf() instead of providing default implementation
     4        https://bugs.webkit.org/show_bug.cgi?id=113139
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * platform/qt-mac/TestExpectations:
     9        * platform/wk2/TestExpectations:
     10        * plugins/npruntime/tostring-expected.txt: Added.
     11        * plugins/npruntime/tostring.html: Added.
     12        * plugins/npruntime/valueof-expected.txt: Added.
     13        * plugins/npruntime/valueof.html: Added.
     14
    1152013-04-08  Tim Horton  <timothy_horton@apple.com>
    216
  • trunk/LayoutTests/platform/qt-mac/TestExpectations

    r147522 r147956  
    26412641plugins/npruntime/round-trip-npobject.html
    26422642plugins/npruntime/throw-exception.html
     2643plugins/npruntime/tostring.html
     2644plugins/npruntime/valueof.html
    26432645plugins/object-embed-plugin-scripting.html
    26442646plugins/get-url-notify-with-url-that-fails-to-load.html
  • trunk/LayoutTests/platform/wk2/TestExpectations

    r147901 r147956  
    338338# https://bugs.webkit.org/show_bug.cgi?id=105266
    339339plugins/npruntime/embed-property-iframe-equality.html
     340
     341# [WK2] Call Netscape Plugin's toString() and valueOf() instead of providing default implementation
     342# https://bugs.webkit.org/show_bug.cgi?id=114213
     343plugins/npruntime/tostring.html
     344plugins/npruntime/valueof.html
    340345
    341346webkit.org/b/105952 fast/loader/submit-form-while-parsing-2.html [ Pass Failure ]
  • trunk/Source/WebCore/ChangeLog

    r147955 r147956  
     12013-04-08  Arunprasad Rajkumar  <arunprasadr@nds.com>
     2
     3        Call Netscape Plugin's toString() and valueOf() instead of providing default implementation
     4        https://bugs.webkit.org/show_bug.cgi?id=113139
     5
     6        Reviewed by Anders Carlsson.
     7
     8        Tests: plugins/npruntime/tostring.html
     9               plugins/npruntime/valueof.html
     10
     11        * bridge/c/c_instance.cpp:
     12        (JSC::Bindings::CInstance::~CInstance):
     13        (JSC::Bindings::CInstance::invokeMethod):
     14        (JSC::Bindings::CInstance::invokeDefaultMethod):
     15        (Bindings):
     16        (JSC::Bindings::CInstance::invokeConstruct):
     17        (JSC::Bindings::CInstance::stringValue):
     18        (JSC::Bindings::CInstance::booleanValue):
     19        (JSC::Bindings::CInstance::valueOf):
     20        (JSC::Bindings::CInstance::toJSPrimitive):
     21        * bridge/c/c_instance.h:
     22        (CInstance):
     23
    1242013-04-08  Tim Horton  <timothy_horton@apple.com>
    225
  • trunk/Source/WebCore/bridge/c/c_instance.cpp

    r129969 r147956  
    2121 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    2222 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
     23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2424 */
    2525
     
    8686}
    8787
    88 CInstance::~CInstance() 
     88CInstance::~CInstance()
    8989{
    9090    _NPN_ReleaseObject(_object);
     
    181181        moveGlobalExceptionToExecState(exec);
    182182    }
    183    
     183
    184184    if (!retval)
    185         throwError(exec, createError(exec, "Error calling method on NPObject."));
     185        throwError(exec, createError(exec, ASCIILiteral("Error calling method on NPObject.")));
    186186
    187187    for (i = 0; i < count; i++)
     
    216216        moveGlobalExceptionToExecState(exec);
    217217    }
    218    
     218
    219219    if (!retval)
    220         throwError(exec, createError(exec, "Error calling method on NPObject."));
     220        throwError(exec, createError(exec, ASCIILiteral("Error calling method on NPObject.")));
    221221
    222222    for (i = 0; i < count; i++)
     
    232232    return _object->_class->construct;
    233233}
    234    
     234
    235235JSValue CInstance::invokeConstruct(ExecState* exec, const ArgList& args)
    236236{
     
    255255        moveGlobalExceptionToExecState(exec);
    256256    }
    257    
     257
    258258    if (!retval)
    259         throwError(exec, createError(exec, "Error calling method on NPObject."));
     259        throwError(exec, createError(exec, ASCIILiteral("Error calling method on NPObject.")));
    260260
    261261    for (i = 0; i < count; i++)
     
    278278JSValue CInstance::stringValue(ExecState* exec) const
    279279{
     280    JSValue value;
     281    if (toJSPrimitive(exec, "toString", value))
     282        return value;
     283
     284    // Fallback to default implementation.
    280285    char buf[1024];
    281286    snprintf(buf, sizeof(buf), "NPObject %p, NPClass %p", _object, _object->_class);
     
    291296JSValue CInstance::booleanValue() const
    292297{
    293     // FIXME: Implement something sensible.
    294     return jsBoolean(false);
    295 }
    296 
    297 JSValue CInstance::valueOf(ExecState* exec) const
    298 {
     298    // As per ECMA 9.2.
     299    return jsBoolean(getObject());
     300}
     301
     302JSValue CInstance::valueOf(ExecState* exec) const
     303{
     304    JSValue value;
     305    if (toJSPrimitive(exec, "valueOf", value))
     306        return value;
     307
     308    // Fallback to default implementation.
    299309    return stringValue(exec);
     310}
     311
     312bool CInstance::toJSPrimitive(ExecState* exec, const char* name, JSValue& resultValue) const
     313{
     314    NPIdentifier ident = _NPN_GetStringIdentifier(name);
     315    if (!_object->_class->hasMethod(_object, ident))
     316        return false;
     317
     318    // Invoke the 'C' method.
     319    bool retval = true;
     320    NPVariant resultVariant;
     321    VOID_TO_NPVARIANT(resultVariant);
     322
     323    {
     324        JSLock::DropAllLocks dropAllLocks(exec);
     325        ASSERT(globalExceptionString().isNull());
     326        retval = _object->_class->invoke(_object, ident, 0, 0, &resultVariant);
     327        moveGlobalExceptionToExecState(exec);
     328    }
     329
     330    if (!retval)
     331        throwError(exec, createError(exec, ASCIILiteral("Error calling method on NPObject.")));
     332
     333    resultValue = convertNPVariantToValue(exec, &resultVariant, m_rootObject.get());
     334    _NPN_ReleaseVariantValue(&resultVariant);
     335    return true;
    300336}
    301337
  • trunk/Source/WebCore/bridge/c/c_instance.h

    r127191 r147956  
    2121 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    2222 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
     23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2424 */
    2525
     
    7979
    8080    virtual RuntimeObject* newRuntimeObject(ExecState*);
     81    bool toJSPrimitive(ExecState*, const char*, JSValue&) const;
     82
    8183
    8284    mutable CClass *_class;
  • trunk/Tools/ChangeLog

    r147946 r147956  
     12013-04-08  Arunprasad Rajkumar  <arunprasadr@nds.com>
     2
     3        Call Netscape Plugin's toString() and valueOf() instead of providing default implementation
     4        https://bugs.webkit.org/show_bug.cgi?id=113139
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * DumpRenderTree/DumpRenderTree.vcxproj/TestNetscapePlugin/TestNetscapePlugin.vcxproj:
     9        * DumpRenderTree/DumpRenderTree.vcxproj/TestNetscapePlugin/TestNetscapePlugin.vcxproj.filters:
     10        * DumpRenderTree/TestNetscapePlugIn/CMakeLists.txt:
     11        * DumpRenderTree/TestNetscapePlugIn/Tests/ToStringAndValueOfObject.cpp: Added.
     12        (ToStringAndValueOfObject):
     13        (ToStringAndValueOfObject::ToStringAndValueOfObject):
     14        (ScriptableObject):
     15        (ToStringAndValueOfObject::ScriptableObject::hasMethod):
     16        (ToStringAndValueOfObject::ScriptableObject::invoke):
     17        (ToStringAndValueOfObject::ScriptableObject::pluginTest):
     18        (ToStringAndValueOfObject::NPP_GetValue):
     19        * DumpRenderTree/TestNetscapePlugIn/win/TestNetscapePlugin.vcproj:
     20        * DumpRenderTree/qt/TestNetscapePlugin/TestNetscapePlugin.pro:
     21        * GNUmakefile.am:
     22
    1232013-04-08  Manuel Rego Casasnovas  <rego@igalia.com>
    224
  • trunk/Tools/DumpRenderTree/DumpRenderTree.vcxproj/TestNetscapePlugin/TestNetscapePlugin.vcxproj

    r146530 r147956  
    5151    <ClCompile Include="..\..\TestNetscapePlugIn\Tests\PluginScriptableObjectOverridesAllProperties.cpp" />
    5252    <ClCompile Include="..\..\TestNetscapePlugIn\Tests\PrivateBrowsing.cpp" />
     53    <ClCompile Include="..\..\TestNetscapePlugIn\Tests\ToStringAndValueOfObject.cpp" />   
    5354    <ClCompile Include="..\..\TestNetscapePlugIn\Tests\win\CallJSThatDestroysPlugin.cpp" />
    5455    <ClCompile Include="..\..\TestNetscapePlugIn\Tests\win\DrawsGradient.cpp" />
  • trunk/Tools/DumpRenderTree/DumpRenderTree.vcxproj/TestNetscapePlugin/TestNetscapePlugin.vcxproj.filters

    r142954 r147956  
    6969      <Filter>Tests</Filter>
    7070    </ClCompile>
     71    <ClCompile Include="..\..\TestNetscapePlugIn\Tests\ToStringAndValueOfObject.cpp">
     72      <Filter>Tests</Filter>
     73    </ClCompile>
    7174    <ClCompile Include="..\..\TestNetscapePlugIn\Tests\win\CallJSThatDestroysPlugin.cpp">
    7275      <Filter>Tests\win</Filter>
  • trunk/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj

    r144657 r147956  
    4242                1A31EB3813466AC100017372 /* ConvertPoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A31EB3713466AC100017372 /* ConvertPoint.cpp */; };
    4343                1A3E28AA1311D73B00501349 /* GetURLWithJavaScriptURLDestroyingPlugin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3E28A91311D73B00501349 /* GetURLWithJavaScriptURLDestroyingPlugin.cpp */; };
     44                1A4CCD4F171375A300981040 /* ToStringAndValueOfObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A4CCD4E171375A300981040 /* ToStringAndValueOfObject.cpp */; };
    4445                1A5CC1F5137DD2EC00A5D7E7 /* GetURLWithJavaScriptURL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5CC1F3137DD2EC00A5D7E7 /* GetURLWithJavaScriptURL.cpp */; };
    4546                1A66C35114576A920099A115 /* ContentsScaleFactor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A66C34F14576A920099A115 /* ContentsScaleFactor.cpp */; };
     
    256257                1A31EB3713466AC100017372 /* ConvertPoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConvertPoint.cpp; sourceTree = "<group>"; };
    257258                1A3E28A91311D73B00501349 /* GetURLWithJavaScriptURLDestroyingPlugin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GetURLWithJavaScriptURLDestroyingPlugin.cpp; sourceTree = "<group>"; };
     259                1A4CCD4E171375A300981040 /* ToStringAndValueOfObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ToStringAndValueOfObject.cpp; sourceTree = "<group>"; };
    258260                1A5CC1F3137DD2EC00A5D7E7 /* GetURLWithJavaScriptURL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GetURLWithJavaScriptURL.cpp; sourceTree = "<group>"; };
    259261                1A66C34F14576A920099A115 /* ContentsScaleFactor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ContentsScaleFactor.cpp; sourceTree = "<group>"; };
     
    586588                                1A1E4296141141C400388758 /* PrivateBrowsing.cpp */,
    587589                                5106803D15CC7B10001A8A23 /* SlowNPPNew.cpp */,
     590                                1A4CCD4E171375A300981040 /* ToStringAndValueOfObject.cpp */,
    588591                        );
    589592                        path = Tests;
     
    914917                        files = (
    915918                                1A66C35114576A920099A115 /* ContentsScaleFactor.cpp in Sources */,
     919                                1A4CCD4F171375A300981040 /* ToStringAndValueOfObject.cpp in Sources */,
    916920                                1A31EB3813466AC100017372 /* ConvertPoint.cpp in Sources */,
    917921                                1A215BE711F27658008AD0F5 /* DocumentOpenInDestroyStream.cpp in Sources */,
  • trunk/Tools/DumpRenderTree/TestNetscapePlugIn/CMakeLists.txt

    r144236 r147956  
    2626    ${WEBKIT_TESTNETSCAPEPLUGIN_DIR}/Tests/PluginScriptableObjectOverridesAllProperties.cpp
    2727    ${WEBKIT_TESTNETSCAPEPLUGIN_DIR}/Tests/PrivateBrowsing.cpp
     28    ${WEBKIT_TESTNETSCAPEPLUGIN_DIR}/Tests/ToStringAndValueOfObject.cpp
    2829    ${WEBKIT_TESTNETSCAPEPLUGIN_DIR}/Tests/x11/CallInvalidateRectWithNullNPPArgument.cpp
    2930)
  • trunk/Tools/DumpRenderTree/TestNetscapePlugIn/win/TestNetscapePlugin.vcproj

    r142495 r147956  
    462462                                >
    463463                        </File>
     464                        <File
     465                                RelativePath="..\Tests\ToStringAndValueOfObject.cpp"
     466                                >
     467                        </File>
    464468                        <Filter
    465469                                Name="win"
  • trunk/Tools/DumpRenderTree/qt/TestNetscapePlugin/TestNetscapePlugin.pro

    r132713 r147956  
    3232    Tests/PluginScriptableNPObjectInvokeDefault.cpp \
    3333    Tests/PluginScriptableObjectOverridesAllProperties.cpp \
    34     Tests/PrivateBrowsing.cpp
     34    Tests/PrivateBrowsing.cpp \
     35    Tests/ToStringAndValueOfObject.cpp
    3536
    3637WEBKIT += webcore # For NPAPI headers
  • trunk/Tools/GNUmakefile.am

    r147137 r147956  
    281281        Tools/DumpRenderTree/TestNetscapePlugIn/Tests/PluginScriptableNPObjectInvokeDefault.cpp \
    282282        Tools/DumpRenderTree/TestNetscapePlugIn/Tests/PrivateBrowsing.cpp \
     283        Tools/DumpRenderTree/TestNetscapePlugIn/Tests/ToStringAndValueOfObject.cpp \   
    283284        Tools/DumpRenderTree/TestNetscapePlugIn/Tests/x11/CallInvalidateRectWithNullNPPArgument.cpp \
    284285        Tools/DumpRenderTree/TestNetscapePlugIn/PluginTest.cpp \
Note: See TracChangeset for help on using the changeset viewer.