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 | /* |
michael@0 | 2 | * Any copyright is dedicated to the Public Domain. |
michael@0 | 3 | * http://creativecommons.org/licenses/publicdomain/ |
michael@0 | 4 | */ |
michael@0 | 5 | |
michael@0 | 6 | //----------------------------------------------------------------------------- |
michael@0 | 7 | var BUGNUMBER = 537863; |
michael@0 | 8 | var summary = |
michael@0 | 9 | 'undefined, Infinity, and NaN global properties should not be writable'; |
michael@0 | 10 | |
michael@0 | 11 | print(BUGNUMBER + ": " + summary); |
michael@0 | 12 | |
michael@0 | 13 | /************** |
michael@0 | 14 | * BEGIN TEST * |
michael@0 | 15 | **************/ |
michael@0 | 16 | |
michael@0 | 17 | var desc, old, error; |
michael@0 | 18 | var global = this; |
michael@0 | 19 | |
michael@0 | 20 | var names = ["NaN", "Infinity", "undefined"]; |
michael@0 | 21 | |
michael@0 | 22 | for (var i = 0; i < names.length; i++) |
michael@0 | 23 | { |
michael@0 | 24 | var name = names[i]; |
michael@0 | 25 | desc = Object.getOwnPropertyDescriptor(global, name); |
michael@0 | 26 | assertEq(desc !== undefined, true, name + " should be present"); |
michael@0 | 27 | assertEq(desc.enumerable, false, name + " should not be enumerable"); |
michael@0 | 28 | assertEq(desc.configurable, false, name + " should not be configurable"); |
michael@0 | 29 | assertEq(desc.writable, false, name + " should not be writable"); |
michael@0 | 30 | |
michael@0 | 31 | old = global[name]; |
michael@0 | 32 | global[name] = 17; |
michael@0 | 33 | assertEq(global[name], old, name + " changed on setting?"); |
michael@0 | 34 | |
michael@0 | 35 | error = "before"; |
michael@0 | 36 | try |
michael@0 | 37 | { |
michael@0 | 38 | throw new TypeError("SpiderMonkey doesn't currently implement " + |
michael@0 | 39 | "strict-mode throwing when setting a readonly " + |
michael@0 | 40 | "property, not running this bit of test for now; " + |
michael@0 | 41 | "see bug 537873"); |
michael@0 | 42 | |
michael@0 | 43 | (function() { "use strict"; global[name] = 42; error = "didn't throw"; })(); |
michael@0 | 44 | } |
michael@0 | 45 | catch (e) |
michael@0 | 46 | { |
michael@0 | 47 | if (e instanceof TypeError) |
michael@0 | 48 | error = "typeerror"; |
michael@0 | 49 | else |
michael@0 | 50 | error = "bad exception: " + e; |
michael@0 | 51 | } |
michael@0 | 52 | assertEq(error, "typeerror", "wrong strict mode error setting " + name); |
michael@0 | 53 | } |
michael@0 | 54 | |
michael@0 | 55 | /******************************************************************************/ |
michael@0 | 56 | |
michael@0 | 57 | reportCompare(true, true); |
michael@0 | 58 | |
michael@0 | 59 | print("All tests passed!"); |