| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
var gTestfile = 'regress-232182.js'; |
| 7 |
|
| 8 |
|
| 9 |
var BUGNUMBER = 232182; |
| 10 |
var summary = 'Display non-ascii characters in JS exceptions'; |
| 11 |
var actual = ''; |
| 12 |
var expect = 'no error'; |
| 13 |
|
| 14 |
printBugNumber(BUGNUMBER); |
| 15 |
printStatus (summary); |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
var utf8Enabled = false; |
| 24 |
try |
| 25 |
{ |
| 26 |
\u0441\u0442; |
| 27 |
} |
| 28 |
catch (e) |
| 29 |
{ |
| 30 |
utf8Enabled = (e.message.charAt (0) == '\u0441'); |
| 31 |
} |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
printStatus('UTF-8 is ' + (utf8Enabled?'':'not ') + 'enabled'); |
| 36 |
|
| 37 |
if (!utf8Enabled) |
| 38 |
{ |
| 39 |
reportCompare('Not run', 'Not run', 'utf8 is not enabled'); |
| 40 |
} |
| 41 |
else |
| 42 |
{ |
| 43 |
status = summary + ': Throw Error with Unicode message'; |
| 44 |
expect = 'test \u0440\u0441'; |
| 45 |
try |
| 46 |
{ |
| 47 |
throw Error (expect); |
| 48 |
} |
| 49 |
catch (e) |
| 50 |
{ |
| 51 |
actual = e.message; |
| 52 |
} |
| 53 |
reportCompare(expect, actual, status); |
| 54 |
|
| 55 |
var inShell = (typeof stringsAreUTF8 == "function"); |
| 56 |
if (!inShell) |
| 57 |
{ |
| 58 |
inShell = (typeof stringsAreUtf8 == "function"); |
| 59 |
if (inShell) |
| 60 |
{ |
| 61 |
this.stringsAreUTF8 = stringsAreUtf8; |
| 62 |
this.testUTF8 = testUtf8; |
| 63 |
} |
| 64 |
} |
| 65 |
|
| 66 |
if (inShell && stringsAreUTF8()) |
| 67 |
{ |
| 68 |
status = summary + ': UTF-8 test: bad UTF-08 sequence'; |
| 69 |
expect = 'Error'; |
| 70 |
actual = 'No error!'; |
| 71 |
try |
| 72 |
{ |
| 73 |
testUTF8(1); |
| 74 |
} |
| 75 |
catch (e) |
| 76 |
{ |
| 77 |
actual = 'Error'; |
| 78 |
} |
| 79 |
reportCompare(expect, actual, status); |
| 80 |
|
| 81 |
status = summary + ': UTF-8 character too big to fit into Unicode surrogate pairs'; |
| 82 |
expect = 'Error'; |
| 83 |
actual = 'No error!'; |
| 84 |
try |
| 85 |
{ |
| 86 |
testUTF8(2); |
| 87 |
} |
| 88 |
catch (e) |
| 89 |
{ |
| 90 |
actual = 'Error'; |
| 91 |
} |
| 92 |
reportCompare(expect, actual, status); |
| 93 |
|
| 94 |
status = summary + ': bad Unicode surrogate character'; |
| 95 |
expect = 'Error'; |
| 96 |
actual = 'No error!'; |
| 97 |
try |
| 98 |
{ |
| 99 |
testUTF8(3); |
| 100 |
} |
| 101 |
catch (e) |
| 102 |
{ |
| 103 |
actual = 'Error'; |
| 104 |
} |
| 105 |
reportCompare(expect, actual, status); |
| 106 |
} |
| 107 |
|
| 108 |
if (inShell) |
| 109 |
{ |
| 110 |
status = summary + ': conversion target buffer overrun'; |
| 111 |
expect = 'Error'; |
| 112 |
actual = 'No error!'; |
| 113 |
try |
| 114 |
{ |
| 115 |
testUTF8(4); |
| 116 |
} |
| 117 |
catch (e) |
| 118 |
{ |
| 119 |
actual = 'Error'; |
| 120 |
} |
| 121 |
reportCompare(expect, actual, status); |
| 122 |
} |
| 123 |
} |