tor-browser

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

syntax-error.js (1054B)


      1 // |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell)
      2 
      3 let sr = new ShadowRealm();
      4 
      5 try {
      6    sr.evaluate("var x /");
      7    assertEq(true, false, "Should have thrown");
      8 } catch (e) {
      9    assertEq(e instanceof SyntaxError, true, "Same Global Error")
     10    assertEq(/unterminated regular expression literal/.test(e.message), true, "Should have reported a sensible error message");
     11 }
     12 
     13 try {
     14    sr.evaluate("var x =");
     15    assertEq(true, false, "Should have thrown");
     16 } catch (e) {
     17    assertEq(e instanceof SyntaxError, true, "Same Global Error")
     18    assertEq(/expected expression/.test(e.message), true, "Should have reported a sensible error message");
     19 }
     20 
     21 
     22 try {
     23    sr.evaluate("#x in this");
     24    assertEq(true, false, "Should have thrown");
     25 } catch (e) {
     26    assertEq(e instanceof SyntaxError, true, "Same Global Error")
     27    assertEq(/reference to undeclared private field or method/.test(e.message), true, "Should have reported a sensible error message");
     28 }
     29 
     30 
     31 
     32 if (typeof reportCompare === 'function')
     33    reportCompare(true, true);