| 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 |
// https://bugzilla.mozilla.org/show_bug.cgi?id=608235 |
| 6 |
|
| 7 |
function Try(f, expected) { |
| 8 |
try { |
| 9 |
f(); |
| 10 |
throw "Expected error: " + expected; |
| 11 |
} catch (e) { |
| 12 |
if (e != expected) { |
| 13 |
throw "Expected error: " + expected; |
| 14 |
} |
| 15 |
} |
| 16 |
} |
| 17 |
|
| 18 |
Try( |
| 19 |
function(){ undefined[undefined] }, |
| 20 |
'TypeError: Cannot read property "undefined" from undefined' |
| 21 |
); |
| 22 |
|
| 23 |
Try( |
| 24 |
function(){ undefined[undefined] = 1 }, |
| 25 |
'TypeError: Cannot set property "undefined" of undefined to "1"' |
| 26 |
); |
| 27 |
|
| 28 |
Try( |
| 29 |
function(){ undefined[undefined] = {} }, |
| 30 |
'TypeError: Cannot set property "undefined" of undefined to "[object Object]"' |
| 31 |
); |
| 32 |
|
| 33 |
Try( |
| 34 |
function(){ undefined[undefined] = [1,2,3] }, |
| 35 |
'TypeError: Cannot set property "undefined" of undefined to "1,2,3"' |
| 36 |
); |
| 37 |
|
| 38 |
Try( |
| 39 |
function(){ delete undefined[undefined] }, |
| 40 |
'TypeError: Cannot delete property "undefined" of undefined' |
| 41 |
); |
| 42 |
|
| 43 |
Try( |
| 44 |
function(){ undefined[undefined]() }, |
| 45 |
'TypeError: Cannot call method "undefined" of undefined' |
| 46 |
); |
| 47 |
|
| 48 |
"success"; |