js/xpconnect/tests/mochitest/test_bug940783.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial