|
1 // |reftest| skip-if(Android) -- bug - nsIDOMWindow.crypto throws NS_ERROR_NOT_IMPLEMENTED on Android |
|
2 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
3 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
4 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 |
|
7 |
|
8 /** |
|
9 * File Name: forin-002.js |
|
10 * ECMA Section: |
|
11 * Description: The forin-001 statement |
|
12 * |
|
13 * Verify that the property name is assigned to the property on the left |
|
14 * hand side of the for...in expression. |
|
15 * |
|
16 * Author: christine@netscape.com |
|
17 * Date: 28 August 1998 |
|
18 */ |
|
19 var SECTION = "forin-002"; |
|
20 var VERSION = "ECMA_2"; |
|
21 var TITLE = "The for...in statement"; |
|
22 |
|
23 startTest(); |
|
24 writeHeaderToLog( SECTION + " "+ TITLE); |
|
25 |
|
26 function MyObject( value ) { |
|
27 this.value = value; |
|
28 this.valueOf = new Function ( "return this.value" ); |
|
29 this.toString = new Function ( "return this.value + \"\"" ); |
|
30 this.toNumber = new Function ( "return this.value + 0" ); |
|
31 this.toBoolean = new Function ( "return Boolean( this.value )" ); |
|
32 } |
|
33 |
|
34 ForIn_1(this); |
|
35 ForIn_2(this); |
|
36 |
|
37 ForIn_1(new MyObject(true)); |
|
38 ForIn_2(new MyObject(new Boolean(true))); |
|
39 |
|
40 ForIn_2(3); |
|
41 |
|
42 test(); |
|
43 |
|
44 /** |
|
45 * For ... In in a With Block |
|
46 * |
|
47 */ |
|
48 function ForIn_1( object) { |
|
49 with ( object ) { |
|
50 for ( property in object ) { |
|
51 new TestCase( |
|
52 SECTION, |
|
53 "with loop in a for...in loop. ("+object+")["+property +"] == "+ |
|
54 "eval ( " + property +" )", |
|
55 true, |
|
56 object[property] == eval(property) ); |
|
57 } |
|
58 } |
|
59 } |
|
60 |
|
61 /** |
|
62 * With block in a For...In loop |
|
63 * |
|
64 */ |
|
65 function ForIn_2(object) { |
|
66 for ( property in object ) { |
|
67 with ( object ) { |
|
68 new TestCase( |
|
69 SECTION, |
|
70 "with loop in a for...in loop. ("+object+")["+property +"] == "+ |
|
71 "eval ( " + property +" )", |
|
72 true, |
|
73 object[property] == eval(property) ); |
|
74 } |
|
75 } |
|
76 } |
|
77 |