Reece Dunn : jscript: Throw TypeError if T in 'new T' is not an object.

Alexandre Julliard julliard at winehq.org
Tue Oct 5 12:03:11 CDT 2010


Module: wine
Branch: master
Commit: e368fd545ca20da61f36f49f61269b7a8c28dbb2
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=e368fd545ca20da61f36f49f61269b7a8c28dbb2

Author: Reece Dunn <msclrhd at gmail.com>
Date:   Fri Oct  1 19:19:29 2010 +0100

jscript: Throw TypeError if T in 'new T' is not an object.

---

 dlls/jscript/engine.c     |   13 ++++++++++---
 dlls/jscript/tests/api.js |    3 +++
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c
index 8aed4db..8e43f70 100644
--- a/dlls/jscript/engine.c
+++ b/dlls/jscript/engine.c
@@ -1562,10 +1562,17 @@ HRESULT new_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, j
     if(FAILED(hres))
         return hres;
 
-    if(V_VT(&constr) != VT_DISPATCH) {
-        FIXME("throw TypeError\n");
+    /* NOTE: Should use to_object here */
+
+    if(V_VT(&constr) == VT_NULL) {
         VariantClear(&constr);
-        return E_FAIL;
+        return throw_type_error(ctx->parser->script, ei, IDS_OBJECT_EXPECTED, NULL);
+    } else if(V_VT(&constr) != VT_DISPATCH) {
+        VariantClear(&constr);
+        return throw_type_error(ctx->parser->script, ei, IDS_UNSUPPORTED_ACTION, NULL);
+    } else if(!V_DISPATCH(&constr)) {
+        VariantClear(&constr);
+        return throw_type_error(ctx->parser->script, ei, IDS_NO_PROPERTY, NULL);
     }
 
     hres = disp_call(ctx->parser->script, V_DISPATCH(&constr), DISPID_VALUE,
diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js
index 2e0ae0b..956ea55 100644
--- a/dlls/jscript/tests/api.js
+++ b/dlls/jscript/tests/api.js
@@ -1894,6 +1894,9 @@ exception_test(function() {(new Object()) instanceof nullDisp;}, "TypeError", -2
 exception_test(function() {"test" in 3;}, "TypeError", -2146823281);
 exception_test(function() {"test" in null;}, "TypeError", -2146823281);
 exception_test(function() {"test" in nullDisp;}, "TypeError", -2146823281);
+exception_test(function() {new 3;}, "TypeError", -2146827843);
+exception_test(function() {new null;}, "TypeError", -2146823281);
+exception_test(function() {new nullDisp;}, "TypeError", -2146827850);
 
 function testThisExcept(func, number) {
     exception_test(function() {func.call(new Object())}, "TypeError", number);




More information about the wine-cvs mailing list