tor-browser

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

S15.1.3.3_A2.5_T1.js (1730B)


      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 string.charAt(k) in [0xE000 - 0xFFFF], return 3 octets (xxxxyyyy
      7    yyzzzzzz -> 1110xxxx 10yyyyyy 10zzzzzz)
      8 esid: sec-encodeuri-uri
      9 description: Complex tests, use RFC 3629
     10 includes: [decimalToHexString.js]
     11 ---*/
     12 
     13 var errorCount = 0;
     14 var count = 0;
     15 var indexP;
     16 var indexO = 0;
     17 for (var index = 0xE000; index <= 0xFFFF; index++) {
     18  count++;
     19  var hex1 = decimalToPercentHexString(0x0080 + (index & 0x003F));
     20  var hex2 = decimalToPercentHexString(0x0080 + (index & 0x0FC0) / 0x0040);
     21  var hex3 = decimalToPercentHexString(0x00E0 + (index & 0xF000) / 0x1000);
     22  var str = String.fromCharCode(index);
     23  if (encodeURI(str).toUpperCase() === hex3 + hex2 + hex1) continue;
     24 
     25  if (indexO === 0) {
     26    indexO = index;
     27  } else {
     28    if ((index - indexP) !== 1) {
     29      if ((indexP - indexO) !== 0) {
     30        var hexP = decimalToHexString(indexP);
     31        var hexO = decimalToHexString(indexO);
     32        throw new Test262Error('#' + hexO + '-' + hexP + ' ');
     33      }
     34      else {
     35        var hexP = decimalToHexString(indexP);
     36        throw new Test262Error('#' + hexP + ' ');
     37      }
     38      indexO = index;
     39    }
     40  }
     41  indexP = index;
     42  errorCount++;
     43 }
     44 
     45 if (errorCount > 0) {
     46  if ((indexP - indexO) !== 0) {
     47    var hexP = decimalToHexString(indexP);
     48    var hexO = decimalToHexString(indexO);
     49    throw new Test262Error('#' + hexO + '-' + hexP + ' ');
     50  } else {
     51    var hexP = decimalToHexString(indexP);
     52    throw new Test262Error('#' + hexP + ' ');
     53  }
     54  throw new Test262Error('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' ');
     55 }
     56 
     57 reportCompare(0, 0);