js/src/jit-test/tests/ion/bug730977-implement-jsop-delprop.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1
michael@0 2 function makeThing(i)
michael@0 3 {
michael@0 4 var thing = {};
michael@0 5 thing.foo = i;
michael@0 6 thing.bar = "bar_" + i;
michael@0 7 Object.defineProperty(thing, 'baz', {'configurable':false, 'value':[i]});
michael@0 8 return thing;
michael@0 9 }
michael@0 10 function makeArray(count)
michael@0 11 {
michael@0 12 var arr = new Array(count);
michael@0 13 for(var i = 0; i < count; i++) {
michael@0 14 arr[i] = makeThing(i);
michael@0 15 }
michael@0 16 return arr;
michael@0 17 }
michael@0 18 function delBar(obj)
michael@0 19 {
michael@0 20 assertEq(Object.getOwnPropertyDescriptor(obj, 'bar') === undefined, false);
michael@0 21 assertEq(delete obj.bar, true);
michael@0 22 assertEq(Object.getOwnPropertyDescriptor(obj, 'bar') === undefined, true);
michael@0 23 }
michael@0 24 function delBaz(obj)
michael@0 25 {
michael@0 26 var s = delete obj.baz;
michael@0 27 assertEq(Object.getOwnPropertyDescriptor(obj, 'baz') === undefined, false);
michael@0 28 assertEq(delete obj.baz, false);
michael@0 29 assertEq(Object.getOwnPropertyDescriptor(obj, 'baz') === undefined, false);
michael@0 30 }
michael@0 31 function delNonexistentThingy(obj)
michael@0 32 {
michael@0 33 assertEq(Object.getOwnPropertyDescriptor(obj, 'thingy') === undefined, true);
michael@0 34 assertEq(delete obj.thingy, true);
michael@0 35 assertEq(Object.getOwnPropertyDescriptor(obj, 'thingy') === undefined, true);
michael@0 36 }
michael@0 37 function testDelProp()
michael@0 38 {
michael@0 39 var arr = makeArray(10000);
michael@0 40 for(var i = 0; i < 10000; i++) {
michael@0 41 var obj = arr[i];
michael@0 42 assertEq(Object.getOwnPropertyDescriptor(obj, 'foo') === undefined, false);
michael@0 43 assertEq(delete obj.foo, true);
michael@0 44 assertEq(Object.getOwnPropertyDescriptor(obj, 'foo') === undefined, true);
michael@0 45 delBar(obj);
michael@0 46 delBaz(obj);
michael@0 47 delNonexistentThingy(obj);
michael@0 48 }
michael@0 49 }
michael@0 50
michael@0 51 testDelProp();

mercurial