mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
Add missing IsCallable checks.
This commit is contained in:
parent
89126b44d7
commit
00559f18b1
2 changed files with 12 additions and 9 deletions
|
@ -6508,7 +6508,8 @@ class CallbackMethod(CallbackMember):
|
||||||
def getCall(self):
|
def getCall(self):
|
||||||
replacements = {
|
replacements = {
|
||||||
"thisObj": self.getThisObj(),
|
"thisObj": self.getThisObj(),
|
||||||
"getCallable": self.getCallableDecl()
|
"getCallable": self.getCallableDecl(),
|
||||||
|
"callGuard": self.getCallGuard(),
|
||||||
}
|
}
|
||||||
if self.argCount > 0:
|
if self.argCount > 0:
|
||||||
replacements["argv"] = "argv.as_ptr()"
|
replacements["argv"] = "argv.as_ptr()"
|
||||||
|
@ -6519,7 +6520,7 @@ class CallbackMethod(CallbackMember):
|
||||||
return string.Template(
|
return string.Template(
|
||||||
"${getCallable}"
|
"${getCallable}"
|
||||||
"rooted!(in(cx) let rootedThis = ${thisObj});\n"
|
"rooted!(in(cx) let rootedThis = ${thisObj});\n"
|
||||||
"let ok = JS_CallFunctionValue(\n"
|
"let ok = ${callGuard}JS_CallFunctionValue(\n"
|
||||||
" cx, rootedThis.handle(), callable.handle(),\n"
|
" cx, rootedThis.handle(), callable.handle(),\n"
|
||||||
" &HandleValueArray {\n"
|
" &HandleValueArray {\n"
|
||||||
" length_: ${argc} as ::libc::size_t,\n"
|
" length_: ${argc} as ::libc::size_t,\n"
|
||||||
|
@ -6535,6 +6536,7 @@ class CallbackMethod(CallbackMember):
|
||||||
|
|
||||||
class CallCallback(CallbackMethod):
|
class CallCallback(CallbackMethod):
|
||||||
def __init__(self, callback, descriptorProvider):
|
def __init__(self, callback, descriptorProvider):
|
||||||
|
self.callback = callback
|
||||||
CallbackMethod.__init__(self, callback.signatures()[0], "Call",
|
CallbackMethod.__init__(self, callback.signatures()[0], "Call",
|
||||||
descriptorProvider, needThisHandling=True)
|
descriptorProvider, needThisHandling=True)
|
||||||
|
|
||||||
|
@ -6544,6 +6546,11 @@ class CallCallback(CallbackMethod):
|
||||||
def getCallableDecl(self):
|
def getCallableDecl(self):
|
||||||
return "rooted!(in(cx) let callable = ObjectValue(&*self.parent.callback()));\n"
|
return "rooted!(in(cx) let callable = ObjectValue(&*self.parent.callback()));\n"
|
||||||
|
|
||||||
|
def getCallGuard(self):
|
||||||
|
if self.callback._treatNonObjectAsNull:
|
||||||
|
return "!IsCallable(self.parent.callback()) || "
|
||||||
|
return ""
|
||||||
|
|
||||||
|
|
||||||
class CallbackOperationBase(CallbackMethod):
|
class CallbackOperationBase(CallbackMethod):
|
||||||
"""
|
"""
|
||||||
|
@ -6579,6 +6586,9 @@ class CallbackOperationBase(CallbackMethod):
|
||||||
CGGeneric('ObjectValue(&*self.parent.callback())'),
|
CGGeneric('ObjectValue(&*self.parent.callback())'),
|
||||||
CGGeneric(getCallableFromProp))).define() + ');\n')
|
CGGeneric(getCallableFromProp))).define() + ');\n')
|
||||||
|
|
||||||
|
def getCallGuard(self):
|
||||||
|
return ""
|
||||||
|
|
||||||
|
|
||||||
class CallbackOperation(CallbackOperationBase):
|
class CallbackOperation(CallbackOperationBase):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
[013.html?wss]
|
|
||||||
type: testharness
|
|
||||||
expected: ERROR
|
|
||||||
|
|
||||||
[013.html]
|
|
||||||
type: testharness
|
|
||||||
expected: ERROR
|
|
Loading…
Add table
Add a link
Reference in a new issue