2010-11-09 Tony Chang <tony@chromium.org>
authortony@chromium.org <tony@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Nov 2010 22:48:13 +0000 (22:48 +0000)
committertony@chromium.org <tony@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Nov 2010 22:48:13 +0000 (22:48 +0000)
        Reviewed by Adam Barth.

        run platform/chromium/plugins/return-npobject.html on all platforms
        https://bugs.webkit.org/show_bug.cgi?id=49103

        * plugins/return-npobject-expected.txt: Renamed from LayoutTests/platform/chromium/plugins/return-npobject-expected.txt.
        * plugins/return-npobject.html: Renamed from LayoutTests/platform/chromium/plugins/return-npobject.html.
2010-11-08  Tony Chang  <tony@chromium.org>

        Reviewed by Adam Barth.

        run platform/chromium/plugins/return-npobject.html on all platforms
        https://bugs.webkit.org/show_bug.cgi?id=49103

        This tests that we can get an NPObject returned through a method on
        an NPAPI Object.

        * DumpRenderTree/TestNetscapePlugIn/PluginObject.cpp:
        (testCallbackReturn):
        (pluginInvoke):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@71681 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/plugins/return-npobject-expected.txt [moved from LayoutTests/platform/chromium/plugins/return-npobject-expected.txt with 100% similarity]
LayoutTests/plugins/return-npobject.html [moved from LayoutTests/platform/chromium/plugins/return-npobject.html with 88% similarity]
WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginObject.cpp

index f28b1db..74f496c 100644 (file)
@@ -1,3 +1,13 @@
+2010-11-09  Tony Chang  <tony@chromium.org>
+
+        Reviewed by Adam Barth.
+
+        run platform/chromium/plugins/return-npobject.html on all platforms
+        https://bugs.webkit.org/show_bug.cgi?id=49103
+
+        * plugins/return-npobject-expected.txt: Renamed from LayoutTests/platform/chromium/plugins/return-npobject-expected.txt.
+        * plugins/return-npobject.html: Renamed from LayoutTests/platform/chromium/plugins/return-npobject.html.
+
 2010-11-09  Ryosuke Niwa  <rniwa@webkit.org>
 
         Unreviewed rebaselines for Chromium.
@@ -3,7 +3,7 @@
   var test_object = new Object();
   test_object.value = 1;
 
-  function callbk(arg) {
+  function callback(arg) {
     return test_object;
   }
 
@@ -11,7 +11,7 @@
     if (window.layoutTestController)
         layoutTestController.dumpAsText();
 
-    var obj = plug.testCallbackRet("callbk");
+    var obj = plug.testCallbackReturn("callback");
     if (obj == test_object) {
       var output = document.getElementById("output");
       output.innerHTML = "SUCCESS";
index 7d3867e..064ea0b 100644 (file)
@@ -1,3 +1,17 @@
+2010-11-08  Tony Chang  <tony@chromium.org>
+
+        Reviewed by Adam Barth.
+
+        run platform/chromium/plugins/return-npobject.html on all platforms
+        https://bugs.webkit.org/show_bug.cgi?id=49103
+
+        This tests that we can get an NPObject returned through a method on
+        an NPAPI Object.
+
+        * DumpRenderTree/TestNetscapePlugIn/PluginObject.cpp:
+        (testCallbackReturn):
+        (pluginInvoke):
+
 2010-11-09  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r71672.
index 7f1c4b4..fdcf66c 100644 (file)
@@ -162,6 +162,7 @@ static const NPUTF8 *pluginPropertyIdentifierNames[NUM_PROPERTY_IDENTIFIERS] = {
 
 enum {
     ID_TEST_CALLBACK_METHOD = 0,
+    ID_TEST_CALLBACK_METHOD_RETURN,
     ID_TEST_GETURL,
     ID_TEST_DOM_ACCESS,
     ID_TEST_GET_URL_NOTIFY,
@@ -199,6 +200,7 @@ enum {
 static NPIdentifier pluginMethodIdentifiers[NUM_METHOD_IDENTIFIERS];
 static const NPUTF8 *pluginMethodIdentifierNames[NUM_METHOD_IDENTIFIERS] = {
     "testCallback",
+    "testCallbackReturn",
     "getURL",
     "testDOMAccess",
     "getURLNotify",
@@ -483,6 +485,35 @@ static bool testCallback(PluginObject* obj, const NPVariant* args, uint32_t argC
     return true;
 }
 
+static bool testCallbackReturn(PluginObject* obj, const NPVariant* args, uint32_t argCount, NPVariant* result)
+{
+    if (argCount != 1 || !NPVARIANT_IS_STRING(args[0]))
+        return false;
+
+    NPObject* windowScriptObject;
+    browser->getvalue(obj->npp, NPNVWindowNPObject, &windowScriptObject);
+
+    NPUTF8* callbackString = createCStringFromNPVariant(&args[0]);
+    NPIdentifier callbackIdentifier = browser->getstringidentifier(callbackString);
+    free(callbackString);
+
+    NPVariant callbackArgs[1];
+    OBJECT_TO_NPVARIANT(windowScriptObject, callbackArgs[0]);
+
+    NPVariant browserResult;
+    browser->invoke(obj->npp, windowScriptObject, callbackIdentifier,
+                    callbackArgs, 1, &browserResult);
+
+    if (NPVARIANT_IS_OBJECT(browserResult))
+        OBJECT_TO_NPVARIANT(NPVARIANT_TO_OBJECT(browserResult), *result);
+    else {
+        browser->releasevariantvalue(&browserResult);
+        VOID_TO_NPVARIANT(*result);
+    }
+
+    return true;
+}
+
 static bool getURL(PluginObject* obj, const NPVariant* args, uint32_t argCount, NPVariant* result)
 {
     if (argCount == 2 && NPVARIANT_IS_STRING(args[0]) && NPVARIANT_IS_STRING(args[1])) {
@@ -894,6 +925,8 @@ static bool pluginInvoke(NPObject* header, NPIdentifier name, const NPVariant* a
     PluginObject* plugin = reinterpret_cast<PluginObject*>(header);
     if (name == pluginMethodIdentifiers[ID_TEST_CALLBACK_METHOD])
         return testCallback(plugin, args, argCount, result);
+    if (name == pluginMethodIdentifiers[ID_TEST_CALLBACK_METHOD_RETURN])
+        return testCallbackReturn(plugin, args, argCount, result);
     if (name == pluginMethodIdentifiers[ID_TEST_GETURL])
         return getURL(plugin, args, argCount, result);
     if (name == pluginMethodIdentifiers[ID_TEST_DOM_ACCESS])