1// Copyright JS Foundation and other contributors, http://js.foundation 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15/* Adding property to a frozen object */ 16var a = {one: "test"}; 17a.two = 3; 18Object.freeze(a); 19a.three = 7; 20assert(a.three === undefined); 21 22/* Adding properties to frozen global object */ 23Object.freeze(this); 24assert(eval ('function b() {};') === undefined); 25assert(eval('var test_var = 3') === undefined); 26 27/* Check strict mode TypeError */ 28function fail() { 29 'use strict'; 30 a.one = 'test'; // throws a TypeError 31 delete a.two; // throws a TypeError 32 a.three = 'test2'; // throws a TypeError 33} 34 35try { 36 fail(); 37} catch (e) { 38 assert(e instanceof TypeError); 39} 40 41function fail_two() { 42 'use strict'; 43 this.a = 'test'; 44} 45 46try { 47 fail_two(); 48} catch (e) { 49 assert(e instanceof TypeError); 50} 51/* Check properties of a */ 52assert(Object.keys(a) == "one,two"); 53/* Check properties of global object */ 54assert(Object.keys(this) == "assert,gc,print,resourceName,a,fail,fail_two"); 55