keith_miller@apple.com | bcc77f2 | 2016-07-15 06:03:25 +0000 | [diff] [blame] | 1 | // Copyright 2009 the Sputnik authors. All rights reserved. |
| 2 | // This code is governed by the BSD license found in the LICENSE file. |
| 3 | |
| 4 | /*--- |
| 5 | info: > |
| 6 | Being in anonymous code, "this" and eval("this"), called as a |
| 7 | constructor, return the object |
| 8 | es5id: 11.1.1_A4.2 |
| 9 | description: > |
| 10 | Creating function by using new Function() constructor. It has the |
| 11 | property, which returns "this" |
| 12 | ---*/ |
| 13 | |
| 14 | //CHECK#1 |
| 15 | var MyFunction = new Function("this.THIS = this"); |
| 16 | var MyObject = new MyFunction(); |
| 17 | if (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 |
| 22 | MyFunction = new Function("this.THIS = eval(\'this\')"); |
| 23 | MyObject = new MyFunction(); |
| 24 | if (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 | } |