NASHORN-697.js revision 2:da1e581c933b
150276Speter/* 2184989Srafan * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. 350276Speter * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 450276Speter * 550276Speter * This code is free software; you can redistribute it and/or modify it 650276Speter * under the terms of the GNU General Public License version 2 only, as 750276Speter * published by the Free Software Foundation. 850276Speter * 950276Speter * This code is distributed in the hope that it will be useful, but WITHOUT 1050276Speter * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1150276Speter * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1250276Speter * version 2 for more details (a copy is included in the LICENSE file that 1350276Speter * accompanied this code). 1450276Speter * 1550276Speter * You should have received a copy of the GNU General Public License version 1650276Speter * 2 along with this work; if not, write to the Free Software Foundation, 1750276Speter * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1850276Speter * 1950276Speter * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2050276Speter * or visit www.oracle.com if you need additional information or have any 2150276Speter * questions. 2250276Speter */ 2350276Speter 2450276Speter/** 2550276Speter * NASHORN-697 : ScriptFunction should differentiate between "strict" and "builtin" 2650276Speter * 2750276Speter * @test 2850276Speter * @run 2950276Speter */ 3050276Speter 3150276Speter// make sure 'this' transformation is not done for built-ins 3250276Spetervar toString = Object.prototype.toString; 3350276Speter 3450276Speterif (toString() !== "[object Undefined]") { 3550276Speter fail("toString() !== [object Undefined]"); 3650276Speter} 3750276Speter 3850276Speterif (toString.call(null) !== "[object Null]") { 3950276Speter fail("toString.call(null) !== [object Null]"); 4050276Speter} 4150276Speter 4250276Speter 4350276Speter// make sure builtin functions are not strict! For example, 44184989Srafan// trying to access arguments and caller should not result in TypeError 4550276Spetertry { 4650276Speter if (toString.arguments) { 4750276Speter fail("toString.arguments is defined!"); 4850276Speter } 4950276Speter} catch (e) { 5076726Speter fail("got " + e, e); 5176726Speter} 5250276Speter 5376726Spetertry { 5476726Speter if (toString.caller) { 5576726Speter fail("toString.caller is defined!"); 5676726Speter } 5776726Speter} catch (e) { 5850276Speter fail("got " + e, e); 5976726Speter} 6076726Speter