[PATCH v2 4/8] jscript: Throw proper error in Object methods with non-objects args.
Gabriel Ivăncescu
gabrielopcode at gmail.com
Thu Mar 24 10:31:09 CDT 2022
According to the ES6 spec, they don't throw anymore (compared to ES5),
but native IE seems to not follow it here and throws anyway.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
---
dlls/jscript/object.c | 18 ++++++------------
dlls/mshtml/tests/documentmode.js | 24 ++++++++++++++++++++++++
2 files changed, 30 insertions(+), 12 deletions(-)
diff --git a/dlls/jscript/object.c b/dlls/jscript/object.c
index a697b63..62a105f 100644
--- a/dlls/jscript/object.c
+++ b/dlls/jscript/object.c
@@ -850,10 +850,8 @@ static HRESULT Object_getPrototypeOf(script_ctx_t *ctx, jsval_t vthis, WORD flag
{
jsdisp_t *obj;
- if(!argc || !is_object_instance(argv[0])) {
- FIXME("invalid arguments\n");
- return E_NOTIMPL;
- }
+ if(!argc || !is_object_instance(argv[0]))
+ return JS_E_OBJECT_EXPECTED;
TRACE("(%s)\n", debugstr_jsval(argv[0]));
@@ -878,10 +876,8 @@ static HRESULT object_keys(script_ctx_t *ctx, jsval_t arg, enum jsdisp_enum_type
jsstr_t *key;
HRESULT hres;
- if(!is_object_instance(arg)) {
- FIXME("invalid arguments %s\n", debugstr_jsval(arg));
- return E_NOTIMPL;
- }
+ if(!is_object_instance(arg))
+ return JS_E_OBJECT_EXPECTED;
obj = to_jsdisp(get_object(arg));
if(!obj) {
@@ -937,10 +933,8 @@ static HRESULT Object_preventExtensions(script_ctx_t *ctx, jsval_t vthis, WORD f
{
jsdisp_t *obj;
- if(!argc || !is_object_instance(argv[0])) {
- FIXME("invalid arguments\n");
- return E_NOTIMPL;
- }
+ if(!argc || !is_object_instance(argv[0]))
+ return JS_E_OBJECT_EXPECTED;
TRACE("(%s)\n", debugstr_jsval(argv[0]));
diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js
index 4a776f8..b4d0beb 100644
--- a/dlls/mshtml/tests/documentmode.js
+++ b/dlls/mshtml/tests/documentmode.js
@@ -1278,6 +1278,30 @@ sync_test("elem_attr", function() {
}
});
+sync_test("builtins_diffs", function() {
+ var v = document.documentMode;
+
+ /* despite what spec says for ES6, IE still throws */
+ var props = [
+ "freeze",
+ "getPrototypeOf",
+ "isExtensible",
+ "isFrozen",
+ "isSealed",
+ "keys",
+ "preventExtensions",
+ "seal"
+ ];
+ for(var i = 0; i < props.length; i++) {
+ try {
+ Object[props[i]]("test");
+ ok(false, "Object." + props[i] + " with non-object: expected exception");
+ }catch(e) {
+ ok(e.number === (v < 9 ? 0xa01b6 : 0xa138f) - 0x80000000, "Object." + props[i] + " with non-object: exception = " + e.number);
+ }
+ }
+});
+
sync_test("__proto__", function() {
var v = document.documentMode;
var r, x = 42;
--
2.34.1
More information about the wine-devel
mailing list