| 1 |
// Copyright 2009 the Sputnik authors. All rights reserved. |
| 2 |
// This code is governed by the BSD license found in the LICENSE file. |
| 3 |
|
| 4 |
/*--- |
| 5 |
info: If B = 11110xxx (n = 4) and (k + 2) + 9 >= length, throw URIError |
| 6 |
es5id: 15.1.3.2_A1.6_T1 |
| 7 |
es6id: 18.2.6.3 |
| 8 |
esid: sec-decodeuricomponent-encodeduricomponent |
| 9 |
description: Complex tests. B = [0xF0 - 0xF7] |
| 10 |
includes: [decimalToHexString.js] |
| 11 |
---*/ |
| 12 |
|
| 13 |
var errorCount = 0; |
| 14 |
var count = 0; |
| 15 |
var indexP; |
| 16 |
var indexO = 0; |
| 17 |
|
| 18 |
for (var index = 0xF0; index <= 0xF7; index++) { |
| 19 |
count++; |
| 20 |
var str = ""; |
| 21 |
var result = true; |
| 22 |
for (var len = 0; len < 9; len++) { |
| 23 |
var hex = decimalToPercentHexString(index); |
| 24 |
try { |
| 25 |
decodeURIComponent(hex + str); |
| 26 |
} catch (e) { |
| 27 |
if ((e instanceof URIError) === true) continue; |
| 28 |
} |
| 29 |
result = false; |
| 30 |
str = str + "1"; |
| 31 |
} |
| 32 |
if (result !== true) { |
| 33 |
if (indexO === 0) { |
| 34 |
indexO = index; |
| 35 |
} else { |
| 36 |
if ((index - indexP) !== 1) { |
| 37 |
if ((indexP - indexO) !== 0) { |
| 38 |
var hexP = decimalToHexString(indexP); |
| 39 |
var hexO = decimalToHexString(indexO); |
| 40 |
$ERROR('#' + hexO + '-' + hexP + ' '); |
| 41 |
} |
| 42 |
else { |
| 43 |
var hexP = decimalToHexString(indexP); |
| 44 |
$ERROR('#' + hexP + ' '); |
| 45 |
} |
| 46 |
indexO = index; |
| 47 |
} |
| 48 |
} |
| 49 |
indexP = index; |
| 50 |
errorCount++; |
| 51 |
} |
| 52 |
} |
| 53 |
|
| 54 |
if (errorCount > 0) { |
| 55 |
if ((indexP - indexO) !== 0) { |
| 56 |
var hexP = decimalToHexString(indexP); |
| 57 |
var hexO = decimalToHexString(indexO); |
| 58 |
$ERROR('#' + hexO + '-' + hexP + ' '); |
| 59 |
} else { |
| 60 |
var hexP = decimalToHexString(indexP); |
| 61 |
$ERROR('#' + hexP + ' '); |
| 62 |
} |
| 63 |
$ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); |
| 64 |
} |