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 | // Map surfaces |
michael@0 | 2 | |
michael@0 | 3 | load(libdir + "iteration.js"); |
michael@0 | 4 | |
michael@0 | 5 | var desc = Object.getOwnPropertyDescriptor(this, "Map"); |
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 Map, 'function'); |
michael@0 | 11 | assertEq(Object.keys(Map).length, 0); |
michael@0 | 12 | assertEq(Map.length, 0); |
michael@0 | 13 | assertEq(Map.name, "Map"); |
michael@0 | 14 | |
michael@0 | 15 | assertEq(Object.getPrototypeOf(Map.prototype), Object.prototype); |
michael@0 | 16 | assertEq(Object.prototype.toString.call(Map.prototype), "[object Map]"); |
michael@0 | 17 | assertEq(Object.prototype.toString.call(new Map), "[object Map]"); |
michael@0 | 18 | assertEq(Object.prototype.toString.call(Map()), "[object Map]"); |
michael@0 | 19 | assertEq(Object.keys(Map.prototype).join(), ""); |
michael@0 | 20 | assertEq(Map.prototype.constructor, Map); |
michael@0 | 21 | |
michael@0 | 22 | function checkMethod(name, arity) { |
michael@0 | 23 | var desc = Object.getOwnPropertyDescriptor(Map.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("get", 1); |
michael@0 | 33 | checkMethod("has", 1); |
michael@0 | 34 | checkMethod("set", 2); |
michael@0 | 35 | checkMethod("delete", 1); |
michael@0 | 36 | checkMethod("keys", 0); |
michael@0 | 37 | checkMethod("values", 0); |
michael@0 | 38 | checkMethod("entries", 0); |
michael@0 | 39 | |
michael@0 | 40 | var desc = Object.getOwnPropertyDescriptor(Map.prototype, "size"); |
michael@0 | 41 | assertEq(desc.enumerable, false); |
michael@0 | 42 | assertEq(desc.configurable, true); |
michael@0 | 43 | assertEq(typeof desc.get, 'function'); |
michael@0 | 44 | assertEq(desc.get.length, 0); |
michael@0 | 45 | assertEq(desc.set, undefined); |
michael@0 | 46 | checkMethod("clear", 0); |
michael@0 | 47 | |
michael@0 | 48 | // Map.prototype[@@iterator] and .entries are the same function object. |
michael@0 | 49 | assertEq(Map.prototype[std_iterator], Map.prototype.entries); |