1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/tests/mochitest/whatwg/test_postMessage_throw.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,74 @@ 1.4 +<!DOCTYPE html> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=postMessage 1.8 +--> 1.9 +<head> 1.10 + <title>postMessage with a thrown exception</title> 1.11 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.13 +</head> 1.14 +<body> 1.15 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=postMessage">Mozilla Bug 387706</a> 1.16 +<p id="display"></p> 1.17 +<div id="content" style="display: none"></div> 1.18 + 1.19 +<iframe src="http://mochi.test:8888/tests/dom/tests/mochitest/whatwg/postMessage_throw_helper.html" 1.20 + name="sameDomain"></iframe> 1.21 +<iframe src="http://example.org:8000/tests/dom/tests/mochitest/whatwg/postMessage_throw_helper.html" 1.22 + name="crossDomain"></iframe> 1.23 + 1.24 + 1.25 +<pre id="test"> 1.26 +<script class="testbody" type="application/javascript"> 1.27 +/** Test for Bug 387706 **/ 1.28 + 1.29 +SimpleTest.waitForExplicitFinish(); 1.30 + 1.31 +function atLoad() 1.32 +{ 1.33 + try 1.34 + { 1.35 + sameDomain.postMessage("foo", "http://mochi.test:8888"); 1.36 + ok(true, "should not have thrown for same-domain exception"); 1.37 + } 1.38 + catch (e) 1.39 + { 1.40 + ok(false, "uh-oh, threw a same-domain exception: " + e); 1.41 + } 1.42 + 1.43 + setTimeout(next, 0); 1.44 +} 1.45 + 1.46 +function next() 1.47 +{ 1.48 + ok(true, "no pending-exception wackiness for same-domain"); 1.49 + setTimeout(next2, 0); 1.50 +} 1.51 + 1.52 +function next2() 1.53 +{ 1.54 + try 1.55 + { 1.56 + crossDomain.postMessage("foo", "http://example.org:8000"); 1.57 + ok(true, "should not have thrown for cross-domain exception"); 1.58 + } 1.59 + catch (e) 1.60 + { 1.61 + ok(false, "uh-oh, threw a cross-domain exception: " + e); 1.62 + } 1.63 + 1.64 + setTimeout(next3, 0); 1.65 +} 1.66 + 1.67 +function next3() 1.68 +{ 1.69 + ok(true, "no pending-exception wackiness for cross-domain"); 1.70 + SimpleTest.finish(); 1.71 +} 1.72 + 1.73 +addLoadEvent(atLoad); 1.74 +</script> 1.75 +</pre> 1.76 +</body> 1.77 +</html>