|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <!-- |
|
4 https://bugzilla.mozilla.org/show_bug.cgi?id=940783 |
|
5 --> |
|
6 <head> |
|
7 <meta charset="utf-8"> |
|
8 <title>Test for Bug 940783</title> |
|
9 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
|
11 <script type="application/javascript"> |
|
12 |
|
13 /** Test for Bug 940783 **/ |
|
14 SimpleTest.waitForExplicitFinish(); |
|
15 |
|
16 function checkHistoryThrows(hist) { |
|
17 checkThrows(function() { hist.length; }); |
|
18 checkThrows(function() { hist.state; }); |
|
19 checkThrows(function() { hist.go(); }); |
|
20 checkThrows(function() { hist.back(); }); |
|
21 checkThrows(function() { hist.forward(); }); |
|
22 checkThrows(function() { hist.pushState({}, "foo"); }); |
|
23 checkThrows(function() { hist.replaceState({}, "foo"); }); |
|
24 |
|
25 } |
|
26 |
|
27 window.gLoads = 0; |
|
28 function load() { |
|
29 var iwin = $('ifr').contentWindow; |
|
30 ++gLoads; |
|
31 if (gLoads == 1) { |
|
32 window.gHist = iwin.history; |
|
33 iwin.location = "file_empty.html"; |
|
34 } else if (gLoads == 2) { |
|
35 checkHistoryThrows(gHist); |
|
36 window.gHist = iwin.history; |
|
37 iwin.location = "http://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html"; |
|
38 } else { |
|
39 checkHistoryThrows(gHist); |
|
40 $('ifr').setAttribute('onload', null); |
|
41 SimpleTest.finish(); |
|
42 } |
|
43 } |
|
44 |
|
45 function checkThrows(fn) { |
|
46 try { fn(); ok(false, "Should have thrown: " + fn.toSource()); } |
|
47 catch (e) { ok(!!/denied|insecure/.exec(e), "Threw correctly: " + e); } |
|
48 } |
|
49 |
|
50 </script> |
|
51 </head> |
|
52 <body> |
|
53 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=940783">Mozilla Bug 940783</a> |
|
54 <p id="display"></p> |
|
55 <div id="content" style="display: none"> |
|
56 <iframe id="ifr" onload="load();" src="file_empty.html"></iframe> |
|
57 |
|
58 </div> |
|
59 <pre id="test"> |
|
60 </pre> |
|
61 </body> |
|
62 </html> |