Commit d74e433f authored by andersca's avatar andersca

JavaScriptCore:

        Reviewed by Geoff.

        * bindings/NP_jsobject.cpp:
        (_NPN_InvokeDefault):
        Call JSObject:call for native JavaScript objects.

LayoutTests:

        Reviewed by Geoff.

        Add NPN_InvokeDefault test.
        
        * plugins/netscape-invoke-default-expected.txt: Added.
        * plugins/netscape-invoke-default.html: Added.

WebKitTools:

        Reviewed by Geoff.

        * DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.c:
        (pluginInvoke):
        Add new function which takes a function and calls it using NPN_InvokeDefault.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@20544 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 7eaa01a4
2007-03-27 Anders Carlsson <acarlsson@apple.com>
Reviewed by Geoff.
* bindings/NP_jsobject.cpp:
(_NPN_InvokeDefault):
Call JSObject:call for native JavaScript objects.
2007-03-26 David Carson <dacarson@gmail.com>
Reviewed by Darin, landed by Anders.
......
......@@ -102,9 +102,29 @@ NPObject *_NPN_CreateNoScriptObject(void)
bool _NPN_InvokeDefault(NPP, NPObject* o, const NPVariant* args, uint32_t argCount, NPVariant* result)
{
if (o->_class == NPScriptObjectClass)
// No notion of a default function on JS objects. Just return false, can't handle.
return false;
if (o->_class == NPScriptObjectClass) {
JavaScriptObject* obj = (JavaScriptObject*)o;
if (!_isSafeScript(obj))
return false;
// Lookup the function object.
RootObject* rootObject = obj->rootObject;
if (!rootObject || !rootObject->isValid())
return false;
ExecState* exec = rootObject->interpreter()->globalExec();
JSLock lock;
// Call the function object.
JSObject *funcImp = static_cast<JSObject*>(obj->imp);
List argList = listFromVariantArgs(exec, args, argCount);
JSValue *resultV = funcImp->call (exec, funcImp, argList);
// Convert and return the result of the function call.
convertValueToNPVariant(exec, resultV, result);
return true;
}
if (o->_class->invokeDefault)
return o->_class->invokeDefault(o, args, argCount, result);
VOID_TO_NPVARIANT(*result);
......
2007-03-27 Anders Carlsson <acarlsson@apple.com>
Reviewed by Geoff.
Add NPN_InvokeDefault test.
* plugins/netscape-invoke-default-expected.txt: Added.
* plugins/netscape-invoke-default.html: Added.
2007-03-27 Justin Garcia <justin.garcia@apple.com>
Reviewed by darin
This tests that it's possible to call NPN_InvokeDefault on a JavaScript object. If this test succeeded, the text "SUCCESS" should be shown below.
SUCCESS
<html>
<script>
function runTest()
{
if (window.layoutTestController)
layoutTestController.dumpAsText();
var successCount = 0;
var plugin = document.getElementById("testPlugin");
var retval = plugin.testInvokeDefault(
function f(str) {
if (f == this && str == 'test')
successCount++;
});
if (retval)
successCount++;
if (successCount == 2)
document.getElementById('result').innerHTML = 'SUCCESS'
}
</script>
<body onload="runTest();">
This tests that it's possible to call NPN_InvokeDefault on a JavaScript object. If this test succeeded, the text "SUCCESS" should be shown below.
<div id="result">FAILURE</div>
<embed id="testPlugin" type="application/x-webkit-test-netscape" width="200" height="200"></embed>
</body>
</html>
2007-03-27 Anders Carlsson <acarlsson@apple.com>
Reviewed by Geoff.
* DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.c:
(pluginInvoke):
Add new function which takes a function and calls it using NPN_InvokeDefault.
2007-03-27 Adele Peterson <adele@apple.com>
Adding comment.
......
......@@ -80,8 +80,8 @@ static const NPUTF8 *pluginPropertyIdentifierNames[NUM_PROPERTY_IDENTIFIERS] = {
#define ID_REMOVE_DEFAULT_METHOD 2
#define ID_TEST_DOM_ACCESS 3
#define ID_TEST_GET_URL_NOTIFY 4
#define NUM_METHOD_IDENTIFIERS 5
#define ID_TEST_INVOKE_DEFAULT 5
#define NUM_METHOD_IDENTIFIERS 6
static NPIdentifier pluginMethodIdentifiers[NUM_METHOD_IDENTIFIERS];
static const NPUTF8 *pluginMethodIdentifierNames[NUM_METHOD_IDENTIFIERS] = {
......@@ -90,6 +90,7 @@ static const NPUTF8 *pluginMethodIdentifierNames[NUM_METHOD_IDENTIFIERS] = {
"removeDefaultMethod",
"testDOMAccess",
"getURLNotify",
"testInvokeDefault"
};
static NPUTF8* createCStringFromNPVariant(const NPVariant *variant)
......@@ -227,6 +228,20 @@ static bool pluginInvoke(NPObject *header, NPIdentifier name, const NPVariant *a
VOID_TO_NPVARIANT(*result);
return true;
}
} else if (name == pluginMethodIdentifiers[ID_TEST_INVOKE_DEFAULT] && NPVARIANT_IS_OBJECT(args[0])) {
NPObject *callback = NPVARIANT_TO_OBJECT(args[0]);
NPVariant args[1];
NPVariant browserResult;
STRINGZ_TO_NPVARIANT("test", args[0]);
bool retval = browser->invokeDefault(obj->npp, callback, args, 1, &browserResult);
if (retval)
browser->releasevariantvalue(&browserResult);
BOOLEAN_TO_NPVARIANT(retval, *result);
return true;
}
return false;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment