OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. | 2 // Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions | 5 // modification, are permitted provided that the following conditions |
6 // are met: | 6 // are met: |
7 // 1. Redistributions of source code must retain the above copyright | 7 // 1. Redistributions of source code must retain the above copyright |
8 // notice, this list of conditions and the following disclaimer. | 8 // notice, this list of conditions and the following disclaimer. |
9 // 2. Redistributions in binary form must reproduce the above copyright | 9 // 2. Redistributions in binary form must reproduce the above copyright |
10 // notice, this list of conditions and the following disclaimer in the | 10 // notice, this list of conditions and the following disclaimer in the |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 shouldThrow("(function f(){'use strict'; f.caller; })()"); | 102 shouldThrow("(function f(){'use strict'; f.caller; })()"); |
103 shouldThrow("(function f(){'use strict'; f.arguments=5; })()"); | 103 shouldThrow("(function f(){'use strict'; f.arguments=5; })()"); |
104 shouldThrow("(function f(){'use strict'; f.caller=5; })()"); | 104 shouldThrow("(function f(){'use strict'; f.caller=5; })()"); |
105 shouldThrow("(function (arg){'use strict'; arguments.callee; })()"); | 105 shouldThrow("(function (arg){'use strict'; arguments.callee; })()"); |
106 shouldThrow("(function (arg){'use strict'; arguments.caller; })()"); | 106 shouldThrow("(function (arg){'use strict'; arguments.caller; })()"); |
107 shouldThrow("(function f(arg){'use strict'; f.arguments; })()"); | 107 shouldThrow("(function f(arg){'use strict'; f.arguments; })()"); |
108 shouldThrow("(function f(arg){'use strict'; f.caller; })()"); | 108 shouldThrow("(function f(arg){'use strict'; f.caller; })()"); |
109 shouldThrow("(function f(arg){'use strict'; f.arguments=5; })()"); | 109 shouldThrow("(function f(arg){'use strict'; f.arguments=5; })()"); |
110 shouldThrow("(function f(arg){'use strict'; f.caller=5; })()"); | 110 shouldThrow("(function f(arg){'use strict'; f.caller=5; })()"); |
111 | 111 |
112 // arguments/caller poisoning should be visible but not throw with 'in' & 'hasOw
nProperty'. | 112 // arguments/caller poisoning should be visible on the intrinsic %FunctionProtot
ype%, but not throw with 'in' & 'hasOwnProperty'. |
113 shouldBeTrue('"caller" in function(){"use strict"}'); | 113 shouldBeTrue('"caller" in function(){"use strict"}'); |
114 shouldBeTrue('(function(){"use strict";}).hasOwnProperty("caller")'); | 114 shouldBeFalse('(function(){"use strict";}).hasOwnProperty("caller")'); |
| 115 shouldBeTrue('(function(){"use strict";}).__proto__.hasOwnProperty("caller")'); |
115 shouldBeTrue('"arguments" in function(){"use strict"}'); | 116 shouldBeTrue('"arguments" in function(){"use strict"}'); |
116 shouldBeTrue('(function(){"use strict";}).hasOwnProperty("arguments")'); | 117 shouldBeFalse('(function(){"use strict";}).hasOwnProperty("arguments")'); |
| 118 shouldBeTrue('(function(){"use strict";}).__proto__.hasOwnProperty("arguments")'
); |
117 | 119 |
118 shouldBeSyntaxError("'use strict'; (function (){with(1){};})"); | 120 shouldBeSyntaxError("'use strict'; (function (){with(1){};})"); |
119 shouldBeSyntaxError("'use strict'; (function (){var a; delete a;})"); | 121 shouldBeSyntaxError("'use strict'; (function (){var a; delete a;})"); |
120 shouldBeSyntaxError("'use strict'; var a; (function (){ delete a;})"); | 122 shouldBeSyntaxError("'use strict'; var a; (function (){ delete a;})"); |
121 shouldBeSyntaxError("var a; (function (){ 'use strict'; delete a;})"); | 123 shouldBeSyntaxError("var a; (function (){ 'use strict'; delete a;})"); |
122 shouldBeSyntaxError("'misc directive'; 'use strict'; with({}){}"); | 124 shouldBeSyntaxError("'misc directive'; 'use strict'; with({}){}"); |
123 shouldThrow("'use strict'; return"); | 125 shouldThrow("'use strict'; return"); |
124 shouldBeSyntaxError("'use strict'; break"); | 126 shouldBeSyntaxError("'use strict'; break"); |
125 shouldBeSyntaxError("'use strict'; continue"); | 127 shouldBeSyntaxError("'use strict'; continue"); |
126 shouldThrow("'use strict'; for(;;)return"); | 128 shouldThrow("'use strict'; for(;;)return"); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 shouldBeTrue("(function (a){'use strict'; var local; (function (){local;})(); ar
guments[0]=true; return arguments; })(false)[0]"); | 189 shouldBeTrue("(function (a){'use strict'; var local; (function (){local;})(); ar
guments[0]=true; return arguments; })(false)[0]"); |
188 shouldBeTrue("(function (){'use strict'; var local; (function (){local;})(); ar
guments[0]=true; return arguments; })(false)[0]"); | 190 shouldBeTrue("(function (){'use strict'; var local; (function (){local;})(); ar
guments[0]=true; return arguments; })(false)[0]"); |
189 shouldBeTrue("(function (a){'use strict'; var local; (function (){local;})(); ar
guments[0]=true; a=false; return arguments; })()[0]"); | 191 shouldBeTrue("(function (a){'use strict'; var local; (function (){local;})(); ar
guments[0]=true; a=false; return arguments; })()[0]"); |
190 shouldBeTrue("(function (a){'use strict'; var local; (function (){local;})(); ar
guments[0]=true; return arguments; })()[0]"); | 192 shouldBeTrue("(function (a){'use strict'; var local; (function (){local;})(); ar
guments[0]=true; return arguments; })()[0]"); |
191 shouldBeTrue("(function (a){'use strict'; var local; (function (){local;})(); ar
guments[0]=false; a=true; return a; })()"); | 193 shouldBeTrue("(function (a){'use strict'; var local; (function (){local;})(); ar
guments[0]=false; a=true; return a; })()"); |
192 shouldBeTrue("(function (){'use strict'; var local; (function (){local;})(); ar
guments[0]=true; return arguments; })()[0]"); | 194 shouldBeTrue("(function (){'use strict'; var local; (function (){local;})(); ar
guments[0]=true; return arguments; })()[0]"); |
193 | 195 |
194 shouldBeTrue("'use strict'; (function (){var a = true; eval('var a = false'); re
turn a; })()"); | 196 shouldBeTrue("'use strict'; (function (){var a = true; eval('var a = false'); re
turn a; })()"); |
195 shouldBeTrue("(function (){var a = true; eval('\"use strict\"; var a = false');
return a; })()"); | 197 shouldBeTrue("(function (){var a = true; eval('\"use strict\"; var a = false');
return a; })()"); |
196 | 198 |
197 shouldBeUndefined("(function f(arg){'use strict'; return Object.getOwnPropertyDe
scriptor(f, 'arguments').value; })()"); | 199 shouldBeUndefined("(function f(arg){'use strict'; return Object.getOwnPropertyDe
scriptor(f.__proto__, 'arguments').value; })()"); |
198 shouldBeUndefined("(function f(arg){'use strict'; return Object.getOwnPropertyDe
scriptor(f, 'caller').value; })()"); | 200 shouldBeUndefined("(function f(arg){'use strict'; return Object.getOwnPropertyDe
scriptor(f.__proto__, 'caller').value; })()"); |
199 shouldBeUndefined("(function f(arg){'use strict'; return Object.getOwnPropertyDe
scriptor(arguments, 'callee').value; })()"); | 201 shouldBeUndefined("(function f(arg){'use strict'; return Object.getOwnPropertyDe
scriptor(arguments, 'callee').value; })()"); |
200 shouldBeUndefined("(function f(arg){'use strict'; return Object.getOwnPropertyDe
scriptor(arguments, 'caller').value; })()"); | 202 shouldBeUndefined("(function f(arg){'use strict'; return Object.getOwnPropertyDe
scriptor(arguments, 'caller').value; })()"); |
201 shouldBeTrue("(function f(arg){'use strict'; var descriptor = Object.getOwnPrope
rtyDescriptor(arguments, 'caller'); return descriptor.get === descriptor.set; })
()"); | 203 shouldBeTrue("(function f(arg){'use strict'; var descriptor = Object.getOwnPrope
rtyDescriptor(arguments, 'caller'); return descriptor.get === descriptor.set; })
()"); |
202 shouldBeTrue("(function f(arg){'use strict'; var descriptor = Object.getOwnPrope
rtyDescriptor(arguments, 'callee'); return descriptor.get === descriptor.set; })
()"); | 204 shouldBeTrue("(function f(arg){'use strict'; var descriptor = Object.getOwnPrope
rtyDescriptor(arguments, 'callee'); return descriptor.get === descriptor.set; })
()"); |
203 shouldBeTrue("(function f(arg){'use strict'; var descriptor = Object.getOwnPrope
rtyDescriptor(f, 'caller'); return descriptor.get === descriptor.set; })()"); | 205 shouldBeTrue("(function f(arg){'use strict'; var descriptor = Object.getOwnPrope
rtyDescriptor(f.__proto__, 'caller'); return descriptor.get === descriptor.set;
})()"); |
204 shouldBeTrue("(function f(arg){'use strict'; var descriptor = Object.getOwnPrope
rtyDescriptor(f, 'arguments'); return descriptor.get === descriptor.set; })()"); | 206 shouldBeTrue("(function f(arg){'use strict'; var descriptor = Object.getOwnPrope
rtyDescriptor(f.__proto__, 'arguments'); return descriptor.get === descriptor.se
t; })()"); |
205 shouldBeTrue("'use strict'; (function f() { for(var i in this); })(); true;") | 207 shouldBeTrue("'use strict'; (function f() { for(var i in this); })(); true;") |
206 | 208 |
207 shouldBeSyntaxError("'use strict'\u033b"); | 209 shouldBeSyntaxError("'use strict'\u033b"); |
208 shouldBeSyntaxError("'use strict'5.f"); | 210 shouldBeSyntaxError("'use strict'5.f"); |
209 shouldBeSyntaxError("'use strict';\u033b"); | 211 shouldBeSyntaxError("'use strict';\u033b"); |
210 shouldBeSyntaxError("'use strict';5.f"); | 212 shouldBeSyntaxError("'use strict';5.f"); |
211 shouldBeSyntaxError("'use strict';1-(eval=1);"); | 213 shouldBeSyntaxError("'use strict';1-(eval=1);"); |
212 shouldBeSyntaxError("'use strict';arguments=1;"); | 214 shouldBeSyntaxError("'use strict';arguments=1;"); |
213 shouldBeSyntaxError("'use strict';1-(arguments=1);"); | 215 shouldBeSyntaxError("'use strict';1-(arguments=1);"); |
214 shouldBeSyntaxError("'use strict';var a=(eval=1);"); | 216 shouldBeSyntaxError("'use strict';var a=(eval=1);"); |
215 shouldBeSyntaxError("'use strict';var a=(arguments=1);"); | 217 shouldBeSyntaxError("'use strict';var a=(arguments=1);"); |
216 | 218 |
217 var aGlobal = false; | 219 var aGlobal = false; |
218 shouldBeTrue("'use strict'; try { throw 1; } catch (e) { aGlobal = true; }"); | 220 shouldBeTrue("'use strict'; try { throw 1; } catch (e) { aGlobal = true; }"); |
219 aGlobal = false; | 221 aGlobal = false; |
220 shouldBeTrue("'use strict'; (function () { try { throw 1; } catch (e) { aGlobal
= true; }})(); aGlobal;"); | 222 shouldBeTrue("'use strict'; (function () { try { throw 1; } catch (e) { aGlobal
= true; }})(); aGlobal;"); |
221 aGlobal = false; | 223 aGlobal = false; |
222 shouldBeTrue("(function () {'use strict'; try { throw 1; } catch (e) { aGlobal
= true; }})(); aGlobal;"); | 224 shouldBeTrue("(function () {'use strict'; try { throw 1; } catch (e) { aGlobal
= true; }})(); aGlobal;"); |
223 aGlobal = false; | 225 aGlobal = false; |
224 shouldBeTrue("try { throw 1; } catch (e) { aGlobal = true; }"); | 226 shouldBeTrue("try { throw 1; } catch (e) { aGlobal = true; }"); |
225 aGlobal = false; | 227 aGlobal = false; |
226 shouldBeTrue("(function () { try { throw 1; } catch (e) { aGlobal = true; }})();
aGlobal;"); | 228 shouldBeTrue("(function () { try { throw 1; } catch (e) { aGlobal = true; }})();
aGlobal;"); |
227 aGlobal = false; | 229 aGlobal = false; |
228 shouldBeTrue("(function () {try { throw 1; } catch (e) { aGlobal = true; }})();
aGlobal;"); | 230 shouldBeTrue("(function () {try { throw 1; } catch (e) { aGlobal = true; }})();
aGlobal;"); |
229 | 231 |
230 // Make sure this doesn't crash! | 232 // Make sure this doesn't crash! |
231 shouldBe('String(Object.getOwnPropertyDescriptor(function() { "use strict"; }, "
caller").get)', "'function () {\\n [native code]\\n}'"); | 233 shouldBe('String(Object.getOwnPropertyDescriptor((function() { "use strict"; }).
__proto__, "caller").get)', "'function () {\\n [native code]\\n}'"); |
OLD | NEW |