test/script/basic/JDK-8056123.js

Tue, 21 Mar 2017 13:41:57 -0700

author
asaha
date
Tue, 21 Mar 2017 13:41:57 -0700
changeset 2160
1df40fe54cd6
parent 982
e56d1f4ecd91
permissions
-rw-r--r--

Merge

sundar@982 1 /*
sundar@982 2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
sundar@982 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
sundar@982 4 *
sundar@982 5 * This code is free software; you can redistribute it and/or modify it
sundar@982 6 * under the terms of the GNU General Public License version 2 only, as
sundar@982 7 * published by the Free Software Foundation.
sundar@982 8 *
sundar@982 9 * This code is distributed in the hope that it will be useful, but WITHOUT
sundar@982 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
sundar@982 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
sundar@982 12 * version 2 for more details (a copy is included in the LICENSE file that
sundar@982 13 * accompanied this code).
sundar@982 14 *
sundar@982 15 * You should have received a copy of the GNU General Public License version
sundar@982 16 * 2 along with this work; if not, write to the Free Software Foundation,
sundar@982 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
sundar@982 18 *
sundar@982 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
sundar@982 20 * or visit www.oracle.com if you need additional information or have any
sundar@982 21 * questions.
sundar@982 22 */
sundar@982 23
sundar@982 24 /**
sundar@982 25 * JDK-8056123: Anonymous function statements leak internal function names into global scope
sundar@982 26 *
sundar@982 27 * @test
sundar@982 28 * @run
sundar@982 29 */
sundar@982 30
sundar@982 31 // do *not* introduce newlines before this line!
sundar@982 32 function () { // line 32
sundar@982 33 print("hello function!");
sundar@982 34 }
sundar@982 35
sundar@982 36 if (typeof this["L:32"] != 'undefined') {
sundar@982 37 fail("anonymous function statement leaks name in global");
sundar@982 38 }
sundar@982 39
sundar@982 40 var keys = Object.keys(this);
sundar@982 41 for (var i in keys) {
sundar@982 42 if (keys[i].contains("L:")) {
sundar@982 43 fail("found " + keys[i] + " in global scope");
sundar@982 44 }
sundar@982 45 }

mercurial