NASHORN-381.js revision 6:5a1b0714df0e
145405Smsmith/*
245405Smsmith * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
345405Smsmith * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
445405Smsmith *
545405Smsmith * This code is free software; you can redistribute it and/or modify it
645405Smsmith * under the terms of the GNU General Public License version 2 only, as
745405Smsmith * published by the Free Software Foundation.
845405Smsmith *
945405Smsmith * This code is distributed in the hope that it will be useful, but WITHOUT
1045405Smsmith * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1145405Smsmith * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1245405Smsmith * version 2 for more details (a copy is included in the LICENSE file that
1345405Smsmith * accompanied this code).
1445405Smsmith *
1545405Smsmith * You should have received a copy of the GNU General Public License version
1645405Smsmith * 2 along with this work; if not, write to the Free Software Foundation,
1745405Smsmith * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1845405Smsmith *
1945405Smsmith * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2045405Smsmith * or visit www.oracle.com if you need additional information or have any
2145405Smsmith * questions.
2245405Smsmith */
2345405Smsmith
2445405Smsmith/**
2545405Smsmith * NASHORN-381 : JSAdapter override mechanism should not search properties of it's own proto
2648008Sgreen *
2745405Smsmith * @test
2845405Smsmith * @run
2945405Smsmith */
3045405Smsmith
3145405Smsmithvar toStringAccessed = false;
3245405Smsmith
3345405Smsmithvar obj = new JSAdapter({}) {
3445405Smsmith    __get__: function(name) {
3545405Smsmith        if (name == 'toString') {
3645405Smsmith           toStringAccessed = true;
3745405Smsmith        }
3845405Smsmith    }
3945405Smsmith};
4045405Smsmith
4145405Smsmithif (obj.toString === Object.prototype.toString) {
4245405Smsmith    fail("JSAdapter uses Object.prototype properties");
4345405Smsmith}
4445405Smsmith
4545405Smsmithif (! toStringAccessed) {
4645405Smsmith    fail("JSAdapter does not use __get__ for toString access");
4745405Smsmith}
4845405Smsmith