tor-browser

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

assorted.js (1504B)


      1 // Reflect.parse Latin1
      2 var ast = Reflect.parse("function f() { return 3; }");
      3 assertEq(ast.body[0].id.name, "f");
      4 assertEq(isLatin1(ast.body[0].id.name), true);
      5 
      6 // Reflect.parse TwoByte
      7 var ast = Reflect.parse("function f\u1200() { return 3; }");
      8 assertEq(ast.body[0].id.name, "f\u1200");
      9 
     10 if (Object.prototype.toSource) {
     11  // obj.toSource Latin1
     12  var o = {};
     13  Object.defineProperty(o, "prop", {get: function() { return 1; },
     14                                    set: function() { return 2; },
     15                                    enumerable: true, configurable: true});
     16  assertEq(o.toSource(), "({get prop() { return 1; }, set prop() { return 2; }})");
     17 
     18  // obj.toSource TwoByte
     19  Object.defineProperty(o, "prop", {get: function() { return "\u1200"; },
     20                                    set: function() { return "\u1200"; },
     21                                    enumerable: true});
     22  assertEq(o.toSource(), '({get prop() { return "\\u1200"; }, set prop() { return "\\u1200"; }})');
     23 
     24  var ff = function() { return 10; };
     25  ff.toSource = function() { return "((11))"; }
     26  Object.defineProperty(o, "prop", {get: ff, set: ff, enumerable: true});
     27  assertEq(o.toSource(), "({get prop(11), set prop(11)})");
     28 }
     29 
     30 // XDR
     31 load(libdir + 'bytecode-cache.js');
     32 
     33 // Latin1 string constant
     34 test = "'string123';";
     35 evalWithCache(test, { assertEqBytecode: true, assertEqResult : true });
     36 
     37 // TwoByte string constant
     38 test = "'string\u1234';";
     39 evalWithCache(test, { assertEqBytecode: true, assertEqResult : true });