IDX props are not configurable, thus they cannot be deleted, so it makes no sense to special-case them anyway.
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/jscript/dispex.c | 13 ++++++++----- dlls/jscript/tests/lang.js | 7 +++++++ dlls/mshtml/tests/es5.js | 15 ++++++++++++++- 3 files changed, 29 insertions(+), 6 deletions(-)
diff --git a/dlls/jscript/dispex.c b/dlls/jscript/dispex.c index 8c0d84b..5cf1e0a 100644 --- a/dlls/jscript/dispex.c +++ b/dlls/jscript/dispex.c @@ -1651,14 +1651,17 @@ static HRESULT delete_prop(dispex_prop_t *prop, BOOL *ret) return S_OK; }
- *ret = TRUE; /* FIXME: not exactly right */ + *ret = TRUE;
- if(prop->type == PROP_JSVAL) { + if(prop->type == PROP_JSVAL) jsval_release(prop->u.val); - prop->type = PROP_DELETED; + if(prop->type == PROP_ACCESSOR) { + if(prop->u.accessor.getter) + jsdisp_release(prop->u.accessor.getter); + if(prop->u.accessor.setter) + jsdisp_release(prop->u.accessor.setter); } - if(prop->type == PROP_ACCESSOR) - FIXME("not supported on accessor property\n"); + prop->type = PROP_DELETED; return S_OK; }
diff --git a/dlls/jscript/tests/lang.js b/dlls/jscript/tests/lang.js index e4f5882..23c9c79 100644 --- a/dlls/jscript/tests/lang.js +++ b/dlls/jscript/tests/lang.js @@ -1589,6 +1589,13 @@ ok((delete tmp["test"]) === true, "delete returned false"); ok(typeof(tmp.test) === "undefined", "tmp.test type = " + typeof(tmp.test)); ok(!("test" in tmp), "test is still in tmp after delete?");
+arr = [1, 2, 3]; +ok(arr.length === 3, "arr.length = " + arr.length); +ok((delete arr.length) === false, "delete arr.length returned true"); +ok("reverse" in arr, "reverse not in arr"); +ok((delete Array.prototype.reverse) === true, "delete Array.prototype.reverse returned false"); +ok(!("reverse" in arr), "reverse is still in arr after delete from prototype"); + tmp.testWith = true; with(tmp) ok(testWith === true, "testWith !== true"); diff --git a/dlls/mshtml/tests/es5.js b/dlls/mshtml/tests/es5.js index ede9419..58b0d43 100644 --- a/dlls/mshtml/tests/es5.js +++ b/dlls/mshtml/tests/es5.js @@ -342,7 +342,8 @@ sync_test("defineProperty", function() { }, set: function(v) { getsetprop_value = v; - } + }, + configurable: true }; Object.defineProperty(obj, "getsetprop", desc); test_accessor_prop_desc(obj, "getsetprop", desc); @@ -353,6 +354,9 @@ sync_test("defineProperty", function() { test_accessor_prop_desc(obj, "getsetprop", desc); ok(obj.getsetprop === 2, "getsetprop = " + obj.getsetprop);
+ ok((delete obj.getsetprop) === true, "delete getsetprop returned false"); + ok(!("getsetprop" in obj), "getsetprop still in obj after delete"); + Object.defineProperty(obj, "notConf", {writable: true, enumerable: true, configurable: false, value: 1}); test_own_data_prop_desc(obj, "notConf", true, true, false);
@@ -631,6 +635,15 @@ sync_test("property_definitions", function() { ok(obj[0] === 7, "obj.prop = " + obj[0]); });
+sync_test("string_idx", function() { + var s = "foobar"; + ok(s[0] === "f", "s[0] = " + s[0]); + ok(s[5] === "r", "s[5] = " + s[5]); + ok(s[6] === undefined, "s[6] = " + s[6]); + ok((delete s[0]) === false, "delete s[0] returned true"); + ok((delete s[6]) === true, "delete s[6] returned false"); +}); + sync_test("string_trim", function() { function test_trim(value, expected) { var r = String.prototype.trim.call(value);