tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

S15.1.3.1_A2.4_T1.js (2150B)


      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: |
      6    If B1 = 1110xxxx ([0xE0 - 0xEF]), B2, B3 = 10xxxxxxx ([0x80 - 0xBF]),
      7    without [B1, B2] = [0xE0, 0x80 - 0x9F], [0xED, 0xA0 - 0xBF] (0xD800 -
      8    0xDFFF), return UTF8(B1, B2, B3)
      9 esid: sec-decodeuri-encodeduri
     10 description: Complex tests, use RFC 3629
     11 includes: [decimalToHexString.js]
     12 ---*/
     13 
     14 var errorCount = 0;
     15 var count = 0;
     16 var indexP;
     17 var indexO = 0;
     18 
     19 for (var indexB1 = 0xE0; indexB1 <= 0xEF; indexB1++) {
     20  var hexB1 = decimalToPercentHexString(indexB1);
     21  for (var indexB2 = 0x80; indexB2 <= 0xBF; indexB2++) {
     22    if ((indexB1 === 0xE0) && (indexB2 <= 0x9F)) continue;
     23    if ((indexB1 === 0xED) && (0xA0 <= indexB2)) continue;
     24    var hexB1_B2 = hexB1 + decimalToPercentHexString(indexB2);
     25    for (var indexB3 = 0x80; indexB3 <= 0xBF; indexB3++) {
     26      count++;
     27      var hexB1_B2_B3 = hexB1_B2 + decimalToPercentHexString(indexB3);
     28      var index = (indexB1 & 0x0F) * 0x1000 + (indexB2 & 0x3F) * 0x40 + (indexB3 & 0x3F);
     29      if (decodeURI(hexB1_B2_B3) === String.fromCharCode(index)) continue;
     30 
     31      if (indexO === 0) {
     32        indexO = index;
     33      } else {
     34        if ((index - indexP) !== 1) {
     35          if ((indexP - indexO) !== 0) {
     36            var hexP = decimalToHexString(indexP);
     37            var hexO = decimalToHexString(indexO);
     38            throw new Test262Error('#' + hexO + '-' + hexP + ' ');
     39          }
     40          else {
     41            var hexP = decimalToHexString(indexP);
     42            throw new Test262Error('#' + hexP + ' ');
     43          }
     44          indexO = index;
     45        }
     46      }
     47      indexP = index;
     48      errorCount++;
     49    }
     50  }
     51 }
     52 
     53 if (errorCount > 0) {
     54  if ((indexP - indexO) !== 0) {
     55    var hexP = decimalToHexString(indexP);
     56    var hexO = decimalToHexString(indexO);
     57    throw new Test262Error('#' + hexO + '-' + hexP + ' ');
     58  } else {
     59    var hexP = decimalToHexString(indexP);
     60    throw new Test262Error('#' + hexP + ' ');
     61  }
     62  throw new Test262Error('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' ');
     63 }
     64 
     65 reportCompare(0, 0);