mirror of
https://github.com/servo/servo.git
synced 2025-06-12 18:34:39 +00:00
fix defineproperty for cases with namedsetter
This commit is contained in:
parent
8ecb9d681c
commit
cdcd6670ba
4 changed files with 31 additions and 62 deletions
|
@ -3745,6 +3745,14 @@ class CGProxyNamedGetter(CGProxySpecialOperation):
|
||||||
self.templateValues = templateValues
|
self.templateValues = templateValues
|
||||||
CGProxySpecialOperation.__init__(self, descriptor, 'NamedGetter')
|
CGProxySpecialOperation.__init__(self, descriptor, 'NamedGetter')
|
||||||
|
|
||||||
|
class CGProxyNamedPresenceChecker(CGProxyNamedGetter):
|
||||||
|
"""
|
||||||
|
Class to generate a call that checks whether a named property exists.
|
||||||
|
For now, we just delegate to CGProxyNamedGetter
|
||||||
|
"""
|
||||||
|
def __init__(self, descriptor):
|
||||||
|
CGProxyNamedGetter.__init__(self, descriptor)
|
||||||
|
|
||||||
class CGProxyNamedSetter(CGProxySpecialOperation):
|
class CGProxyNamedSetter(CGProxySpecialOperation):
|
||||||
"""
|
"""
|
||||||
Class to generate a call to a named setter.
|
Class to generate a call to a named setter.
|
||||||
|
@ -3872,6 +3880,7 @@ return true;"""
|
||||||
def definition_body(self):
|
def definition_body(self):
|
||||||
return CGGeneric(self.getBody())
|
return CGGeneric(self.getBody())
|
||||||
|
|
||||||
|
# TODO(Issue 5876)
|
||||||
class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod):
|
class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod):
|
||||||
def __init__(self, descriptor):
|
def __init__(self, descriptor):
|
||||||
args = [Argument('*mut JSContext', 'cx'), Argument('*mut JSObject', 'proxy'),
|
args = [Argument('*mut JSContext', 'cx'), Argument('*mut JSObject', 'proxy'),
|
||||||
|
@ -3911,21 +3920,29 @@ class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod):
|
||||||
" let this = Unrooted::from_raw(this);\n" +
|
" let this = Unrooted::from_raw(this);\n" +
|
||||||
" let this = this.root();\n" +
|
" let this = this.root();\n" +
|
||||||
CGIndenter(CGProxyNamedSetter(self.descriptor)).define() +
|
CGIndenter(CGProxyNamedSetter(self.descriptor)).define() +
|
||||||
|
" return true;\n" +
|
||||||
|
"} else {\n" +
|
||||||
|
" return false;\n" +
|
||||||
"}\n")
|
"}\n")
|
||||||
elif self.descriptor.operations['NamedGetter']:
|
else:
|
||||||
set += ("if RUST_JSID_IS_STRING(id) != 0 {\n" +
|
if self.descriptor.operations['NamedGetter']:
|
||||||
" let name = jsid_to_str(cx, id);\n" +
|
set += ("if RUST_JSID_IS_STRING(id) != 0 {\n" +
|
||||||
" let this = UnwrapProxy(proxy);\n" +
|
" let name = jsid_to_str(cx, id);\n" +
|
||||||
" let this = Unrooted::from_raw(this);\n" +
|
" let this = UnwrapProxy(proxy);\n" +
|
||||||
" let this = this.root();\n" +
|
" let this = Unrooted::from_raw(this);\n" +
|
||||||
CGIndenter(CGProxyNamedGetter(self.descriptor)).define() +
|
" let this = this.root();\n" +
|
||||||
" if (found) {\n"
|
CGProxyNamedPresenceChecker(self.descriptor).define() +
|
||||||
" return false;\n" +
|
" if (found) {\n" +
|
||||||
" //return ThrowErrorMessage(cx, MSG_NO_PROPERTY_SETTER, \"%s\");\n" +
|
# TODO(Issue 5876)
|
||||||
" }\n" +
|
" //return js::IsInNonStrictPropertySet(cx)\n" +
|
||||||
" return true;\n"
|
" // ? opresult.succeed()\n" +
|
||||||
"}\n") % (self.descriptor.name)
|
" // : ThrowErrorMessage(cx, MSG_NO_NAMED_SETTER, \"${name}\");\n" +
|
||||||
return set + """return proxyhandler::define_property(%s);""" % ", ".join(a.name for a in self.args)
|
" return true;\n" +
|
||||||
|
" }\n" +
|
||||||
|
"}"
|
||||||
|
) % (self.descriptor.name, self.descriptor.name)
|
||||||
|
set += "return proxyhandler::define_property(%s);" % ", ".join(a.name for a in self.args)
|
||||||
|
return set
|
||||||
|
|
||||||
def definition_body(self):
|
def definition_body(self):
|
||||||
return CGGeneric(self.getBody())
|
return CGGeneric(self.getBody())
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
[builtins.html]
|
|
||||||
type: testharness
|
|
||||||
[Builtins in localStorage]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Builtins in sessionStorage]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
[in.html]
|
|
||||||
type: testharness
|
|
||||||
[The in operator in localStorage: method access]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[The in operator in sessionStorage: method access]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,32 +0,0 @@
|
||||||
[setitem.html]
|
|
||||||
type: testharness
|
|
||||||
[localStorage[\] = null]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[localStorage.setItem(_, undefined)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[localStorage[\] = undefined]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[localStorage.setItem({ throws })]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[localStorage[\] = { throws }]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[sessionStorage[\] = null]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[sessionStorage.setItem(_, undefined)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[sessionStorage[\] = undefined]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[sessionStorage.setItem({ throws })]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[sessionStorage[\] = { throws }]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue