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 | // Copyright 2009 the Sputnik authors. All rights reserved. |
michael@0 | 2 | // This code is governed by the BSD license found in the LICENSE file. |
michael@0 | 3 | |
michael@0 | 4 | /** |
michael@0 | 5 | * Variables are created when the program is entered. Variables are initialised to "undefined" |
michael@0 | 6 | * when created. A variable with an Initialiser is assigned the value of its AssignmentExpression when the |
michael@0 | 7 | * VariableStatement is executed, not when the variable is created |
michael@0 | 8 | * |
michael@0 | 9 | * @path ch12/12.2/S12.2_A1.js |
michael@0 | 10 | * @description Creating variables after entering the execution scope |
michael@0 | 11 | */ |
michael@0 | 12 | |
michael@0 | 13 | ////////////////////////////////////////////////////////////////////////////// |
michael@0 | 14 | //CHECK#1 |
michael@0 | 15 | try { |
michael@0 | 16 | __x = __x; |
michael@0 | 17 | __y = __x ? "good fellow" : "liar"; // __y assigned to "liar" since __x undefined |
michael@0 | 18 | __z = __z === __x ? 1 : 0; // __z assigned to 1 since both __x and __z are undefined |
michael@0 | 19 | } catch (e) { |
michael@0 | 20 | $ERROR('#1: Using declarated variable before it declaration is admitted'); |
michael@0 | 21 | } |
michael@0 | 22 | // |
michael@0 | 23 | ////////////////////////////////////////////////////////////////////////////// |
michael@0 | 24 | |
michael@0 | 25 | ////////////////////////////////////////////////////////////////////////////// |
michael@0 | 26 | //CHECK#2 |
michael@0 | 27 | try{ |
michael@0 | 28 | __something__undefined = __something__undefined; |
michael@0 | 29 | $ERROR('#2: "__something__undefined = __something__undefined" lead to throwing exception'); |
michael@0 | 30 | } catch(e){ |
michael@0 | 31 | $PRINT(e.message); |
michael@0 | 32 | } |
michael@0 | 33 | // |
michael@0 | 34 | ////////////////////////////////////////////////////////////////////////////// |
michael@0 | 35 | |
michael@0 | 36 | ////////////////////////////////////////////////////////////////////////////// |
michael@0 | 37 | //CHECK#3 |
michael@0 | 38 | if ((__y !== "liar")&(__z !== 1)) { |
michael@0 | 39 | $ERROR('#3: (__y === "liar") and (__z === 1). Actual: __y ==='+__y+' and __z ==='+__z ); |
michael@0 | 40 | } |
michael@0 | 41 | // |
michael@0 | 42 | ////////////////////////////////////////////////////////////////////////////// |
michael@0 | 43 | |
michael@0 | 44 | var __x, __y = true, __z = __y ? "smeagol" : "golum"; |
michael@0 | 45 | |
michael@0 | 46 | ////////////////////////////////////////////////////////////////////////////// |
michael@0 | 47 | //CHECK#4 |
michael@0 | 48 | if (!__y&!(__z = "smeagol")) { |
michael@0 | 49 | $ERROR('#4: A variable with an Initialiser is assigned the value of its AssignmentExpression when the VariableStatement is executed'); |
michael@0 | 50 | } |
michael@0 | 51 | // |
michael@0 | 52 | ////////////////////////////////////////////////////////////////////////////// |
michael@0 | 53 |