tor-browser

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

bug791465.js (1405B)


      1 load(libdir + "asserts.js");
      2 
      3 var valid_strict_funs = [
      4  // directive ends on next line
      5  function () {
      6    "use strict"
      7    ;
      8  },
      9  function () {
     10    "use strict"
     11  },
     12  // directive ends on same line
     13  function () { "use strict"; },
     14  function () { "use strict" },
     15 ];
     16 
     17 for (var f of valid_strict_funs) {
     18  assertThrowsInstanceOf(function() { f.caller }, TypeError);
     19 }
     20 
     21 
     22 var binary_ops = [
     23  "||", "&&",
     24  "|", "^", "&",
     25  "==", "!=", "===", "!==",
     26  "<", "<=", ">", ">=", "in", "instanceof",
     27  "<<", ">>", ">>>",
     28  "+", "-",
     29  "*", "/", "%",
     30 ];
     31 
     32 var invalid_strict_funs = [
     33  function () {
     34    "use strict"
     35    , "not";
     36  },
     37  function () {
     38    "use strict"
     39    ? 1 : 0;
     40  },
     41  function () {
     42    "use strict"
     43    .length;
     44  },
     45  function () {
     46    "use strict"
     47    [0];
     48  },
     49  function () {
     50    "use strict"
     51    ();
     52  },
     53  ...([]),
     54  ...(binary_ops.map(op => Function("'use strict'\n " + op + " 'not'"))),
     55 ];
     56 
     57 for (var f of invalid_strict_funs) {
     58  f.caller;
     59 }
     60 
     61 
     62 var assignment_ops = [
     63   "=", "+=", "-=",
     64  "|=", "^=", "&=",
     65  "<<=", ">>=", ">>>=",
     66  "*=", "/=", "%=",
     67 ];
     68 
     69 var invalid_strict_funs_syntax_error = assignment_ops.map(op => ("'use strict'\n " + op + " 'not'"));
     70 
     71 // assignment with string literal as LHS is an early error, therefore we
     72 // can only test for SyntaxError
     73 for (var f of invalid_strict_funs_syntax_error) {
     74  assertThrowsInstanceOf(function() { Function(f) }, SyntaxError);
     75 }