test_bug696301-1.html (2567B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=696301 5 --> 6 <head> 7 <meta charset="utf-8"> 8 <title>Test for Bug 696301</title> 9 <script src="/tests/SimpleTest/SimpleTest.js"></script> 10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 11 </head> 12 <body> 13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=696301">Mozilla Bug 696301</a> 14 <p id="display"></p> 15 <div id="content" style="display: none"> 16 17 </div> 18 <pre id="test"> 19 <script type="application/javascript"> 20 var errorFired = false; 21 var global = ""; 22 window.onerror = function(message, uri, line) { 23 is(message, "Script error.", "Should have empty error message"); 24 is(uri, 25 "http://example.com/tests/dom/base/test/bug696301-script-1.js", 26 "Should have correct script URI"); 27 is(line, 0, "Shouldn't have a line here"); 28 errorFired = true; 29 } 30 </script> 31 <script src="http://example.com/tests/dom/base/test/bug696301-script-1.js"></script> 32 <script> 33 is(errorFired, true, "Should have error in different origin script"); 34 is(global, "ran", "Different origin script should have run"); 35 </script> 36 37 <script type="application/javascript"> 38 errorFired = false; 39 global = ""; 40 window.onerror = function(message, uri, line) { 41 is(message, "ReferenceError: c is not defined", "Should have correct error message"); 42 is(uri, 43 "http://example.com/tests/dom/base/test/bug696301-script-1.js", 44 "Should also have correct script URI"); 45 is(line, 3, "Should have a line here"); 46 errorFired = true; 47 } 48 </script> 49 <script src="http://example.com/tests/dom/base/test/bug696301-script-1.js" 50 crossorigin></script> 51 <script> 52 is(errorFired, true, "Should have error in different origin script with CORS"); 53 is(global, "ran", "Different origin script with CORS should have run"); 54 </script> 55 56 <script type="application/javascript"> 57 errorFired = false; 58 global = ""; 59 window.addEventListener("error", function(e) { 60 is(Object.getPrototypeOf(e), Event.prototype, 61 "Object prototype should be Event"); 62 var externalScripts = document.querySelectorAll("script[src]"); 63 is(e.target, externalScripts[externalScripts.length - 1], 64 "Event's target should be the right <script>"); 65 errorFired = true; 66 }, true); 67 </script> 68 <script src="http://example.com/tests/dom/base/test/bug696301-script-2.js" 69 crossorigin></script> 70 <script> 71 is(errorFired, true, 72 "Should have error when different origin script fails CORS check"); 73 is(global, "", "Different origin script that fails CORS should not have run"); 74 </script> 75 76 </pre> 77 </body> 78 </html>