test_bug143220.html (1903B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=143220 5 --> 6 <head> 7 <title>Test for Bug 143220</title> 8 <script 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=143220">Mozilla Bug 143220</a> 13 <p id="display"> 14 <input type="file" id="i1"> 15 <input type="file" id="i2"> 16 </p> 17 <div id="content" style="display: none"> 18 19 </div> 20 <pre id="test"> 21 <script class="testbody" type="text/javascript"> 22 23 /** Test for Bug 143220 */ 24 SimpleTest.waitForExplicitFinish(); 25 const helperURL = SimpleTest.getTestFileURL("simpleFileOpener.js"); 26 const helper = SpecialPowers.loadChromeScript(helperURL); 27 helper.addMessageListener("fail", function onFail(message) { 28 is(message, null, "chrome script failed"); 29 SimpleTest.finish(); 30 }); 31 helper.addMessageListener("file.opened", onFileOpened); 32 helper.sendAsyncMessage("file.open", "test_bug143220.txt"); 33 34 function onFileOpened(message) { 35 const { leafName, fullPath, domFile } = message; 36 37 function initControl1() { 38 SpecialPowers.wrap($("i1")).mozSetFileArray([domFile]); 39 } 40 41 function initControl2() { 42 SpecialPowers.wrap($("i2")).mozSetFileArray([domFile]); 43 } 44 45 // Check that we can't just set the value 46 try { 47 $("i1").value = fullPath; 48 is(0, 1, "Should have thrown exception on set!"); 49 } catch(e) { 50 is($("i1").value, "", "Shouldn't have value here"); 51 } 52 53 initControl1(); 54 initControl2(); 55 56 is($("i1").value, 'C:\\fakepath\\' + leafName, "Leaking full value?"); 57 is($("i2").value, 'C:\\fakepath\\' + leafName, "Leaking full value?"); 58 59 helper.addMessageListener("file.removed", onFileRemoved); 60 helper.sendAsyncMessage("file.remove", null); 61 } 62 63 function onFileRemoved() { 64 helper.destroy(); 65 SimpleTest.finish(); 66 } 67 68 </script> 69 </pre> 70 </body> 71 </html>