aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/script/dom/bindings/codegen/CodegenRust.py31
-rw-r--r--components/script/dom/bindings/guard.rs2
-rw-r--r--tests/wpt/metadata/hr-time/idlharness.any.js.ini8
3 files changed, 23 insertions, 18 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py
index 8f0281be802..96947d83ec7 100644
--- a/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/components/script/dom/bindings/codegen/CodegenRust.py
@@ -2966,24 +2966,35 @@ class CGCollectJSONAttributesMethod(CGAbstractMethod):
self.toJSONMethod = toJSONMethod
def definition_body(self):
- ret = ''
+ ret = """let incumbent_global = GlobalScope::incumbent().expect("no incumbent global");
+let global = incumbent_global.reflector().get_jsobject();\n"""
interface = self.descriptor.interface
for m in interface.members:
if m.isAttr() and not m.isStatic() and m.type.isJSONType():
name = m.identifier.name
+ conditions = MemberCondition(None, None, m.exposureSet)
+ ret_conditions = '&[' + ", ".join(conditions) + "]"
ret += fill(
"""
- rooted!(in(cx) let mut temp = UndefinedValue());
- if !get_${name}(cx, obj, this, JSJitGetterCallArgs { _base: temp.handle_mut().into() }) {
- return false;
- }
- if !JS_DefineProperty(cx, result.handle().into(),
- ${nameAsArray} as *const u8 as *const libc::c_char,
- temp.handle(), JSPROP_ENUMERATE as u32) {
- return false;
+ let conditions = ${conditions};
+ let is_satisfied = conditions.iter().any(|c|
+ c.is_satisfied(
+ SafeJSContext::from_ptr(cx),
+ HandleObject::from_raw(obj),
+ global));
+ if is_satisfied {
+ rooted!(in(cx) let mut temp = UndefinedValue());
+ if !get_${name}(cx, obj, this, JSJitGetterCallArgs { _base: temp.handle_mut().into() }) {
+ return false;
+ }
+ if !JS_DefineProperty(cx, result.handle().into(),
+ ${nameAsArray} as *const u8 as *const libc::c_char,
+ temp.handle(), JSPROP_ENUMERATE as u32) {
+ return false;
+ }
}
""",
- name=name, nameAsArray=str_to_const_array(name))
+ name=name, nameAsArray=str_to_const_array(name), conditions=ret_conditions)
ret += 'return true;\n'
return CGGeneric(ret)
diff --git a/components/script/dom/bindings/guard.rs b/components/script/dom/bindings/guard.rs
index bba30e1581c..188d36fee17 100644
--- a/components/script/dom/bindings/guard.rs
+++ b/components/script/dom/bindings/guard.rs
@@ -50,7 +50,7 @@ pub enum Condition {
}
impl Condition {
- fn is_satisfied(&self, cx: JSContext, obj: HandleObject, global: HandleObject) -> bool {
+ pub fn is_satisfied(&self, cx: JSContext, obj: HandleObject, global: HandleObject) -> bool {
match *self {
Condition::Pref(name) => prefs::pref_map().get(name).as_bool().unwrap_or(false),
Condition::Func(f) => f(cx, obj),
diff --git a/tests/wpt/metadata/hr-time/idlharness.any.js.ini b/tests/wpt/metadata/hr-time/idlharness.any.js.ini
index e7e8c641ef8..286747ba9de 100644
--- a/tests/wpt/metadata/hr-time/idlharness.any.js.ini
+++ b/tests/wpt/metadata/hr-time/idlharness.any.js.ini
@@ -13,10 +13,4 @@
[idlharness.https.any.serviceworker.html]
expected: TIMEOUT
[idlharness]
- expected: FAIL
-
-
-[idlharness.any.html]
-
-[idlharness.any.worker.html]
- expected: CRASH
+ expected: FAIL \ No newline at end of file