michael@0: /* michael@0: * Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/licenses/publicdomain/ michael@0: */ michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: var BUGNUMBER = 537863; michael@0: var summary = michael@0: 'undefined, Infinity, and NaN global properties should not be writable'; michael@0: michael@0: print(BUGNUMBER + ": " + summary); michael@0: michael@0: /************** michael@0: * BEGIN TEST * michael@0: **************/ michael@0: michael@0: var desc, old, error; michael@0: var global = this; michael@0: michael@0: var names = ["NaN", "Infinity", "undefined"]; michael@0: michael@0: for (var i = 0; i < names.length; i++) michael@0: { michael@0: var name = names[i]; michael@0: desc = Object.getOwnPropertyDescriptor(global, name); michael@0: assertEq(desc !== undefined, true, name + " should be present"); michael@0: assertEq(desc.enumerable, false, name + " should not be enumerable"); michael@0: assertEq(desc.configurable, false, name + " should not be configurable"); michael@0: assertEq(desc.writable, false, name + " should not be writable"); michael@0: michael@0: old = global[name]; michael@0: global[name] = 17; michael@0: assertEq(global[name], old, name + " changed on setting?"); michael@0: michael@0: error = "before"; michael@0: try michael@0: { michael@0: throw new TypeError("SpiderMonkey doesn't currently implement " + michael@0: "strict-mode throwing when setting a readonly " + michael@0: "property, not running this bit of test for now; " + michael@0: "see bug 537873"); michael@0: michael@0: (function() { "use strict"; global[name] = 42; error = "didn't throw"; })(); michael@0: } michael@0: catch (e) michael@0: { michael@0: if (e instanceof TypeError) michael@0: error = "typeerror"; michael@0: else michael@0: error = "bad exception: " + e; michael@0: } michael@0: assertEq(error, "typeerror", "wrong strict mode error setting " + name); michael@0: } michael@0: michael@0: /******************************************************************************/ michael@0: michael@0: reportCompare(true, true); michael@0: michael@0: print("All tests passed!");