mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
fix failures in [[DefineOwnProperty]] subtest
Calling throw_type_error in the [[DefineOwnProperty]] trap (and returning false) makes the internal method throw a TypeError, which means both Object#defineProperty and Reflect#defineProperty will throw a TypeError, but we actually want the latter to return false. This commit makes the trap set ObjectOpResult to a TypeError (and return true), making the internal method return false per the spec [1] and in turn allowing Reflect#defineProperty to return false. [1] https://webidl.spec.whatwg.org/#named-properties-object-defineownproperty
This commit is contained in:
parent
b67c082dfc
commit
8814e4bb4f
1 changed files with 4 additions and 8 deletions
|
@ -11,7 +11,6 @@ use crate::dom::window::Window;
|
|||
use crate::js::conversions::ToJSValConvertible;
|
||||
use crate::script_runtime::JSContext as SafeJSContext;
|
||||
use js::conversions::jsstr_to_string;
|
||||
use js::error::throw_type_error;
|
||||
use js::glue::RUST_JSID_TO_STRING;
|
||||
use js::glue::{CreateProxyHandler, NewProxyObject, ProxyTraps, RUST_JSID_IS_STRING};
|
||||
use js::jsapi::JS_SetImmutablePrototype;
|
||||
|
@ -131,17 +130,14 @@ unsafe extern "C" fn own_property_keys(
|
|||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe extern "C" fn define_property(
|
||||
cx: *mut JSContext,
|
||||
_cx: *mut JSContext,
|
||||
_proxy: HandleObject,
|
||||
_id: HandleId,
|
||||
_desc: Handle<PropertyDescriptor>,
|
||||
_result: *mut ObjectOpResult,
|
||||
result: *mut ObjectOpResult,
|
||||
) -> bool {
|
||||
throw_type_error(
|
||||
cx,
|
||||
"Not allowed to define a property on the named properties object.",
|
||||
);
|
||||
false
|
||||
(*result).code_ = JSErrNum::JSMSG_CANT_DEFINE_WINDOW_NAMED_PROPERTY as usize;
|
||||
true
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue