Bug 522400. Fix a typo which prevented the invokedefault method on plugin-defined objects from being called. r+sr=jst

This commit is contained in:
Jonathan Griffin 2009-10-16 10:27:33 -07:00
parent 363334c64d
commit 3f3a0c3b8f
4 changed files with 41 additions and 5 deletions

View File

@ -9781,7 +9781,7 @@ nsHTMLPluginObjElementSH::Call(nsIXPConnectWrappedNative *wrapper,
// If obj is a native wrapper, or if there's no plugin around for // If obj is a native wrapper, or if there's no plugin around for
// this object, throw. // this object, throw.
if (!ObjectIsNativeWrapper(cx, obj) || !pi) { if (ObjectIsNativeWrapper(cx, obj) || !pi) {
return NS_ERROR_NOT_AVAILABLE; return NS_ERROR_NOT_AVAILABLE;
} }

View File

@ -51,8 +51,6 @@
["Boolean", "false", true], ["Boolean", "false", true],
["Boolean", new Boolean(false), true], ["Boolean", new Boolean(false), true],
["Boolean", { "value": false }, true], ["Boolean", { "value": false }, true],
// Date object
// ["Date", "December 17, 1995 03:24:00", Date("December 17, 1995 03:24:00")],
// Function object // Function object
["Function", "return 3", Function("return 3")], ["Function", "return 3", Function("return 3")],
["Function", "window.alert('test')", Function("window.alert('test')")], ["Function", "window.alert('test')", Function("window.alert('test')")],
@ -87,6 +85,7 @@
function runTests() { function runTests() {
var plugin = document.getElementById("plugin1"); var plugin = document.getElementById("plugin1");
// Test calling NPN_InvokeDefault from within plugin code.
for each (var test in tests) { for each (var test in tests) {
var result = plugin.npnInvokeDefaultTest(test[0], test[1]); var result = plugin.npnInvokeDefaultTest(test[0], test[1]);
// serialize the two values for easy // serialize the two values for easy
@ -110,7 +109,17 @@
BR() BR()
); );
} }
// Test calling the invokedefault method of plugin-defined object
is(plugin(), "Test Plug-in",
"calling NPN_InvokeDefault on plugin-defined Object doesn't work");
is(plugin(1), "Test Plug-in;1",
"calling NPN_InvokeDefault on plugin-defined Object doesn't work");
is(plugin("test"), "Test Plug-in;test",
"calling NPN_InvokeDefault on plugin-defined Object doesn't work");
is(plugin(undefined, -1, null), "Test Plug-in;undefined;-1;null",
"calling NPN_InvokeDefault on plugin-defined Object doesn't work");
SimpleTest.finish(); SimpleTest.finish();
} }
</script> </script>

View File

@ -47,6 +47,10 @@ with the specified argument. Returns the result of the invocation.
If an error has occurred during the last stream or npruntime function, If an error has occurred during the last stream or npruntime function,
this will return a string error message, otherwise it returns "pass". this will return a string error message, otherwise it returns "pass".
* () - default method
Returns a string consisting of the plugin name, concatenated with any
arguments passed to the method.
== Private browsing == == Private browsing ==
The test plugin object supports the following scriptable methods: The test plugin object supports the following scriptable methods:

View File

@ -1192,7 +1192,30 @@ scriptableInvoke(NPObject* npobj, NPIdentifier name, const NPVariant* args, uint
bool bool
scriptableInvokeDefault(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result) scriptableInvokeDefault(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
{ {
return false; ostringstream value;
value << PLUGIN_NAME;
for (uint32_t i = 0; i < argCount; i++) {
switch(args[i].type) {
case NPVariantType_Int32:
value << ";" << NPVARIANT_TO_INT32(args[i]);
break;
case NPVariantType_String: {
const NPString* argstr = &NPVARIANT_TO_STRING(args[i]);
value << ";" << argstr->UTF8Characters;
break;
}
case NPVariantType_Void:
value << ";undefined";
break;
case NPVariantType_Null:
value << ";null";
break;
default:
value << ";other";
}
}
STRINGZ_TO_NPVARIANT(strdup(value.str().c_str()), *result);
return true;
} }
bool bool