Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | // Set surfaces |
michael@0 | 2 | |
michael@0 | 3 | load(libdir + "iteration.js"); |
michael@0 | 4 | |
michael@0 | 5 | var desc = Object.getOwnPropertyDescriptor(this, "Set"); |
michael@0 | 6 | assertEq(desc.enumerable, false); |
michael@0 | 7 | assertEq(desc.configurable, true); |
michael@0 | 8 | assertEq(desc.writable, true); |
michael@0 | 9 | |
michael@0 | 10 | assertEq(typeof Set, 'function'); |
michael@0 | 11 | assertEq(Object.keys(Set).length, 0); |
michael@0 | 12 | assertEq(Set.length, 0); |
michael@0 | 13 | assertEq(Set.name, "Set"); |
michael@0 | 14 | |
michael@0 | 15 | assertEq(Object.getPrototypeOf(Set.prototype), Object.prototype); |
michael@0 | 16 | assertEq(Object.prototype.toString.call(Set.prototype), "[object Set]"); |
michael@0 | 17 | assertEq(Object.prototype.toString.call(new Set), "[object Set]"); |
michael@0 | 18 | assertEq(Object.prototype.toString.call(Set()), "[object Set]"); |
michael@0 | 19 | assertEq(Object.keys(Set.prototype).join(), ""); |
michael@0 | 20 | assertEq(Set.prototype.constructor, Set); |
michael@0 | 21 | |
michael@0 | 22 | function checkMethod(name, arity) { |
michael@0 | 23 | var desc = Object.getOwnPropertyDescriptor(Set.prototype, name); |
michael@0 | 24 | assertEq(desc.enumerable, false); |
michael@0 | 25 | assertEq(desc.configurable, true); |
michael@0 | 26 | assertEq(desc.writable, true); |
michael@0 | 27 | assertEq(typeof desc.value, 'function'); |
michael@0 | 28 | assertEq(desc.value.name, name); |
michael@0 | 29 | assertEq(desc.value.length, arity); |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | checkMethod("has", 1); |
michael@0 | 33 | checkMethod("add", 1); |
michael@0 | 34 | checkMethod("delete", 1); |
michael@0 | 35 | checkMethod("values", 0); |
michael@0 | 36 | checkMethod("entries", 0); |
michael@0 | 37 | |
michael@0 | 38 | var desc = Object.getOwnPropertyDescriptor(Set.prototype, "size"); |
michael@0 | 39 | assertEq(desc.enumerable, false); |
michael@0 | 40 | assertEq(desc.configurable, true); |
michael@0 | 41 | assertEq(typeof desc.get, 'function'); |
michael@0 | 42 | assertEq(desc.get.length, 0); |
michael@0 | 43 | assertEq(desc.set, undefined); |
michael@0 | 44 | checkMethod("clear", 0); |
michael@0 | 45 | |
michael@0 | 46 | // Set.prototype.keys, .values, and .iterator are the same function object |
michael@0 | 47 | assertEq(Set.prototype.keys, Set.prototype.values); |
michael@0 | 48 | assertEq(Set.prototype[std_iterator], Set.prototype.values); |