js/src/tests/test262/ch12/12.10/S12.10_A1.7_T5.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 // Copyright 2009 the Sputnik authors.  All rights reserved.
     2 // This code is governed by the BSD license found in the LICENSE file.
     4 /**
     5  * The with statement adds a computed object to the front of the
     6  * scope chain of the current execution context
     7  *
     8  * @path ch12/12.10/S12.10_A1.7_T5.js
     9  * @description Calling a function within "with" statement declared within the statement, leading to completion by exception
    10  * @noStrict
    11  */
    13 this.p1 = 1;
    14 this.p2 = 2;
    15 this.p3 = 3;
    16 var result = "result";
    17 var myObj = {p1: 'a', 
    18              p2: 'b', 
    19              p3: 'c',
    20              value: 'myObj_value',
    21              valueOf : function(){return 'obj_valueOf';},
    22              parseInt : function(){return 'obj_parseInt';},
    23              NaN : 'obj_NaN',
    24              Infinity : 'obj_Infinity',
    25              eval     : function(){return 'obj_eval';},
    26              parseFloat : function(){return 'obj_parseFloat';},
    27              isNaN      : function(){return 'obj_isNaN';},
    28              isFinite   : function(){return 'obj_isFinite';}
    29 }
    30 var del;
    31 var st_p1 = "p1";
    32 var st_p2 = "p2";
    33 var st_p3 = "p3";
    34 var st_parseInt = "parseInt";
    35 var st_NaN = "NaN";
    36 var st_Infinity = "Infinity";
    37 var st_eval = "eval";
    38 var st_parseFloat = "parseFloat";
    39 var st_isNaN = "isNaN";
    40 var st_isFinite = "isFinite";
    42 try {
    43   with(myObj){
    44     var f = function(){
    45       throw value;
    46       st_p1 = p1;
    47       st_p2 = p2;
    48       st_p3 = p3;
    49       st_parseInt = parseInt;
    50       st_NaN = NaN;
    51       st_Infinity = Infinity;
    52       st_eval = eval;
    53       st_parseFloat = parseFloat;
    54       st_isNaN = isNaN;
    55       st_isFinite = isFinite;
    56       p1 = 'x1';
    57       this.p2 = 'x2';
    58       del = delete p3;
    59       var p4 = 'x4';
    60       p5 = 'x5';
    61       var value = 'value';
    62     }
    63     f();
    64   }
    65 } catch(e){
    66   result = e;
    67 }
    69 if(!(result === undefined)){
    70   $ERROR('#0: result === undefined. Actual:  result ==='+ result  );
    71 }
    73 if(!(p1 === 1)){
    74   $ERROR('#1: p1 === 1. Actual:  p1 ==='+ p1  );
    75 }
    77 if(!(p2 === 2)){
    78   $ERROR('#2: p2 === 2. Actual:  p2 ==='+ p2  );
    79 }
    81 if(!(p3 === 3)){
    82   $ERROR('#3: p3 === 3. Actual:  p3 ==='+ p3  );
    83 }
    85 try {
    86   p4;
    87   $ERROR('#4: p4 is not defined');
    88 } catch(e) {    
    89 }
    91 try {
    92   p5;
    93   $ERROR('#5: p5 is not defined');
    94 } catch(e) {    
    95 }
    97 if(!(myObj.p1 === "a")){
    98   $ERROR('#6: myObj.p1 === "a". Actual:  myObj.p1 ==='+ myObj.p1  );
    99 }
   101 if(!(myObj.p2 === "b")){
   102   $ERROR('#7: myObj.p2 === "b". Actual:  myObj.p2 ==='+ myObj.p2  );
   103 }
   105 if(!(myObj.p3 === "c")){
   106   $ERROR('#8: myObj.p3 === "c". Actual:  myObj.p3 ==='+ myObj.p3  );
   107 }
   109 if(!(myObj.p4 === undefined)){
   110   $ERROR('#9: myObj.p4 === undefined. Actual:  myObj.p4 ==='+ myObj.p4  );
   111 }
   113 if(!(myObj.p5 === undefined)){
   114   $ERROR('#10: myObj.p5 === undefined. Actual:  myObj.p5 ==='+ myObj.p5  );
   115 }
   117 if(!(st_parseInt === "parseInt")){
   118   $ERROR('#11: myObj.parseInt === "parseInt". Actual:  myObj.parseInt ==='+ myObj.parseInt  );
   119 }
   121 if(!(st_NaN === "NaN")){
   122   $ERROR('#12: st_NaN === "NaN". Actual:  st_NaN ==='+ st_NaN  );
   123 }
   125 if(!(st_Infinity === "Infinity")){
   126   $ERROR('#13: st_Infinity === "Infinity". Actual:  st_Infinity ==='+ st_Infinity  );
   127 }
   129 if(!(st_eval === "eval")){
   130   $ERROR('#14: st_eval === "eval". Actual:  st_eval ==='+ st_eval  );
   131 }
   133 if(!(st_parseFloat === "parseFloat")){
   134   $ERROR('#15: st_parseFloat === "parseFloat". Actual:  st_parseFloat ==='+ st_parseFloat  );
   135 }
   137 if(!(st_isNaN === "isNaN")){
   138   $ERROR('#16: st_isNaN === "isNaN". Actual:  st_isNaN ==='+ st_isNaN  );
   139 }
   141 if(!(st_isFinite === "isFinite")){
   142   $ERROR('#17: st_isFinite === "isFinite". Actual:  st_isFinite ==='+ st_isFinite  );
   143 }
   145 try{
   146   value;
   147   $ERROR('#18: value is not defined');
   148 }
   149 catch(e){
   150 }
   152 if(!(myObj.value === "myObj_value")){
   153   $ERROR('#19: myObj.value === "myObj_value". Actual:  myObj.value ==='+ myObj.value  );
   154 }

mercurial