1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/tests/mochitest/general/test_showModalDialog.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,60 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=862918 1.8 +--> 1.9 +<head> 1.10 + <meta charset="utf-8"> 1.11 + <title>Test for Bug 862918</title> 1.12 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.13 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.14 + <script type="application/javascript"> 1.15 + 1.16 + /** Test for window.showModalDialog. **/ 1.17 + 1.18 + // The modal window needs to touch Cu, which means that it needs 1.19 + // SpecialPowers. But given the semantics of modal windows, we have to 1.20 + // do some funny stuff with postMessage to set this up. 1.21 + window.onmessage = function(evt) { 1.22 + is(evt.data, 'dosetup', "message from modal window is correct"); 1.23 + var win = SpecialPowers.wrap(evt.source); 1.24 + win.wrappedJSObject.SpecialPowers = SpecialPowers; 1.25 + win.wrappedJSObject.is = SpecialPowers.wrap(is); 1.26 + win.wrappedJSObject.ok = SpecialPowers.wrap(ok); 1.27 + win.wrappedJSObject.go(); 1.28 + }; 1.29 + 1.30 + var someObj = { foo: 42, bar: "hi"}; 1.31 + var xurl = location.toString() 1.32 + .replace('mochi.test:8888', 'example.org') 1.33 + .replace('test_showModal', 'file_showModal'); 1.34 + if (xurl.indexOf('?') != -1) 1.35 + xurl = xurl.substring(0, xurl.indexOf('?')); 1.36 + is(showModalDialog('file_showModalDialog.html'), "rv: undefined"); 1.37 + is(showModalDialog(xurl), undefined); 1.38 + is(showModalDialog('file_showModalDialog.html', 3), "rv: 3"); 1.39 + is(showModalDialog(xurl, 3), undefined); 1.40 + is(showModalDialog('file_showModalDialog.html', someObj), "rv: " + someObj); 1.41 + is(showModalDialog(xurl, someObj), undefined); 1.42 + 1.43 + // Test sequential navigations. 1.44 + is(showModalDialog('file_showModalDialog.html?http://mochi.test:8888', 4), 1.45 + 'rv: 4'); 1.46 + is(showModalDialog('file_showModalDialog.html?http://example.com', 4), undefined); 1.47 + is(showModalDialog('file_showModalDialog.html?http://example.com,http://mochi.test:8888', 4), 'rv: 4'); 1.48 + 1.49 + // This test used to assert after gc. Make sure it doesn't. 1.50 + SpecialPowers.gc(); 1.51 + 1.52 + </script> 1.53 +</head> 1.54 +<body> 1.55 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=862918">Mozilla Bug 862918</a> 1.56 +<p id="display"></p> 1.57 +<div id="content" style="display: none"> 1.58 + 1.59 +</div> 1.60 +<pre id="test"> 1.61 +</pre> 1.62 +</body> 1.63 +</html>