tor-browser

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

S15.1.3.3_A1.1_T2.js (1458B)


      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 string.charAt(k) in [0xDC00 - 0xDFFF], throw URIError
      6 esid: sec-encodeuri-uri
      7 description: Complex tests
      8 includes: [decimalToHexString.js]
      9 ---*/
     10 
     11 var errorCount = 0;
     12 var count = 0;
     13 var indexP;
     14 var indexO = 0;
     15 
     16 for (var index = 0xDC00; index <= 0xDFFF; index++) {
     17  count++;
     18  try {
     19    encodeURI(String.fromCharCode(index, 0x0041));
     20  } catch (e) {
     21    if ((e instanceof URIError) === true) continue;
     22  }
     23  if (indexO === 0) {
     24    indexO = index;
     25  } else {
     26    if ((index - indexP) !== 1) {
     27      if ((indexP - indexO) !== 0) {
     28        var hexP = decimalToHexString(indexP);
     29        var hexO = decimalToHexString(indexO);
     30        throw new Test262Error('#' + hexO + '-' + hexP + ' ');
     31      }
     32      else {
     33        var hexP = decimalToHexString(indexP);
     34        throw new Test262Error('#' + hexP + ' ');
     35      }
     36      indexO = index;
     37    }
     38  }
     39  indexP = index;
     40  errorCount++;
     41 }
     42 
     43 if (errorCount > 0) {
     44  if ((indexP - indexO) !== 0) {
     45    var hexP = decimalToHexString(indexP);
     46    var hexO = decimalToHexString(indexO);
     47    throw new Test262Error('#' + hexO + '-' + hexP + ' ');
     48  } else {
     49    var hexP = decimalToHexString(indexP);
     50    throw new Test262Error('#' + hexP + ' ');
     51  }
     52  throw new Test262Error('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' ');
     53 }
     54 
     55 reportCompare(0, 0);