Thu, 22 Jan 2015 13:21:57 +0100
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=345339 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 345339</title> |
michael@0 | 8 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 9 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 10 | </head> |
michael@0 | 11 | <body> |
michael@0 | 12 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=345339">Mozilla Bug 345339</a> |
michael@0 | 13 | <p id="display"></p> |
michael@0 | 14 | <div id="content" style="display: none"> |
michael@0 | 15 | </div> |
michael@0 | 16 | <iframe id="testframe" |
michael@0 | 17 | src="http://mochi.test:8888/tests/content/base/test/345339_iframe.html"> |
michael@0 | 18 | </iframe> |
michael@0 | 19 | <pre id="test"> |
michael@0 | 20 | <script class="testbody" type="text/javascript"> |
michael@0 | 21 | /** Test for Bug 345339 **/ |
michael@0 | 22 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 23 | |
michael@0 | 24 | var filePath; |
michael@0 | 25 | |
michael@0 | 26 | function afterLoad() { |
michael@0 | 27 | var iframeDoc = $("testframe").contentDocument; |
michael@0 | 28 | |
michael@0 | 29 | /* change all the form controls */ |
michael@0 | 30 | iframeDoc.getElementById("select").selectedIndex = 1; |
michael@0 | 31 | iframeDoc.getElementById("radio2").checked = true; |
michael@0 | 32 | iframeDoc.getElementById("password").value = "123456"; |
michael@0 | 33 | iframeDoc.getElementById("hidden").value = "gecko"; |
michael@0 | 34 | |
michael@0 | 35 | var file = SpecialPowers.Cc["@mozilla.org/file/directory_service;1"] |
michael@0 | 36 | .getService(SpecialPowers.Ci.nsIProperties) |
michael@0 | 37 | .get("TmpD", SpecialPowers.Ci.nsILocalFile); |
michael@0 | 38 | file.append("345339_test.file"); |
michael@0 | 39 | file.createUnique(SpecialPowers.Ci.nsIFile.NORMAL_FILE_TYPE, 0666); |
michael@0 | 40 | filePath = file.path; |
michael@0 | 41 | |
michael@0 | 42 | SpecialPowers.wrap(iframeDoc).getElementById("file").value = filePath; |
michael@0 | 43 | |
michael@0 | 44 | /* Reload the page */ |
michael@0 | 45 | $("testframe").setAttribute("onload", "afterReload()"); |
michael@0 | 46 | iframeDoc.location.reload(); |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | addLoadEvent(afterLoad); |
michael@0 | 50 | |
michael@0 | 51 | function afterReload() { |
michael@0 | 52 | var iframeDoc = $("testframe").contentDocument; |
michael@0 | 53 | |
michael@0 | 54 | is(iframeDoc.getElementById("select").selectedIndex, 1, |
michael@0 | 55 | "select element selected index preserved"); |
michael@0 | 56 | is(iframeDoc.getElementById("radio1").checked, false, |
michael@0 | 57 | "radio button #1 value preserved"); |
michael@0 | 58 | is(iframeDoc.getElementById("radio2").checked, true, |
michael@0 | 59 | "radio button #2 value preserved"); |
michael@0 | 60 | isnot(iframeDoc.getElementById("password").value, "123456", |
michael@0 | 61 | "password field value forgotten"); |
michael@0 | 62 | is(iframeDoc.getElementById("hidden").value, "gecko", |
michael@0 | 63 | "hidden field value preserved"); |
michael@0 | 64 | is(SpecialPowers.wrap(iframeDoc).getElementById("file").value, filePath, |
michael@0 | 65 | "file field value preserved"); |
michael@0 | 66 | |
michael@0 | 67 | SimpleTest.finish(); |
michael@0 | 68 | } |
michael@0 | 69 | </script> |
michael@0 | 70 | </pre> |
michael@0 | 71 | </body> |
michael@0 | 72 | </html> |
michael@0 | 73 |