diff options
author | Bastien Orivel <eijebong@bananium.fr> | 2019-05-25 14:43:44 +0200 |
---|---|---|
committer | Bastien Orivel <eijebong@bananium.fr> | 2019-05-25 14:43:44 +0200 |
commit | 0b29caa5548b0e307f2a891f5082b940c10d5762 (patch) | |
tree | 28824723cefcdf48921f9b98cc947b7abe50a070 | |
parent | 7dbff6efb7ce93ecfb04883cd1dffa24a03ed0ad (diff) | |
download | servo-0b29caa5548b0e307f2a891f5082b940c10d5762.tar.gz servo-0b29caa5548b0e307f2a891f5082b940c10d5762.zip |
Add support for attributes to the inCompartments binding parameter
-rw-r--r-- | components/script/dom/bindings/codegen/Bindings.conf | 6 | ||||
-rw-r--r-- | components/script/dom/bindings/codegen/CodegenRust.py | 9 | ||||
-rw-r--r-- | components/script/dom/testbinding.rs | 5 |
3 files changed, 13 insertions, 7 deletions
diff --git a/components/script/dom/bindings/codegen/Bindings.conf b/components/script/dom/bindings/codegen/Bindings.conf index 0f847e4eead..c8eba92d7b0 100644 --- a/components/script/dom/bindings/codegen/Bindings.conf +++ b/components/script/dom/bindings/codegen/Bindings.conf @@ -48,6 +48,10 @@ DOMInterfaces = { 'WorkerGlobalScope': { 'inCompartments': ['Fetch'], -} +}, + +'TestBinding': { + 'inCompartments': ['PromiseAttribute'], +}, } diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index 9032012dea7..a4a74cff753 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -5627,13 +5627,16 @@ class CGInterfaceTrait(CGThing): def __init__(self, descriptor): CGThing.__init__(self) - def attribute_arguments(needCx, argument=None): + def attribute_arguments(needCx, argument=None, inCompartment=False): if needCx: yield "cx", "*mut JSContext" if argument: yield "value", argument_type(descriptor, argument) + if inCompartment: + yield "_comp", "InCompartment" + def members(): for m in descriptor.interface.members: if (m.isMethod() and not m.isStatic() and @@ -5649,7 +5652,7 @@ class CGInterfaceTrait(CGThing): name = CGSpecializedGetter.makeNativeName(descriptor, m) infallible = 'infallible' in descriptor.getExtendedAttributes(m, getter=True) yield (name, - attribute_arguments(typeNeedsCx(m.type, True)), + attribute_arguments(typeNeedsCx(m.type, True), inCompartment=name in descriptor.inCompartmentMethods), return_type(descriptor, m.type, infallible)) if not m.readonly: @@ -5659,7 +5662,7 @@ class CGInterfaceTrait(CGThing): rettype = "()" else: rettype = "ErrorResult" - yield name, attribute_arguments(typeNeedsCx(m.type, False), m.type), rettype + yield name, attribute_arguments(typeNeedsCx(m.type, False), m.type, inCompartment=name in descriptor.inCompartmentMethods), rettype if descriptor.proxy: for name, operation in descriptor.operations.iteritems(): diff --git a/components/script/dom/testbinding.rs b/components/script/dom/testbinding.rs index 99e294e75e9..d048c07415c 100644 --- a/components/script/dom/testbinding.rs +++ b/components/script/dom/testbinding.rs @@ -1048,11 +1048,10 @@ impl TestBindingMethods for TestBinding { } } - fn PromiseAttribute(&self) -> Rc<Promise> { - let in_compartment_proof = AlreadyInCompartment::assert(&self.global()); + fn PromiseAttribute(&self, comp: InCompartment) -> Rc<Promise> { Promise::new_in_current_compartment( &self.global(), - InCompartment::Already(&in_compartment_proof), + comp ) } |