| 1 |
// This Source Code Form is subject to the terms of the Mozilla Public |
| 2 |
// License, v. 2.0. If a copy of the MPL was not distributed with this |
| 3 |
// file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 4 |
|
| 5 |
// This function should never work (no x in lexical scope) |
| 6 |
function getX() { return x; } |
| 7 |
|
| 8 |
global = this; |
| 9 |
(function() { |
| 10 |
var x = 12345; |
| 11 |
(function() { |
| 12 |
|
| 13 |
// indirect call, not direct-call-optimized, |
| 14 |
// uses this scope's parent instead of getX's parent |
| 15 |
try { |
| 16 |
global["getX"](); |
| 17 |
} catch (e) { |
| 18 |
if (!(e instanceof ReferenceError)) |
| 19 |
throw("Expected ReferenceError from getX(), got " + e); |
| 20 |
return; |
| 21 |
} |
| 22 |
throw("Indirect call of getX() did not throw"); |
| 23 |
|
| 24 |
})(); |
| 25 |
})(); |
| 26 |
|
| 27 |
// call site triggers direct-call optimization of getX; |
| 28 |
// remove this line and the bug doesn't manifest! |
| 29 |
function neverCalled() { getX(); } |
| 30 |
|
| 31 |
"success" |