tor-browser

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

S15.1.3.1_A2.2_T1.js (1796B)


      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 B1 = 0xxxxxxxx ([0x00 - 0x7F]), without [uriReserved, #], return B1
      6 esid: sec-decodeuri-encodeduri
      7 description: Complex tests, use RFC 3629
      8 includes: [decimalToHexString.js]
      9 ---*/
     10 
     11 var errorCount = 0;
     12 var count = 0;
     13 var indexP;
     14 var indexO = 0;
     15 var uriReserved = [";", "/", "?", ":", "@", "&", "=", "+", "$", ","];
     16 l:
     17  for (var indexB1 = 0x00; indexB1 <= 0x7F; indexB1++) {
     18    count++;
     19    var hexB1 = decimalToPercentHexString(indexB1);
     20    var index = indexB1;
     21    var hex = String.fromCharCode(index);
     22    for (var indexC = 0; indexC < uriReserved.length; indexC++) {
     23      if (hex === uriReserved[indexC]) continue l;
     24    }
     25    if (hex === "#") continue;
     26    if (decodeURI(hexB1) === hex) continue;
     27 
     28    if (indexO === 0) {
     29      indexO = index;
     30    } else {
     31      if ((index - indexP) !== 1) {
     32        if ((indexP - indexO) !== 0) {
     33          var hexP = decimalToHexString(indexP);
     34          var hexO = decimalToHexString(indexO);
     35          throw new Test262Error('#' + hexO + '-' + hexP + ' ');
     36        }
     37        else {
     38          var hexP = decimalToHexString(indexP);
     39          throw new Test262Error('#' + hexP + ' ');
     40        }
     41        indexO = index;
     42      }
     43    }
     44    indexP = index;
     45    errorCount++;
     46  }
     47 
     48 if (errorCount > 0) {
     49  if ((indexP - indexO) !== 0) {
     50    var hexP = decimalToHexString(indexP);
     51    var hexO = decimalToHexString(indexO);
     52    throw new Test262Error('#' + hexO + '-' + hexP + ' ');
     53  } else {
     54    var hexP = decimalToHexString(indexP);
     55    throw new Test262Error('#' + hexP + ' ');
     56  }
     57  throw new Test262Error('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' ');
     58 }
     59 
     60 reportCompare(0, 0);