tor-browser

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

errorcolumnblame.js (2020B)


      1 /*
      2 * Any copyright is dedicated to the Public Domain.
      3 * http://creativecommons.org/licenses/publicdomain/
      4 */
      5 
      6 // SKIP test262 export
      7 // columnNumber is not specified.
      8 
      9 var BUGNUMBER = 568142;
     10 var summary = 'error reporting blames column as well as line';
     11 
     12 function test(f, col) {
     13    var caught = false;
     14    try {
     15        f();
     16    } catch (e) {
     17        caught = true;
     18        assertEq(e.columnNumber, col);
     19    }
     20    assertEq(caught, true);
     21 }
     22 
     23 /* Note single hard tab before return! */
     24 function foo(o) {
     25 return o.p;
     26 }
     27 test(foo, 2);
     28 
     29 //345678901234567890
     30 test(function(f) { return f.bar; }, 20);
     31 //       1         2
     32 //3456789012345678901234567
     33 test(function(f) { return f(); }, 27);
     34 /* Cover negative colspan case using for(;;) loop with error in update part. */
     35 test(function(){
     36        //         1         2         3         4
     37        //123456789012345678901234567890123456789012
     38    eval("function baz() { for (var i = 0; i < 10; i += a.b); assertEq(i !== i, true); }");
     39    baz();
     40 }, 42);
     41 
     42 //       1         2         3
     43 //3456789012345678901234567890123456
     44 test(function() { var tmp = null; tmp(); }, 35)
     45 test(function() { var tmp = null;  tmp.foo; }, 36)
     46 
     47 /* Just a generic 'throw'. */
     48 test(function() {
     49 //       1         2
     50 //345678901234567890
     51    foo({}); throw new Error('a');
     52 }, 20);
     53 
     54 /* Be sure to report the right statement */
     55 test(function() {
     56    function f() { return true; }
     57    function g() { return false; }
     58 //       1         2
     59 //345678901234567890123456789
     60    f(); g(); f(); if (f()) a += e;
     61 }, 29);
     62 
     63 //       1         2
     64 //345678901234567890
     65 test(function() { e++; }, 19);
     66 test(function() {print += e; }, 18);
     67 test(function(){e += 1 }, 17);
     68 test(function() {  print[e]; }, 20);
     69 test(function() { e[1]; }, 19);
     70 test(function() { e(); }, 19);
     71 test(function() { 1(); }, 20);
     72 test(function() { Object.defineProperty() }, 26);
     73 
     74 test(function() {
     75 //       1         2
     76 //34567890123456789012
     77    function foo() { asdf; } foo()
     78 }, 22);
     79 
     80 reportCompare(0, 0, "ok");
     81 
     82 printStatus("All tests passed!");