Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | |
michael@0 | 7 | /** |
michael@0 | 8 | File Name: 12.6.3-1.js |
michael@0 | 9 | ECMA Section: 12.6.3 The for...in Statement |
michael@0 | 10 | Description: |
michael@0 | 11 | The production IterationStatement : for ( LeftHandSideExpression in Expression ) |
michael@0 | 12 | Statement is evaluated as follows: |
michael@0 | 13 | |
michael@0 | 14 | 1. Evaluate the Expression. |
michael@0 | 15 | 2. Call GetValue(Result(1)). |
michael@0 | 16 | 3. Call ToObject(Result(2)). |
michael@0 | 17 | 4. Let C be "normal completion". |
michael@0 | 18 | 5. Get the name of the next property of Result(3) that doesn't have the |
michael@0 | 19 | DontEnum attribute. If there is no such property, go to step 14. |
michael@0 | 20 | 6. Evaluate the LeftHandSideExpression (it may be evaluated repeatedly). |
michael@0 | 21 | 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): |
michael@0 | 22 | 1. If Type(V) is not Reference, generate a runtime error. |
michael@0 | 23 | 2. Call GetBase(V). |
michael@0 | 24 | 3. If Result(2) is null, go to step 6. |
michael@0 | 25 | 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) |
michael@0 | 26 | for the property name and W for the value. |
michael@0 | 27 | 5. Return. |
michael@0 | 28 | 6. Call the [[Put]] method for the global object, passing |
michael@0 | 29 | GetPropertyName(V) for the property name and W for the value. |
michael@0 | 30 | 7. Return. |
michael@0 | 31 | 8. Evaluate Statement. |
michael@0 | 32 | 9. If Result(8) is a value completion, change C to be "normal completion |
michael@0 | 33 | after value V" where V is the value carried by Result(8). |
michael@0 | 34 | 10. If Result(8) is a break completion, go to step 14. |
michael@0 | 35 | 11. If Result(8) is a continue completion, go to step 5. |
michael@0 | 36 | 12. If Result(8) is a return completion, return Result(8). |
michael@0 | 37 | 13. Go to step 5. |
michael@0 | 38 | 14. Return C. |
michael@0 | 39 | |
michael@0 | 40 | Author: christine@netscape.com |
michael@0 | 41 | Date: 11 september 1997 |
michael@0 | 42 | */ |
michael@0 | 43 | var SECTION = "12.6.3-4"; |
michael@0 | 44 | var VERSION = "ECMA_1"; |
michael@0 | 45 | startTest(); |
michael@0 | 46 | var TITLE = "The for..in statement"; |
michael@0 | 47 | |
michael@0 | 48 | writeHeaderToLog( SECTION + " "+ TITLE); |
michael@0 | 49 | |
michael@0 | 50 | // for ( LeftHandSideExpression in Expression ) |
michael@0 | 51 | // LeftHandSideExpression:NewExpression:MemberExpression |
michael@0 | 52 | |
michael@0 | 53 | var count = 0; |
michael@0 | 54 | function f() { count++; return new Array("h","e","l","l","o"); } |
michael@0 | 55 | |
michael@0 | 56 | var result = ""; |
michael@0 | 57 | for ( p in f() ) { result += f()[p] }; |
michael@0 | 58 | |
michael@0 | 59 | new TestCase( SECTION, |
michael@0 | 60 | "count = 0; result = \"\"; "+ |
michael@0 | 61 | "function f() { count++; return new Array(\"h\",\"e\",\"l\",\"l\",\"o\"); }"+ |
michael@0 | 62 | "for ( p in f() ) { result += f()[p] }; count", |
michael@0 | 63 | 6, |
michael@0 | 64 | count ); |
michael@0 | 65 | |
michael@0 | 66 | new TestCase( SECTION, |
michael@0 | 67 | "result", |
michael@0 | 68 | "hello", |
michael@0 | 69 | result ); |
michael@0 | 70 | |
michael@0 | 71 | |
michael@0 | 72 | |
michael@0 | 73 | // LeftHandSideExpression:NewExpression:MemberExpression [ Expression ] |
michael@0 | 74 | // LeftHandSideExpression:NewExpression:MemberExpression . Identifier |
michael@0 | 75 | // LeftHandSideExpression:NewExpression:new MemberExpression Arguments |
michael@0 | 76 | // LeftHandSideExpression:NewExpression:PrimaryExpression:( Expression ) |
michael@0 | 77 | // LeftHandSideExpression:CallExpression:MemberExpression Arguments |
michael@0 | 78 | // LeftHandSideExpression:CallExpression Arguments |
michael@0 | 79 | // LeftHandSideExpression:CallExpression [ Expression ] |
michael@0 | 80 | // LeftHandSideExpression:CallExpression . Identifier |
michael@0 | 81 | |
michael@0 | 82 | test(); |
michael@0 | 83 |