1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/base/test/test_bug696301-1.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,78 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=696301 1.8 +--> 1.9 +<head> 1.10 + <meta charset="utf-8"> 1.11 + <title>Test for Bug 696301</title> 1.12 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.13 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.14 +</head> 1.15 +<body> 1.16 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=696301">Mozilla Bug 696301</a> 1.17 +<p id="display"></p> 1.18 +<div id="content" style="display: none"> 1.19 + 1.20 +</div> 1.21 +<pre id="test"> 1.22 +<script type="application/javascript"> 1.23 +var errorFired = false; 1.24 +var global = ""; 1.25 +window.onerror = function(message, uri, line) { 1.26 + is(message, "Script error.", "Should have empty error message"); 1.27 + is(uri, 1.28 + "http://example.com/tests/content/base/test/bug696301-script-1.js", 1.29 + "Should have correct script URI"); 1.30 + is(line, 0, "Shouldn't have a line here"); 1.31 + errorFired = true; 1.32 +} 1.33 +</script> 1.34 +<script src="http://example.com/tests/content/base/test/bug696301-script-1.js"></script> 1.35 +<script> 1.36 + is(errorFired, true, "Should have error in different origin script"); 1.37 + is(global, "ran", "Different origin script should have run"); 1.38 +</script> 1.39 + 1.40 +<script type="application/javascript"> 1.41 +errorFired = false; 1.42 +global = ""; 1.43 +window.onerror = function(message, uri, line) { 1.44 + is(message, "ReferenceError: c is not defined", "Should have correct error message"); 1.45 + is(uri, 1.46 + "http://example.com/tests/content/base/test/bug696301-script-1.js", 1.47 + "Should also have correct script URI"); 1.48 + is(line, 3, "Should have a line here"); 1.49 + errorFired = true; 1.50 +} 1.51 +</script> 1.52 +<script src="http://example.com/tests/content/base/test/bug696301-script-1.js" 1.53 + crossorigin></script> 1.54 +<script> 1.55 + is(errorFired, true, "Should have error in different origin script with CORS"); 1.56 + is(global, "ran", "Different origin script with CORS should have run"); 1.57 +</script> 1.58 + 1.59 +<script type="application/javascript"> 1.60 +errorFired = false; 1.61 +global = ""; 1.62 +window.addEventListener("error", function(e) { 1.63 + is(Object.getPrototypeOf(e), Event.prototype, 1.64 + "Object prototype should be Event"); 1.65 + var externalScripts = document.querySelectorAll("script[src]"); 1.66 + is(e.target, externalScripts[externalScripts.length - 1], 1.67 + "Event's target should be the right <script>"); 1.68 + errorFired = true; 1.69 +}, true); 1.70 +</script> 1.71 +<script src="http://example.com/tests/content/base/test/bug696301-script-2.js" 1.72 + crossorigin></script> 1.73 +<script> 1.74 + is(errorFired, true, 1.75 + "Should have error when different origin script fails CORS check"); 1.76 + is(global, "", "Different origin script that fails CORS should not have run"); 1.77 +</script> 1.78 + 1.79 +</pre> 1.80 +</body> 1.81 +</html>