dom/tests/mochitest/general/test_showModalDialog.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial