mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
make getOwnPropertyDescriptor trap accept integer indices
Several /webidl/ecmascript-binding/window-named-properties-object.html subtests, including the “[[GetOwnProperty]]” and “[[HasProperty]]” subtests, expect iframe.contentWindow.Window.prototype[0] to return an element with id “0”. This commit makes the getOwnPropertyDescriptor trap accept property keys that are integer indices, by converting them to a DOMString just like we would for a property key that is a JSString.
This commit is contained in:
parent
9a3d6969c9
commit
33387eb75a
1 changed files with 13 additions and 5 deletions
|
@ -84,10 +84,6 @@ unsafe extern "C" fn get_own_property_descriptor(
|
|||
is_none: *mut bool,
|
||||
) -> bool {
|
||||
let cx = SafeJSContext::from_ptr(cx);
|
||||
if !id.is_string() {
|
||||
// Nothing to do if we're resolving a non-string property.
|
||||
return true;
|
||||
}
|
||||
|
||||
let mut found = false;
|
||||
if !has_property_on_prototype(
|
||||
|
@ -102,7 +98,19 @@ unsafe extern "C" fn get_own_property_descriptor(
|
|||
return true;
|
||||
}
|
||||
|
||||
let s = jsstr_to_string(*cx, id.to_string());
|
||||
let s = if id.is_string() {
|
||||
jsstr_to_string(*cx, id.to_string())
|
||||
} else if id.is_int() {
|
||||
// If the property key is an integer index, convert it to a String too.
|
||||
// TODO(delan) will this interfere with indexed access on the Window object
|
||||
// (window[index]), which should only return document-tree child navigables?
|
||||
// https://html.spec.whatwg.org/#accessing-other-browsing-contexts
|
||||
id.to_int().to_string()
|
||||
} else {
|
||||
// TODO(delan) what do we do if the property key is a symbol?
|
||||
warn!("[[GetOwnProperty]] called with id neither string nor int: {:?}", id.get());
|
||||
return true;
|
||||
};
|
||||
if s.is_empty() {
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue