mirror of
https://github.com/servo/servo.git
synced 2025-07-30 02:30:21 +01:00
Auto merge of #5896 - nox:stringifier-proxy, r=jdm
The proxy stringifiers called through {}.toString.call() (obj_toString) shouldn't use the stringifier. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/5896) <!-- Reviewable:end -->
This commit is contained in:
commit
2c17779440
9 changed files with 15 additions and 57 deletions
|
@ -4106,25 +4106,6 @@ class CGDOMJSProxyHandler_obj_toString(CGAbstractExternMethod):
|
||||||
CGAbstractExternMethod.__init__(self, descriptor, "obj_toString", "*mut JSString", args)
|
CGAbstractExternMethod.__init__(self, descriptor, "obj_toString", "*mut JSString", args)
|
||||||
self.descriptor = descriptor
|
self.descriptor = descriptor
|
||||||
def getBody(self):
|
def getBody(self):
|
||||||
stringifier = self.descriptor.operations['Stringifier']
|
|
||||||
if stringifier:
|
|
||||||
name = self.descriptor.binaryNameFor(stringifier.identifier.name)
|
|
||||||
nativeName = MakeNativeName(name)
|
|
||||||
signature = stringifier.signatures()[0]
|
|
||||||
returnType = signature[0]
|
|
||||||
extendedAttributes = self.descriptor.getExtendedAttributes(stringifier)
|
|
||||||
infallible = 'infallible' in extendedAttributes
|
|
||||||
if not infallible:
|
|
||||||
error = CGGeneric(
|
|
||||||
('ThrowMethodFailedWithDetails(cx, rv, "%s", "toString");\n' +
|
|
||||||
"return NULL;") % self.descriptor.interface.identifier.name)
|
|
||||||
else:
|
|
||||||
error = None
|
|
||||||
call = CGCallGenerator(error, [], "", returnType, extendedAttributes, self.descriptor, nativeName, False, object="UnwrapProxy(proxy)")
|
|
||||||
return call.define() + """\
|
|
||||||
JSString* jsresult;
|
|
||||||
return xpc_qsStringToJsstring(cx, result, &jsresult) ? jsresult : NULL;"""
|
|
||||||
|
|
||||||
return """proxyhandler::object_to_string(cx, "%s")""" % self.descriptor.name
|
return """proxyhandler::object_to_string(cx, "%s")""" % self.descriptor.name
|
||||||
|
|
||||||
def definition_body(self):
|
def definition_body(self):
|
||||||
|
@ -4264,7 +4245,7 @@ class CGInterfaceTrait(CGThing):
|
||||||
|
|
||||||
if descriptor.proxy:
|
if descriptor.proxy:
|
||||||
for name, operation in descriptor.operations.iteritems():
|
for name, operation in descriptor.operations.iteritems():
|
||||||
if not operation:
|
if not operation or operation.isStringifier():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
assert len(operation.signatures()) == 1
|
assert len(operation.signatures()) == 1
|
||||||
|
|
|
@ -254,7 +254,7 @@ class Descriptor(DescriptorProvider):
|
||||||
|
|
||||||
self._binaryNames = desc.get('binaryNames', {})
|
self._binaryNames = desc.get('binaryNames', {})
|
||||||
self._binaryNames.setdefault('__legacycaller', 'LegacyCall')
|
self._binaryNames.setdefault('__legacycaller', 'LegacyCall')
|
||||||
self._binaryNames.setdefault('__stringifier', 'Stringify')
|
self._binaryNames.setdefault('__stringifier', 'Stringifier')
|
||||||
|
|
||||||
for member in self.interface.members:
|
for member in self.interface.members:
|
||||||
if not member.isAttr() and not member.isMethod():
|
if not member.isAttr() and not member.isMethod():
|
||||||
|
|
|
@ -159,4 +159,9 @@ impl<'a> DOMTokenListMethods for JSRef<'a, DOMTokenList> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://dom.spec.whatwg.org/#stringification-behavior
|
||||||
|
fn Stringifier(self) -> DOMString {
|
||||||
|
self.element.root().r().get_string_attribute(&self.local_name)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ impl<'a> LocationMethods for JSRef<'a, Location> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://url.spec.whatwg.org/#URLUtils-stringification-behavior
|
// https://url.spec.whatwg.org/#URLUtils-stringification-behavior
|
||||||
fn Stringify(self) -> DOMString {
|
fn Stringifier(self) -> DOMString {
|
||||||
self.Href().0
|
self.Href().0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,6 +106,11 @@ impl<'a> URLSearchParamsMethods for JSRef<'a, URLSearchParams> {
|
||||||
self.data.borrow_mut().insert(name, vec!(value));
|
self.data.borrow_mut().insert(name, vec!(value));
|
||||||
self.update_steps();
|
self.update_steps();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://url.spec.whatwg.org/#stringification-behavior
|
||||||
|
fn Stringifier(self) -> DOMString {
|
||||||
|
DOMString::from_utf8(self.serialize(None)).unwrap()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait URLSearchParamsHelpers {
|
pub trait URLSearchParamsHelpers {
|
||||||
|
|
|
@ -17,5 +17,5 @@ interface DOMTokenList {
|
||||||
[Throws]
|
[Throws]
|
||||||
boolean toggle(DOMString token, optional boolean force);
|
boolean toggle(DOMString token, optional boolean force);
|
||||||
|
|
||||||
//stringifier;
|
stringifier;
|
||||||
};
|
};
|
||||||
|
|
|
@ -15,5 +15,5 @@ interface URLSearchParams {
|
||||||
// sequence<DOMString> getAll(DOMString name);
|
// sequence<DOMString> getAll(DOMString name);
|
||||||
boolean has(DOMString name);
|
boolean has(DOMString name);
|
||||||
void set(DOMString name, DOMString value);
|
void set(DOMString name, DOMString value);
|
||||||
//stringifier;
|
stringifier;
|
||||||
};
|
};
|
||||||
|
|
|
@ -825,9 +825,6 @@
|
||||||
[DOMTokenList interface: operation toggle(DOMString,boolean)]
|
[DOMTokenList interface: operation toggle(DOMString,boolean)]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[DOMTokenList interface: stringifier]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[DOMTokenList interface: calling add(DOMString) on document.body.classList with too few arguments must throw TypeError]
|
[DOMTokenList interface: calling add(DOMString) on document.body.classList with too few arguments must throw TypeError]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
|
@ -12,42 +12,12 @@
|
||||||
[classList.add must not cause the CSS selector to stop matching]
|
[classList.add must not cause the CSS selector to stop matching]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[classList must stringify correctly when items have been added]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.add should not add a token if it already exists]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.remove removes arguments passed, if they are present.]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.remove must remove existing tokens]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.remove must not break case-sensitive CSS selector matching]
|
[classList.remove must not break case-sensitive CSS selector matching]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[classList.remove must collapse whitespace around removed tokens]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.remove must collapse whitespaces around each token]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.remove must collapse whitespaces around each token and remove duplicates]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.remove must collapse whitespace when removing duplicate tokens]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.add must collapse whitespaces and remove duplicates when adding a token that already exists]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.toggle must not break case-sensitive CSS selector matching]
|
[classList.toggle must not break case-sensitive CSS selector matching]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[CSS class selectors must stop matching when all classes have been removed]
|
[CSS class selectors must stop matching when all classes have been removed]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[classList must stringify to an empty string when all classes have been removed]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue