mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 611652 - NPN_Construct doesn't work on JS functions, only on plugin-provided objects. Fix this by using JS_New to set up the construction class and prototype correctly, r=jst
This commit is contained in:
parent
a95396d2ef
commit
542fdd7b82
@ -719,10 +719,8 @@ doInvoke(NPObject *npobj, NPIdentifier method, const NPVariant *args,
|
||||
}
|
||||
|
||||
if (ctorCall) {
|
||||
JSObject *global = ::JS_GetGlobalForObject(cx, npjsobj->mJSObj);
|
||||
JSObject *newObj =
|
||||
::JS_ConstructObjectWithArguments(cx, JS_GET_CLASS(cx, npjsobj->mJSObj),
|
||||
nsnull, global, argCount, jsargs);
|
||||
::JS_New(cx, npjsobj->mJSObj, argCount, jsargs);
|
||||
|
||||
if (newObj) {
|
||||
v = OBJECT_TO_JSVAL(newObj);
|
||||
|
@ -93,6 +93,7 @@ _MOCHITEST_FILES = \
|
||||
test_bug539565-1.html \
|
||||
test_bug539565-2.html \
|
||||
test_enumerate.html \
|
||||
test_npruntim_construct.html \
|
||||
$(NULL)
|
||||
|
||||
# test_plugin_scroll_painting.html \ bug 596491
|
||||
|
28
modules/plugin/test/mochitest/test_npruntime_construct.html
Normal file
28
modules/plugin/test/mochitest/test_npruntime_construct.html
Normal file
@ -0,0 +1,28 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test whether windowless plugins receive correct visible/invisible notifications.</title>
|
||||
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
|
||||
<body>
|
||||
<p id="display"></p>
|
||||
|
||||
<embed id="theplugin" type="application/x-test"></embed>
|
||||
|
||||
<script type="application/javascript">
|
||||
function MyFunc(arg) {
|
||||
is(arg, "hi", "Argument passed to constructor function");
|
||||
this.localProp = 'local';
|
||||
}
|
||||
MyFunc.prototype.protoProp = 't';
|
||||
|
||||
var theplugin = document.getElementById('theplugin');
|
||||
|
||||
ok(theplugin.constructObject(Array) instanceof Array, "Constructed Array");
|
||||
var o = theplugin.constructObject(MyFunc, "hi");
|
||||
ok(o instanceof MyFunc, "Constructed MyFunc");
|
||||
is(o.localProp, 'local', "this property correct");
|
||||
is(o.protoProp, 't', "prototype property correct");
|
||||
</script>
|
@ -179,6 +179,7 @@ static bool getEventModel(NPObject* npobj, const NPVariant* args, uint32_t argCo
|
||||
static bool getReflector(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
||||
static bool isVisible(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
||||
static bool getWindowPosition(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
||||
static bool constructObject(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
||||
|
||||
static const NPUTF8* sPluginMethodIdentifierNames[] = {
|
||||
"npnEvaluateTest",
|
||||
@ -232,7 +233,8 @@ static const NPUTF8* sPluginMethodIdentifierNames[] = {
|
||||
"getEventModel",
|
||||
"getReflector",
|
||||
"isVisible",
|
||||
"getWindowPosition"
|
||||
"getWindowPosition",
|
||||
"constructObject"
|
||||
};
|
||||
static NPIdentifier sPluginMethodIdentifiers[ARRAY_LENGTH(sPluginMethodIdentifierNames)];
|
||||
static const ScriptableFunction sPluginMethodFunctions[] = {
|
||||
@ -287,7 +289,8 @@ static const ScriptableFunction sPluginMethodFunctions[] = {
|
||||
getEventModel,
|
||||
getReflector,
|
||||
isVisible,
|
||||
getWindowPosition
|
||||
getWindowPosition,
|
||||
constructObject
|
||||
};
|
||||
|
||||
STATIC_ASSERT(ARRAY_LENGTH(sPluginMethodIdentifierNames) ==
|
||||
@ -3173,3 +3176,15 @@ bool getWindowPosition(NPObject* npobj, const NPVariant* args, uint32_t argCount
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool constructObject(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
|
||||
{
|
||||
if (argCount == 0 || !NPVARIANT_IS_OBJECT(args[0]))
|
||||
return false;
|
||||
|
||||
NPObject* ctor = NPVARIANT_TO_OBJECT(args[0]);
|
||||
|
||||
NPP npp = static_cast<TestNPObject*>(npobj)->npp;
|
||||
|
||||
return NPN_Construct(npp, ctor, args + 1, argCount - 1, result);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user