dom/tests/mochitest/general/test_showModalDialog.html

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:298a4086f8e1
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=862918
5 -->
6 <head>
7 <meta charset="utf-8">
8 <title>Test for Bug 862918</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 window.showModalDialog. **/
14
15 // The modal window needs to touch Cu, which means that it needs
16 // SpecialPowers. But given the semantics of modal windows, we have to
17 // do some funny stuff with postMessage to set this up.
18 window.onmessage = function(evt) {
19 is(evt.data, 'dosetup', "message from modal window is correct");
20 var win = SpecialPowers.wrap(evt.source);
21 win.wrappedJSObject.SpecialPowers = SpecialPowers;
22 win.wrappedJSObject.is = SpecialPowers.wrap(is);
23 win.wrappedJSObject.ok = SpecialPowers.wrap(ok);
24 win.wrappedJSObject.go();
25 };
26
27 var someObj = { foo: 42, bar: "hi"};
28 var xurl = location.toString()
29 .replace('mochi.test:8888', 'example.org')
30 .replace('test_showModal', 'file_showModal');
31 if (xurl.indexOf('?') != -1)
32 xurl = xurl.substring(0, xurl.indexOf('?'));
33 is(showModalDialog('file_showModalDialog.html'), "rv: undefined");
34 is(showModalDialog(xurl), undefined);
35 is(showModalDialog('file_showModalDialog.html', 3), "rv: 3");
36 is(showModalDialog(xurl, 3), undefined);
37 is(showModalDialog('file_showModalDialog.html', someObj), "rv: " + someObj);
38 is(showModalDialog(xurl, someObj), undefined);
39
40 // Test sequential navigations.
41 is(showModalDialog('file_showModalDialog.html?http://mochi.test:8888', 4),
42 'rv: 4');
43 is(showModalDialog('file_showModalDialog.html?http://example.com', 4), undefined);
44 is(showModalDialog('file_showModalDialog.html?http://example.com,http://mochi.test:8888', 4), 'rv: 4');
45
46 // This test used to assert after gc. Make sure it doesn't.
47 SpecialPowers.gc();
48
49 </script>
50 </head>
51 <body>
52 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=862918">Mozilla Bug 862918</a>
53 <p id="display"></p>
54 <div id="content" style="display: none">
55
56 </div>
57 <pre id="test">
58 </pre>
59 </body>
60 </html>

mercurial