JDK-8026162.js revision 608:34f7a699cdef
1189251Ssam/* 2189251Ssam * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 3214734Srpaulo * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4189251Ssam * 5252726Srpaulo * This code is free software; you can redistribute it and/or modify it 6252726Srpaulo * under the terms of the GNU General Public License version 2 only, as 7189251Ssam * published by the Free Software Foundation. 8189251Ssam * 9189251Ssam * This code is distributed in the hope that it will be useful, but WITHOUT 10189251Ssam * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11189251Ssam * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12214734Srpaulo * version 2 for more details (a copy is included in the LICENSE file that 13214734Srpaulo * accompanied this code). 14189251Ssam * 15189251Ssam * You should have received a copy of the GNU General Public License version 16252726Srpaulo * 2 along with this work; if not, write to the Free Software Foundation, 17252726Srpaulo * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18252726Srpaulo * 19252726Srpaulo * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20189251Ssam * or visit www.oracle.com if you need additional information or have any 21252726Srpaulo * questions. 22189251Ssam */ 23189251Ssam 24189251Ssam/** 25189251Ssam * JDK-8026162: "this" in SAM adapter functions is wrong 26189251Ssam * 27214734Srpaulo * @test 28214734Srpaulo * @run 29214734Srpaulo */ 30189251Ssam 31189251Ssamvar global = this; 32189251Ssam 33214734Srpaulonew java.lang.Runnable( 34189251Ssam function func() { 35189251Ssam if (this !== global) { 36189251Ssam fail("Expected 'this' to be global instance"); 37189251Ssam } 38214734Srpaulo } 39214734Srpaulo).run(); 40214734Srpaulo 41189251Ssamnew java.lang.Runnable( 42189251Ssam function func() { 43189251Ssam 'use strict'; 44189251Ssam if (typeof this != 'undefined') { 45189251Ssam fail("Expected 'undefined' to be global instance"); 46189251Ssam } 47189251Ssam } 48189251Ssam).run(); 49189251Ssam