Diff
Modified: trunk/LayoutTests/ChangeLog (147955 => 147956)
--- trunk/LayoutTests/ChangeLog 2013-04-08 21:43:15 UTC (rev 147955)
+++ trunk/LayoutTests/ChangeLog 2013-04-08 22:05:24 UTC (rev 147956)
@@ -1,3 +1,17 @@
+2013-04-08 Arunprasad Rajkumar <[email protected]>
+
+ Call Netscape Plugin's toString() and valueOf() instead of providing default implementation
+ https://bugs.webkit.org/show_bug.cgi?id=113139
+
+ Reviewed by Anders Carlsson.
+
+ * 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.
+
2013-04-08 Tim Horton <[email protected]>
REGRESSION (r138858): Crash in WebCore::FrameLoader::~FrameLoader() when opening page in a background tab
Modified: trunk/LayoutTests/platform/qt-mac/TestExpectations (147955 => 147956)
--- trunk/LayoutTests/platform/qt-mac/TestExpectations 2013-04-08 21:43:15 UTC (rev 147955)
+++ trunk/LayoutTests/platform/qt-mac/TestExpectations 2013-04-08 22:05:24 UTC (rev 147956)
@@ -2640,6 +2640,8 @@
plugins/npruntime/remove-property.html
plugins/npruntime/round-trip-npobject.html
plugins/npruntime/throw-exception.html
+plugins/npruntime/tostring.html
+plugins/npruntime/valueof.html
plugins/object-embed-plugin-scripting.html
plugins/get-url-notify-with-url-that-fails-to-load.html
plugins/get-url-with-_javascript_-url.html
Modified: trunk/LayoutTests/platform/wk2/TestExpectations (147955 => 147956)
--- trunk/LayoutTests/platform/wk2/TestExpectations 2013-04-08 21:43:15 UTC (rev 147955)
+++ trunk/LayoutTests/platform/wk2/TestExpectations 2013-04-08 22:05:24 UTC (rev 147956)
@@ -338,6 +338,11 @@
# https://bugs.webkit.org/show_bug.cgi?id=105266
plugins/npruntime/embed-property-iframe-equality.html
+# [WK2] Call Netscape Plugin's toString() and valueOf() instead of providing default implementation
+# https://bugs.webkit.org/show_bug.cgi?id=114213
+plugins/npruntime/tostring.html
+plugins/npruntime/valueof.html
+
webkit.org/b/105952 fast/loader/submit-form-while-parsing-2.html [ Pass Failure ]
# [WebKit2] WKTR's output for dumpResourceLoadCallbacks is inconsistent with DRT
Added: trunk/LayoutTests/plugins/npruntime/tostring-expected.txt (0 => 147956)
--- trunk/LayoutTests/plugins/npruntime/tostring-expected.txt (rev 0)
+++ trunk/LayoutTests/plugins/npruntime/tostring-expected.txt 2013-04-08 22:05:24 UTC (rev 147956)
@@ -0,0 +1,11 @@
+This tests that toString() works correctly on NPObject.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS plugin.toString() is "TestObject"
+PASS [plugin, ''].join('') is "TestObject"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/plugins/npruntime/tostring.html (0 => 147956)
--- trunk/LayoutTests/plugins/npruntime/tostring.html (rev 0)
+++ trunk/LayoutTests/plugins/npruntime/tostring.html 2013-04-08 22:05:24 UTC (rev 147956)
@@ -0,0 +1,25 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+ description("This tests that toString() works correctly on NPObject.");
+
+ plugin = document.createElement("embed");
+ plugin.type = "application/x-webkit-test-netscape";
+ plugin.setAttribute('test', 'to-string-and-value-of-object');
+ document.body.appendChild(plugin);
+
+ shouldBeEqualToString("plugin.toString()", "TestObject");
+ // Normal plugin.testObject + "" will call valueOf,
+ // do some tricks to make a call to implicit toString.
+ shouldBeEqualToString("[plugin, ''].join('')", "TestObject");
+ var successfullyParsed = true;
+</script>
+<script src=""
+</body>
+</html>
Added: trunk/LayoutTests/plugins/npruntime/valueof-expected.txt (0 => 147956)
--- trunk/LayoutTests/plugins/npruntime/valueof-expected.txt (rev 0)
+++ trunk/LayoutTests/plugins/npruntime/valueof-expected.txt 2013-04-08 22:05:24 UTC (rev 147956)
@@ -0,0 +1,11 @@
+This tests that valueOf() works correctly on NPObject.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS plugin.valueOf() is 123456789
+PASS plugin == 123456789 is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/plugins/npruntime/valueof.html (0 => 147956)
--- trunk/LayoutTests/plugins/npruntime/valueof.html (rev 0)
+++ trunk/LayoutTests/plugins/npruntime/valueof.html 2013-04-08 22:05:24 UTC (rev 147956)
@@ -0,0 +1,23 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+ description("This tests that valueOf() works correctly on NPObject.");
+
+ plugin = document.createElement("embed");
+ plugin.type = "application/x-webkit-test-netscape";
+ plugin.setAttribute('test', 'to-string-and-value-of-object');
+ document.body.appendChild(plugin);
+
+ shouldBe("plugin.valueOf()", "123456789");
+ shouldBeTrue("plugin == 123456789");
+ var successfullyParsed = true;
+</script>
+<script src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (147955 => 147956)
--- trunk/Source/WebCore/ChangeLog 2013-04-08 21:43:15 UTC (rev 147955)
+++ trunk/Source/WebCore/ChangeLog 2013-04-08 22:05:24 UTC (rev 147956)
@@ -1,3 +1,26 @@
+2013-04-08 Arunprasad Rajkumar <[email protected]>
+
+ Call Netscape Plugin's toString() and valueOf() instead of providing default implementation
+ https://bugs.webkit.org/show_bug.cgi?id=113139
+
+ Reviewed by Anders Carlsson.
+
+ 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):
+
2013-04-08 Tim Horton <[email protected]>
REGRESSION (r138858): Crash in WebCore::FrameLoader::~FrameLoader() when opening page in a background tab
Modified: trunk/Source/WebCore/bridge/c/c_instance.cpp (147955 => 147956)
--- trunk/Source/WebCore/bridge/c/c_instance.cpp 2013-04-08 21:43:15 UTC (rev 147955)
+++ trunk/Source/WebCore/bridge/c/c_instance.cpp 2013-04-08 22:05:24 UTC (rev 147956)
@@ -20,7 +20,7 @@
* 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.
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
@@ -85,7 +85,7 @@
_class = 0;
}
-CInstance::~CInstance()
+CInstance::~CInstance()
{
_NPN_ReleaseObject(_object);
}
@@ -180,9 +180,9 @@
retval = _object->_class->invoke(_object, ident, cArgs.data(), count, &resultVariant);
moveGlobalExceptionToExecState(exec);
}
-
+
if (!retval)
- throwError(exec, createError(exec, "Error calling method on NPObject."));
+ throwError(exec, createError(exec, ASCIILiteral("Error calling method on NPObject.")));
for (i = 0; i < count; i++)
_NPN_ReleaseVariantValue(&cArgs[i]);
@@ -215,9 +215,9 @@
retval = _object->_class->invokeDefault(_object, cArgs.data(), count, &resultVariant);
moveGlobalExceptionToExecState(exec);
}
-
+
if (!retval)
- throwError(exec, createError(exec, "Error calling method on NPObject."));
+ throwError(exec, createError(exec, ASCIILiteral("Error calling method on NPObject.")));
for (i = 0; i < count; i++)
_NPN_ReleaseVariantValue(&cArgs[i]);
@@ -231,7 +231,7 @@
{
return _object->_class->construct;
}
-
+
JSValue CInstance::invokeConstruct(ExecState* exec, const ArgList& args)
{
if (!_object->_class->construct)
@@ -254,9 +254,9 @@
retval = _object->_class->construct(_object, cArgs.data(), count, &resultVariant);
moveGlobalExceptionToExecState(exec);
}
-
+
if (!retval)
- throwError(exec, createError(exec, "Error calling method on NPObject."));
+ throwError(exec, createError(exec, ASCIILiteral("Error calling method on NPObject.")));
for (i = 0; i < count; i++)
_NPN_ReleaseVariantValue(&cArgs[i]);
@@ -277,6 +277,11 @@
JSValue CInstance::stringValue(ExecState* exec) const
{
+ JSValue value;
+ if (toJSPrimitive(exec, "toString", value))
+ return value;
+
+ // Fallback to default implementation.
char buf[1024];
snprintf(buf, sizeof(buf), "NPObject %p, NPClass %p", _object, _object->_class);
return jsString(exec, buf);
@@ -290,15 +295,46 @@
JSValue CInstance::booleanValue() const
{
- // FIXME: Implement something sensible.
- return jsBoolean(false);
+ // As per ECMA 9.2.
+ return jsBoolean(getObject());
}
-JSValue CInstance::valueOf(ExecState* exec) const
+JSValue CInstance::valueOf(ExecState* exec) const
{
+ JSValue value;
+ if (toJSPrimitive(exec, "valueOf", value))
+ return value;
+
+ // Fallback to default implementation.
return stringValue(exec);
}
+bool CInstance::toJSPrimitive(ExecState* exec, const char* name, JSValue& resultValue) const
+{
+ NPIdentifier ident = _NPN_GetStringIdentifier(name);
+ if (!_object->_class->hasMethod(_object, ident))
+ return false;
+
+ // Invoke the 'C' method.
+ bool retval = true;
+ NPVariant resultVariant;
+ VOID_TO_NPVARIANT(resultVariant);
+
+ {
+ JSLock::DropAllLocks dropAllLocks(exec);
+ ASSERT(globalExceptionString().isNull());
+ retval = _object->_class->invoke(_object, ident, 0, 0, &resultVariant);
+ moveGlobalExceptionToExecState(exec);
+ }
+
+ if (!retval)
+ throwError(exec, createError(exec, ASCIILiteral("Error calling method on NPObject.")));
+
+ resultValue = convertNPVariantToValue(exec, &resultVariant, m_rootObject.get());
+ _NPN_ReleaseVariantValue(&resultVariant);
+ return true;
+}
+
void CInstance::getPropertyNames(ExecState* exec, PropertyNameArray& nameArray)
{
if (!NP_CLASS_STRUCT_VERSION_HAS_ENUM(_object->_class) || !_object->_class->enumerate)
Modified: trunk/Source/WebCore/bridge/c/c_instance.h (147955 => 147956)
--- trunk/Source/WebCore/bridge/c/c_instance.h 2013-04-08 21:43:15 UTC (rev 147955)
+++ trunk/Source/WebCore/bridge/c/c_instance.h 2013-04-08 22:05:24 UTC (rev 147956)
@@ -20,7 +20,7 @@
* 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.
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef BINDINGS_C_INSTANCE_H_
@@ -78,7 +78,9 @@
CInstance(NPObject*, PassRefPtr<RootObject>);
virtual RuntimeObject* newRuntimeObject(ExecState*);
+ bool toJSPrimitive(ExecState*, const char*, JSValue&) const;
+
mutable CClass *_class;
NPObject *_object;
};
Modified: trunk/Tools/ChangeLog (147955 => 147956)
--- trunk/Tools/ChangeLog 2013-04-08 21:43:15 UTC (rev 147955)
+++ trunk/Tools/ChangeLog 2013-04-08 22:05:24 UTC (rev 147956)
@@ -1,3 +1,25 @@
+2013-04-08 Arunprasad Rajkumar <[email protected]>
+
+ Call Netscape Plugin's toString() and valueOf() instead of providing default implementation
+ https://bugs.webkit.org/show_bug.cgi?id=113139
+
+ Reviewed by Anders Carlsson.
+
+ * 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:
+
2013-04-08 Manuel Rego Casasnovas <[email protected]>
[GTK] Bump gnome-themes-standard to 3.6.0
Modified: trunk/Tools/DumpRenderTree/DumpRenderTree.vcxproj/TestNetscapePlugin/TestNetscapePlugin.vcxproj (147955 => 147956)
--- trunk/Tools/DumpRenderTree/DumpRenderTree.vcxproj/TestNetscapePlugin/TestNetscapePlugin.vcxproj 2013-04-08 21:43:15 UTC (rev 147955)
+++ trunk/Tools/DumpRenderTree/DumpRenderTree.vcxproj/TestNetscapePlugin/TestNetscapePlugin.vcxproj 2013-04-08 22:05:24 UTC (rev 147956)
@@ -50,6 +50,7 @@
<ClCompile Include="..\..\TestNetscapePlugIn\Tests\PluginScriptableNPObjectInvokeDefault.cpp" />
<ClCompile Include="..\..\TestNetscapePlugIn\Tests\PluginScriptableObjectOverridesAllProperties.cpp" />
<ClCompile Include="..\..\TestNetscapePlugIn\Tests\PrivateBrowsing.cpp" />
+ <ClCompile Include="..\..\TestNetscapePlugIn\Tests\ToStringAndValueOfObject.cpp" />
<ClCompile Include="..\..\TestNetscapePlugIn\Tests\win\CallJSThatDestroysPlugin.cpp" />
<ClCompile Include="..\..\TestNetscapePlugIn\Tests\win\DrawsGradient.cpp" />
<ClCompile Include="..\..\TestNetscapePlugIn\Tests\win\DumpWindowRect.cpp" />
@@ -144,4 +145,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
\ No newline at end of file
+</Project>
Modified: trunk/Tools/DumpRenderTree/DumpRenderTree.vcxproj/TestNetscapePlugin/TestNetscapePlugin.vcxproj.filters (147955 => 147956)
--- trunk/Tools/DumpRenderTree/DumpRenderTree.vcxproj/TestNetscapePlugin/TestNetscapePlugin.vcxproj.filters 2013-04-08 21:43:15 UTC (rev 147955)
+++ trunk/Tools/DumpRenderTree/DumpRenderTree.vcxproj/TestNetscapePlugin/TestNetscapePlugin.vcxproj.filters 2013-04-08 22:05:24 UTC (rev 147956)
@@ -68,6 +68,9 @@
<ClCompile Include="..\..\TestNetscapePlugIn\Tests\PrivateBrowsing.cpp">
<Filter>Tests</Filter>
</ClCompile>
+ <ClCompile Include="..\..\TestNetscapePlugIn\Tests\ToStringAndValueOfObject.cpp">
+ <Filter>Tests</Filter>
+ </ClCompile>
<ClCompile Include="..\..\TestNetscapePlugIn\Tests\win\CallJSThatDestroysPlugin.cpp">
<Filter>Tests\win</Filter>
</ClCompile>
@@ -133,4 +136,4 @@
<Filter>Resources</Filter>
</ResourceCompile>
</ItemGroup>
-</Project>
\ No newline at end of file
+</Project>
Modified: trunk/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj (147955 => 147956)
--- trunk/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj 2013-04-08 21:43:15 UTC (rev 147955)
+++ trunk/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj 2013-04-08 22:05:24 UTC (rev 147956)
@@ -41,6 +41,7 @@
1A24BAA9120734EE00FBB059 /* NPRuntimeObjectFromDestroyedPlugin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A24BAA8120734EE00FBB059 /* NPRuntimeObjectFromDestroyedPlugin.cpp */; };
1A31EB3813466AC100017372 /* ConvertPoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A31EB3713466AC100017372 /* ConvertPoint.cpp */; };
1A3E28AA1311D73B00501349 /* GetURLWithJavaScriptURLDestroyingPlugin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3E28A91311D73B00501349 /* GetURLWithJavaScriptURLDestroyingPlugin.cpp */; };
+ 1A4CCD4F171375A300981040 /* ToStringAndValueOfObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A4CCD4E171375A300981040 /* ToStringAndValueOfObject.cpp */; };
1A5CC1F5137DD2EC00A5D7E7 /* GetURLWithJavaScriptURL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5CC1F3137DD2EC00A5D7E7 /* GetURLWithJavaScriptURL.cpp */; };
1A66C35114576A920099A115 /* ContentsScaleFactor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A66C34F14576A920099A115 /* ContentsScaleFactor.cpp */; };
1A8F02E80BB9B4EC008CFA34 /* TestObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8F024C0BB9B056008CFA34 /* TestObject.h */; };
@@ -255,6 +256,7 @@
1A24BAA8120734EE00FBB059 /* NPRuntimeObjectFromDestroyedPlugin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NPRuntimeObjectFromDestroyedPlugin.cpp; sourceTree = "<group>"; };
1A31EB3713466AC100017372 /* ConvertPoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConvertPoint.cpp; sourceTree = "<group>"; };
1A3E28A91311D73B00501349 /* GetURLWithJavaScriptURLDestroyingPlugin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GetURLWithJavaScriptURLDestroyingPlugin.cpp; sourceTree = "<group>"; };
+ 1A4CCD4E171375A300981040 /* ToStringAndValueOfObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ToStringAndValueOfObject.cpp; sourceTree = "<group>"; };
1A5CC1F3137DD2EC00A5D7E7 /* GetURLWithJavaScriptURL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GetURLWithJavaScriptURL.cpp; sourceTree = "<group>"; };
1A66C34F14576A920099A115 /* ContentsScaleFactor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ContentsScaleFactor.cpp; sourceTree = "<group>"; };
1A8F024C0BB9B056008CFA34 /* TestObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestObject.h; sourceTree = "<group>"; };
@@ -585,6 +587,7 @@
515F429B15C07872007C8F90 /* PluginScriptableObjectOverridesAllProperties.cpp */,
1A1E4296141141C400388758 /* PrivateBrowsing.cpp */,
5106803D15CC7B10001A8A23 /* SlowNPPNew.cpp */,
+ 1A4CCD4E171375A300981040 /* ToStringAndValueOfObject.cpp */,
);
path = Tests;
sourceTree = "<group>";
@@ -913,6 +916,7 @@
buildActionMask = 2147483647;
files = (
1A66C35114576A920099A115 /* ContentsScaleFactor.cpp in Sources */,
+ 1A4CCD4F171375A300981040 /* ToStringAndValueOfObject.cpp in Sources */,
1A31EB3813466AC100017372 /* ConvertPoint.cpp in Sources */,
1A215BE711F27658008AD0F5 /* DocumentOpenInDestroyStream.cpp in Sources */,
C0E720751281C828004EF533 /* EvaluateJSAfterRemovingPluginElement.cpp in Sources */,
Modified: trunk/Tools/DumpRenderTree/TestNetscapePlugIn/CMakeLists.txt (147955 => 147956)
--- trunk/Tools/DumpRenderTree/TestNetscapePlugIn/CMakeLists.txt 2013-04-08 21:43:15 UTC (rev 147955)
+++ trunk/Tools/DumpRenderTree/TestNetscapePlugIn/CMakeLists.txt 2013-04-08 22:05:24 UTC (rev 147956)
@@ -25,6 +25,7 @@
${WEBKIT_TESTNETSCAPEPLUGIN_DIR}/Tests/PluginScriptableNPObjectInvokeDefault.cpp
${WEBKIT_TESTNETSCAPEPLUGIN_DIR}/Tests/PluginScriptableObjectOverridesAllProperties.cpp
${WEBKIT_TESTNETSCAPEPLUGIN_DIR}/Tests/PrivateBrowsing.cpp
+ ${WEBKIT_TESTNETSCAPEPLUGIN_DIR}/Tests/ToStringAndValueOfObject.cpp
${WEBKIT_TESTNETSCAPEPLUGIN_DIR}/Tests/x11/CallInvalidateRectWithNullNPPArgument.cpp
)
Added: trunk/Tools/DumpRenderTree/TestNetscapePlugIn/Tests/ToStringAndValueOfObject.cpp (0 => 147956)
--- trunk/Tools/DumpRenderTree/TestNetscapePlugIn/Tests/ToStringAndValueOfObject.cpp (rev 0)
+++ trunk/Tools/DumpRenderTree/TestNetscapePlugIn/Tests/ToStringAndValueOfObject.cpp 2013-04-08 22:05:24 UTC (rev 147956)
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2013 Cisco Systems, 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"
+
+#include <string.h>
+
+using namespace std;
+
+class ToStringAndValueOfObject : public PluginTest {
+public:
+ ToStringAndValueOfObject(NPP npp, const string& identifier)
+ : PluginTest(npp, identifier)
+ {
+ }
+
+private:
+ class ScriptableObject : public Object<ScriptableObject> {
+ public:
+ bool hasMethod(NPIdentifier methodName)
+ {
+ return identifierIs(methodName, "toString")
+ || identifierIs(methodName, "valueOf");
+ }
+
+ bool invoke(NPIdentifier methodName, const NPVariant*, uint32_t, NPVariant* result)
+ {
+ if (identifierIs(methodName, "toString")) {
+ // Return classname as string.
+ char* className = static_cast<char*>(pluginTest()->NPN_MemAlloc(11));
+ strcpy(className, "TestObject");
+ STRINGZ_TO_NPVARIANT(className, *result);
+ return true;
+ }
+ if (identifierIs(methodName, "valueOf")) {
+ // Return some number.
+ DOUBLE_TO_NPVARIANT(123456789, *result);
+ return true;
+ }
+ return false;
+ }
+
+ private:
+ ToStringAndValueOfObject* pluginTest() const { return static_cast<ToStringAndValueOfObject*>(Object<ScriptableObject>::pluginTest()); }
+ };
+
+ 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<ToStringAndValueOfObject> ToStringAndValueOfObject("to-string-and-value-of-object");
Modified: trunk/Tools/DumpRenderTree/TestNetscapePlugIn/win/TestNetscapePlugin.vcproj (147955 => 147956)
--- trunk/Tools/DumpRenderTree/TestNetscapePlugIn/win/TestNetscapePlugin.vcproj 2013-04-08 21:43:15 UTC (rev 147955)
+++ trunk/Tools/DumpRenderTree/TestNetscapePlugIn/win/TestNetscapePlugin.vcproj 2013-04-08 22:05:24 UTC (rev 147956)
@@ -461,6 +461,10 @@
RelativePath="..\Tests\PrivateBrowsing.cpp"
>
</File>
+ <File
+ RelativePath="..\Tests\ToStringAndValueOfObject.cpp"
+ >
+ </File>
<Filter
Name="win"
>
Modified: trunk/Tools/DumpRenderTree/qt/TestNetscapePlugin/TestNetscapePlugin.pro (147955 => 147956)
--- trunk/Tools/DumpRenderTree/qt/TestNetscapePlugin/TestNetscapePlugin.pro 2013-04-08 21:43:15 UTC (rev 147955)
+++ trunk/Tools/DumpRenderTree/qt/TestNetscapePlugin/TestNetscapePlugin.pro 2013-04-08 22:05:24 UTC (rev 147956)
@@ -31,7 +31,8 @@
Tests/PassDifferentNPPStruct.cpp \
Tests/PluginScriptableNPObjectInvokeDefault.cpp \
Tests/PluginScriptableObjectOverridesAllProperties.cpp \
- Tests/PrivateBrowsing.cpp
+ Tests/PrivateBrowsing.cpp \
+ Tests/ToStringAndValueOfObject.cpp
WEBKIT += webcore # For NPAPI headers
Modified: trunk/Tools/GNUmakefile.am (147955 => 147956)
--- trunk/Tools/GNUmakefile.am 2013-04-08 21:43:15 UTC (rev 147955)
+++ trunk/Tools/GNUmakefile.am 2013-04-08 22:05:24 UTC (rev 147956)
@@ -280,6 +280,7 @@
Tools/DumpRenderTree/TestNetscapePlugIn/Tests/PassDifferentNPPStruct.cpp \
Tools/DumpRenderTree/TestNetscapePlugIn/Tests/PluginScriptableNPObjectInvokeDefault.cpp \
Tools/DumpRenderTree/TestNetscapePlugIn/Tests/PrivateBrowsing.cpp \
+ Tools/DumpRenderTree/TestNetscapePlugIn/Tests/ToStringAndValueOfObject.cpp \
Tools/DumpRenderTree/TestNetscapePlugIn/Tests/x11/CallInvalidateRectWithNullNPPArgument.cpp \
Tools/DumpRenderTree/TestNetscapePlugIn/PluginTest.cpp \
Tools/DumpRenderTree/TestNetscapePlugIn/PluginTest.h \