blob: 259108014910c42315bf7435b18750af1b55bc45 [file] [log] [blame]
keith_miller@apple.combcc77f22016-07-15 06:03:25 +00001// Copyright 2009 the Sputnik authors. All rights reserved.
2// This code is governed by the BSD license found in the LICENSE file.
3
4/*---
5info: >
6 Being in anonymous code, "this" and eval("this"), called as a
7 constructor, return the object
8es5id: 11.1.1_A4.2
9description: >
10 Creating function by using new Function() constructor. It has the
11 property, which returns "this"
12---*/
13
14//CHECK#1
15var MyFunction = new Function("this.THIS = this");
16var MyObject = new MyFunction();
17if (MyObject.THIS.toString() !== "[object Object]") {
18 $ERROR('#1: var MyFunction = new Function("this.THIS = this"); var MyObject = new MyFunction(); MyObject.THIS.toString() === "[object Object]". Actual: ' + (MyObject.THIS.toString()));
19}
20
21//CHECK#2
22MyFunction = new Function("this.THIS = eval(\'this\')");
23MyObject = new MyFunction();
24if (MyObject.THIS.toString() !== "[object Object]") {
25 $ERROR('#2: var MyFunction = new Function("this.THIS = eval(\'this\')"); var MyObject = new MyFunction(); MyObject.THIS.toString() === "[object Object]". Actual: ' + (MyObject.THIS.toString()));
26}