1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/xpconnect/tests/mochitest/test_bug940783.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,62 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=940783 1.8 +--> 1.9 +<head> 1.10 + <meta charset="utf-8"> 1.11 + <title>Test for Bug 940783</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 + <script type="application/javascript"> 1.15 + 1.16 + /** Test for Bug 940783 **/ 1.17 + SimpleTest.waitForExplicitFinish(); 1.18 + 1.19 + function checkHistoryThrows(hist) { 1.20 + checkThrows(function() { hist.length; }); 1.21 + checkThrows(function() { hist.state; }); 1.22 + checkThrows(function() { hist.go(); }); 1.23 + checkThrows(function() { hist.back(); }); 1.24 + checkThrows(function() { hist.forward(); }); 1.25 + checkThrows(function() { hist.pushState({}, "foo"); }); 1.26 + checkThrows(function() { hist.replaceState({}, "foo"); }); 1.27 + 1.28 + } 1.29 + 1.30 + window.gLoads = 0; 1.31 + function load() { 1.32 + var iwin = $('ifr').contentWindow; 1.33 + ++gLoads; 1.34 + if (gLoads == 1) { 1.35 + window.gHist = iwin.history; 1.36 + iwin.location = "file_empty.html"; 1.37 + } else if (gLoads == 2) { 1.38 + checkHistoryThrows(gHist); 1.39 + window.gHist = iwin.history; 1.40 + iwin.location = "http://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html"; 1.41 + } else { 1.42 + checkHistoryThrows(gHist); 1.43 + $('ifr').setAttribute('onload', null); 1.44 + SimpleTest.finish(); 1.45 + } 1.46 + } 1.47 + 1.48 + function checkThrows(fn) { 1.49 + try { fn(); ok(false, "Should have thrown: " + fn.toSource()); } 1.50 + catch (e) { ok(!!/denied|insecure/.exec(e), "Threw correctly: " + e); } 1.51 + } 1.52 + 1.53 + </script> 1.54 +</head> 1.55 +<body> 1.56 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=940783">Mozilla Bug 940783</a> 1.57 +<p id="display"></p> 1.58 +<div id="content" style="display: none"> 1.59 +<iframe id="ifr" onload="load();" src="file_empty.html"></iframe> 1.60 + 1.61 +</div> 1.62 +<pre id="test"> 1.63 +</pre> 1.64 +</body> 1.65 +</html>