blob: 3e87e9ee2aa23ec4c0d088887bcf76b38e7b5750 [file] [log] [blame]
keith_miller@apple.combcc77f22016-07-15 06:03:25 +00001// Copyright 2009 the Sputnik authors. All rights reserved.
2// This code is governed by the BSD license found in the LICENSE file.
3
4/*---
5info: >
6 No matter how control leaves the embedded 'Statement',
7 the scope chain is always restored to its former state
8es5id: 12.10_A3.11_T4
9description: >
10 Calling a function within "with" statement declared without the
11 statement, leading to completion by exception
12flags: [noStrict]
13---*/
14
15this.p1 = 1;
16var result = "result";
17var value = "value";
18var myObj = {p1: 'a',
19 value: 'myObj_value',
20 valueOf : function(){return 'obj_valueOf';}
21}
22
23try {
24 var f = function(){
25 p1 = 'x1';
26 throw value;
27 }
28
29 with(myObj){
30 f();
31 }
32} catch(e){
33 result = e;
34}
35
36if(!(p1 === "x1")){
37 $ERROR('#1: p1 === "x1". Actual: p1 ==='+ p1 );
38}
39
40if(!(myObj.p1 === "a")){
41 $ERROR('#2: myObj.p1 === "a". Actual: myObj.p1 ==='+ myObj.p1 );
42}
43
44if(!(result === "value")){
45 $ERROR('#3: result === "value". Actual: result ==='+ result );
46}