test_bug914381.html (1844B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=650776 5 --> 6 <head> 7 <meta charset="utf-8"> 8 <title>Test for Bug 914381</title> 9 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 10 <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/> 11 </head> 12 <body> 13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=914381">Mozilla Bug 914381</a> 14 <p id="display"></p> 15 <div id="content" style="display: none"> 16 </div> 17 <pre id="test"> 18 <script type="application/javascript"> 19 function createFileWithData(fileData) { 20 var testFile = Services.dirsvc.get("ProfD", Ci.nsIFile); 21 testFile.append("testBug914381"); 22 23 var outStream = Cc["@mozilla.org/network/file-output-stream;1"].createInstance(Ci.nsIFileOutputStream); 24 outStream.init(testFile, 0x02 | 0x08 | 0x20, // write, create, truncate 25 0o666, 0); 26 outStream.write(fileData, fileData.length); 27 outStream.close(); 28 29 return testFile; 30 } 31 32 /** Test for Bug 914381. File's created in JS using an nsIFile should allow mozGetFullPathInternal calls to succeed */ 33 var file = createFileWithData("Test bug 914381"); 34 35 SpecialPowers.pushPrefEnv({ set: [["dom.file.createInChild", true]]}) 36 .then(() => { 37 return File.createFromNsIFile(file); 38 }) 39 .then(f => { 40 is(f.mozFullPathInternal, undefined, "mozFullPathInternal is undefined from js"); 41 is(f.mozFullPath, file.path, "mozFullPath returns path if created with nsIFile"); 42 }) 43 .then(() => { 44 return File.createFromFileName(file.path); 45 }) 46 .then(f => { 47 is(f.mozFullPathInternal, undefined, "mozFullPathInternal is undefined from js"); 48 is(f.mozFullPath, "", "mozFullPath returns blank if created with a string"); 49 }) 50 .then(() => { 51 SimpleTest.finish(); 52 }); 53 54 SimpleTest.waitForExplicitFinish(); 55 </script> 56 </pre> 57 </body> 58 </html>