test_parse_importMap_failed.html (1055B)
1 <!DOCTYPE html> 2 <head> 3 <meta charset=utf-8> 4 <title>Test the error message when parsing import maps failed</title> 5 </head> 6 <body onload='testLoaded()'> 7 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 8 9 <script> 10 // eslint-disable-next-line no-unused-vars 11 let gotMsg = false; 12 window.onerror = function(event, src, lineno, colno, error) { 13 info("error: " + error.message); 14 ok(error instanceof SyntaxError, "error should be SyntaxError."); 15 ok(error.message.match(/import map/), 16 "error.message should contain 'import map'"); 17 gotMsg = true; 18 }; 19 </script> 20 21 <!-- 22 An import map with invalid JSON format. A SyntaxError will be thrown when parsing 23 the import map. 24 --> 25 <script type="importmap" onerror='importMapError()'> 26 { 27 "imports": {{ 28 "foo": "./foo.js" 29 } 30 } 31 </script> 32 33 <script> 34 SimpleTest.waitForExplicitFinish(); 35 /* global gotMsg */ 36 37 // eslint-disable-next-line no-unused-vars 38 function testLoaded() { 39 ok(gotMsg, "Should have thrown a SyntaxError."); 40 SimpleTest.finish(); 41 } 42 </script> 43 </body>