Commit 9fd4f4a4 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Added support for constructor property.

parent 75ab8e20
...@@ -803,6 +803,7 @@ HRESULT init_dispex_from_constr(DispatchEx *dispex, script_ctx_t *ctx, const bui ...@@ -803,6 +803,7 @@ HRESULT init_dispex_from_constr(DispatchEx *dispex, script_ctx_t *ctx, const bui
dispex_prop_t *prop; dispex_prop_t *prop;
HRESULT hres; HRESULT hres;
static const WCHAR constructorW[] = {'c','o','n','s','t','r','u','c','t','o','r'};
static const WCHAR prototypeW[] = {'p','r','o','t','o','t','y','p','e',0}; static const WCHAR prototypeW[] = {'p','r','o','t','o','t','y','p','e',0};
hres = find_prop_name_prot(constr, prototypeW, &prop); hres = find_prop_name_prot(constr, prototypeW, &prop);
...@@ -827,6 +828,22 @@ HRESULT init_dispex_from_constr(DispatchEx *dispex, script_ctx_t *ctx, const bui ...@@ -827,6 +828,22 @@ HRESULT init_dispex_from_constr(DispatchEx *dispex, script_ctx_t *ctx, const bui
if(prot) if(prot)
jsdisp_release(prot); jsdisp_release(prot);
if(FAILED(hres))
return hres;
hres = ensure_prop_name(dispex, constructorW, FALSE, 0, &prop);
if(SUCCEEDED(hres)) {
jsexcept_t jsexcept;
VARIANT var;
V_VT(&var) = VT_DISPATCH;
V_DISPATCH(&var) = (IDispatch*)_IDispatchEx_(constr);
memset(&jsexcept, 0, sizeof(jsexcept));
hres = prop_put(dispex, prop, &var, &jsexcept, NULL/*FIXME*/);
}
if(FAILED(hres))
jsdisp_release(dispex);
return hres; return hres;
} }
......
...@@ -116,6 +116,7 @@ ok(tmp === 1, "tmp = " + tmp); ...@@ -116,6 +116,7 @@ ok(tmp === 1, "tmp = " + tmp);
var obj1 = new Object(); var obj1 = new Object();
ok(typeof(obj1) === "object", "typeof(obj1) is not object"); ok(typeof(obj1) === "object", "typeof(obj1) is not object");
ok(obj1.constructor === Object, "unexpected obj1.constructor");
obj1.test = true; obj1.test = true;
obj1.func = function () { obj1.func = function () {
ok(this === obj1, "this is not obj1"); ok(this === obj1, "this is not obj1");
...@@ -144,6 +145,7 @@ testConstr1.prototype.pvar = 1; ...@@ -144,6 +145,7 @@ testConstr1.prototype.pvar = 1;
var obj2 = new testConstr1(true); var obj2 = new testConstr1(true);
ok(typeof(obj2) === "object", "typeof(obj2) is not object"); ok(typeof(obj2) === "object", "typeof(obj2) is not object");
ok(obj2.constructor === testConstr1, "unexpected obj2.constructor");
ok(obj2.pvar === 1, "obj2.pvar is not 1"); ok(obj2.pvar === 1, "obj2.pvar is not 1");
testConstr1.prototype.pvar = 2; testConstr1.prototype.pvar = 2;
...@@ -209,6 +211,7 @@ if(false) { ...@@ -209,6 +211,7 @@ if(false) {
var obj3 = { prop1: 1, prop2: typeof(false) }; var obj3 = { prop1: 1, prop2: typeof(false) };
ok(obj3.prop1 === 1, "obj3.prop1 is not 1"); ok(obj3.prop1 === 1, "obj3.prop1 is not 1");
ok(obj3.prop2 === "boolean", "obj3.prop2 is not \"boolean\""); ok(obj3.prop2 === "boolean", "obj3.prop2 is not \"boolean\"");
ok(obj3.constructor === Object, "unexpected obj3.constructor");
{ {
var blockVar = 1; var blockVar = 1;
...@@ -422,8 +425,10 @@ ok(+"3e3" === 3000, "+'3e3' !== 3000"); ...@@ -422,8 +425,10 @@ ok(+"3e3" === 3000, "+'3e3' !== 3000");
tmp = new Number(1); tmp = new Number(1);
ok(+tmp === 1, "+(new Number(1)) = " + (+tmp)); ok(+tmp === 1, "+(new Number(1)) = " + (+tmp));
ok(tmp.constructor === Number, "unexpected tmp.constructor");
tmp = new String("1"); tmp = new String("1");
ok(+tmp === 1, "+(new String('1')) = " + (+tmp)); ok(+tmp === 1, "+(new String('1')) = " + (+tmp));
ok(tmp.constructor === String, "unexpected tmp.constructor");
ok("" + 0 === "0", "\"\" + 0 !== \"0\""); ok("" + 0 === "0", "\"\" + 0 !== \"0\"");
ok("" + 123 === "123", "\"\" + 123 !== \"123\""); ok("" + 123 === "123", "\"\" + 123 !== \"123\"");
......
...@@ -100,6 +100,7 @@ m = "abcabc".match(re = /ca/); ...@@ -100,6 +100,7 @@ m = "abcabc".match(re = /ca/);
ok(typeof(m) === "object", "typeof m is not object"); ok(typeof(m) === "object", "typeof m is not object");
ok(m.length === 1, "m.length is not 1"); ok(m.length === 1, "m.length is not 1");
ok(m["0"] === "ca", "m[0] is not \"ca\""); ok(m["0"] === "ca", "m[0] is not \"ca\"");
ok(m.constructor === Array, "unexpected m.constructor");
ok(re.lastIndex === 4, "re.lastIndex = " + re.lastIndex); ok(re.lastIndex === 4, "re.lastIndex = " + re.lastIndex);
m = "abcabc".match(/ab/); m = "abcabc".match(/ab/);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment