dom/tests/mochitest/dom-level0/test_location_setters.html

branch
TOR_BUG_9701
changeset 9
a63d609f5ebe
equal deleted inserted replaced
-1:000000000000 0:9a6a1a10f805
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=639720
5 -->
6 <head>
7 <title>Test for Bug 639720</title>
8 <script type="application/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=639720">Mozilla Bug 639720</a>
13 <p id="display">
14 <iframe id="f"></iframe>
15 </p>
16 <div id="content" style="display: none">
17
18 </div>
19 <pre id="test">
20 <script type="application/javascript">
21
22 /** Test for Bug 639720 **/
23 SimpleTest.waitForExplicitFinish();
24
25 var tests = [
26 { url: "data:text/plain,1" },
27 { url: "data:text/plain,2",
28 useDocument: true },
29 { prepURL: "http://www.example.com",
30 url: "data:text/plain,3" }
31 ];
32
33 var currentTest = 0;
34
35 function checkTest() {
36 is($("f").contentWindow.location.href, tests[currentTest].url,
37 "href of content window's location should match url of current test");
38 ++currentTest;
39 runNextTest();
40 }
41
42 function runCurrentTest() {
43 var test = tests[currentTest];
44 $("f").onload = checkTest;
45 if (test.useDocument) {
46 $("f").contentDocument.location = test.url;
47 } else {
48 $("f").contentWindow.location = test.url;
49 }
50 is(typeof($("f").contentWindow.location), "object",
51 "Location should not have become string");
52 }
53
54 function prepComplete() {
55 runCurrentTest();
56 }
57
58 function runNextTest() {
59 if (currentTest == tests.length) {
60 SimpleTest.finish();
61 return;
62 }
63
64 var test = tests[currentTest];
65 if ("prepURL" in test) {
66 $("f").onload = prepComplete;
67 $("f").src = test.prepURL;
68 return;
69 }
70
71 runCurrentTest();
72 }
73
74 addLoadEvent(runNextTest);
75 </script>
76 </pre>
77 </body>
78 </html>

mercurial