tor-browser

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

bug507180.js (1693B)


      1 var o = {
      2  valueOf : function() {
      3    return {
      4      toString : function() { return "fail" }
      5    }
      6  },
      7  toString : function() { return "good" }
      8 };
      9 
     10 var p = {
     11  valueOf : function() {
     12    return {
     13      toString : function() { return "0" }
     14    }
     15  },
     16  toString : function() { return "7" }
     17 };
     18 
     19 var q = {
     20  toString : function() {
     21    return {
     22      valueOf : function() { return "0" }
     23    }
     24  },
     25  valueOf : function() { return "7" }
     26 };
     27 
     28 function assert(b, s) {
     29    if (b)
     30        return;
     31    assertEq("imacro produces incorrect result for " + s, "fail");
     32 }
     33 
     34 function run() {
     35    for (var i = 0; i < 5; ++i) {
     36        // equality / inequality
     37        assert(!(o == "fail"), "obj == any");
     38        assert(!("fail" == o), "any == obj");
     39        assert(!(o != "good"), "obj != any");
     40        assert(!("good" != o), "any != obj");
     41 
     42        // binary
     43        assert(!((p | 3) != 7), "obj | any");
     44        assert(!((3 | p) != 7), "any | obj");
     45        assert(!((p | p) != 7), "obj | obj");
     46        assert(!((p & 3) != 3), "obj & any");
     47        assert(!((3 & p) != 3), "any & obj");
     48        assert(!((p & p) != 7), "obj & obj");
     49        assert(!((p * 3) != 21), "obj * any");
     50        assert(!((3 * p) != 21), "any * obj");
     51        assert(!((p * p) != 49), "obj * obj");
     52 
     53        // addition
     54        assert(!(o + "" != "good"), "obj + any");
     55        assert(!("" + o != "good"), "any + obj");
     56        assert(!(o + o != "goodgood"), "any + any");
     57 
     58        // sign
     59        assert(!(-p != -7), "-obj");
     60        assert(!(+p != 7), "+obj");
     61 
     62        // String
     63        assert(!(String(q) != "7"), "String(obj)");
     64        assert(!(new String(q) != "7"), "new String(obj)");
     65    }
     66    return true;
     67 }
     68 
     69 run();