OLD | NEW |
(Empty) | |
| 1 <!doctype HTML> |
| 2 <html> |
| 3 <head> |
| 4 <title>html-script-module-errored</title> |
| 5 <script src="/resources/testharness.js"></script> |
| 6 <script src="/resources/testharnessreport.js"></script> |
| 7 |
| 8 <script> |
| 9 // The case where Step 6 of |
| 10 // https://html.spec.whatwg.org/#internal-module-script-graph-fetching-procedure |
| 11 // fails. In such cases, fetch a module script graph returns a non-null |
| 12 // module script with instantiation state = "errored" |
| 13 // and module record = null. |
| 14 |
| 15 setup({allow_uncaught_exception:true}); |
| 16 internals.runtimeFlags.moduleScriptsEnabled = true; |
| 17 |
| 18 var test1 = async_test('foo'); |
| 19 |
| 20 var isWindowOnErrorCalled = false; |
| 21 |
| 22 window.addEventListener("error", test1.step_func(function(ev) { |
| 23 console.log(ev); |
| 24 console.log(ev.error); |
| 25 |
| 26 assert_false(isWindowOnErrorCalled, |
| 27 "window's error event shouldn't be fired twice"); |
| 28 isWindowOnErrorCalled = true; |
| 29 |
| 30 for (var a in ev) { |
| 31 console.log(a + " => " + ev[a]); |
| 32 } |
| 33 |
| 34 assert_true(ev.filename.endsWith("errored-root.js"), |
| 35 "window's error event's filename is set correctly"); |
| 36 assert_equals(ev.message, |
| 37 "Uncaught SyntaxError: The requested module does not " + |
| 38 "provide an export named 'default'", |
| 39 "window's error event is fired for instantiation error"); |
| 40 })); |
| 41 |
| 42 var scriptOnLoad = test1.step_func_done(function() { |
| 43 assert_true(isWindowOnErrorCalled, |
| 44 "window's error event should be fired"); |
| 45 }); |
| 46 |
| 47 function unreached() { |
| 48 test1.step(function() { |
| 49 assert_unreached("script's error event should not be fired"); |
| 50 }); |
| 51 } |
| 52 </script> |
| 53 <script type="module" src="errored-root.js" onerror="unreached()" onload="script
OnLoad()"></script> |
| 54 <script type="module" src="errored-root.js" onerror="unreached()" onload="script
OnLoad()"></script> |
| 55 <script> |
| 56 testRunner.waitUntilDone(); |
| 57 setTimeout(() => {testRunner.notifyDone();}, 100); |
| 58 </script> |
OLD | NEW |