content/html/document/test/test_bug172261.html

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:92fcc8cdeed8
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=172261
5 -->
6 <head>
7 <title>Test for Bug 172261</title>
8 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
10 </head>
11 <body>
12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=172261">Mozilla Bug 172261</a>
13 <p id="display">
14 <iframe id="test"></iframe>
15 </p>
16 <div id="content" style="display: none">
17
18 </div>
19 <pre id="test">
20 <script class="testbody" type="text/javascript">
21 /** Test for Bug 172261 **/
22 SimpleTest.waitForExplicitFinish();
23
24 var callable = false;
25 function toggleCallable() { callable = true; }
26
27 var doTestInIframe = false;
28
29 // Shouldn't do history stuff from inside onload
30 addLoadEvent(function() { setTimeout(startTest, 10) });
31
32 function startTest() {
33 // First, create a dummy document. Use onunload handlers to make sure
34 // bfcache doesn't screw us up.
35 var doc = $("test").contentDocument;
36
37 doc.write("<html><body onunload=''>First</body></html>");
38 doc.close();
39
40 // Now write our test document
41 doc.write("<html><script>window.onerror = parent.onerror; if (parent.doTestInIframe) { parent.is(document.domain, parent.document.domain, 'Domains should match'); parent.toggleCallable(); } <" + "/script><body>Second</body></html>");
42 doc.close();
43
44 $("test").onload = goForward;
45 history.back();
46 }
47
48 function goForward() {
49 $("test").onload = doTest;
50 doTestInIframe = true;
51 history.forward();
52 }
53
54 function doTest() {
55 is($("test").contentDocument.domain, document.domain,
56 "Domains should match 2");
57 is($("test").contentDocument.location.href, location.href,
58 "Locations should match");
59 is(callable, true, "Subframe should be able to call us");
60 SimpleTest.finish();
61 }
62 </script>
63 </pre>
64 </body>
65 </html>
66

mercurial