tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_bug403852.html (2087B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4 <!--
      5 https://bugzilla.mozilla.org/show_bug.cgi?id=403852
      6 -->
      7  <title>Test for Bug 403852</title>
      8  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      9  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
     10 </head>
     11 
     12 <body>
     13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=403852">Mozilla Bug 403852</a>
     14 <p id="display">
     15  <input id="fileList" type="file"></input>
     16 </p>
     17 <div id="content" style="display: none">
     18 </div>
     19 
     20 <pre id="test">
     21 <script class="testbody" type="text/javascript">
     22 SimpleTest.waitForExplicitFinish();
     23 
     24 var script = '';
     25 SpecialPowers.pushPrefEnv({ "set":
     26      [["privacy.reduceTimerPrecision", false]]},
     27  function() {
     28    var url = SimpleTest.getTestFileURL("bug403852_fileOpener.js");
     29    script = SpecialPowers.loadChromeScript(url);
     30    script.addMessageListener("file.opened", onOpened);
     31    script.sendAsyncMessage("file.open");
     32 });
     33 
     34 function onOpened(message) {
     35  var fileList = document.getElementById('fileList');
     36  SpecialPowers.wrap(fileList).mozSetFileArray([message.file]);
     37 
     38  // Make sure the file is accessible with indexed notation
     39  var domFile = fileList.files[0];
     40 
     41  is(domFile.name, "prefs.js", "fileName should be prefs.js");
     42 
     43  ok("lastModified" in domFile, "lastModified must be present");
     44 
     45  var d = new Date(message.mtime);
     46  is(d.getTime(), (new Date(domFile.lastModified)).getTime(), "lastModified should be the same");
     47 
     48  var x = new Date();
     49 
     50  // In our implementation of File object, lastModified is unknown only for new objects.
     51  // Using canvas or input[type=file] elements, we 'often' have a valid lastModified values.
     52  // For canvas we use memory files and the lastModified is now().
     53  var f = new File([new Blob(['test'], {type: 'text/plain'})], "test-name");
     54 
     55  var y = new Date(f.lastModified);
     56  var z = new Date();
     57 
     58  ok((x.getTime() <= y.getTime()) && (y.getTime() <= z.getTime()), "lastModified of file which does not have last modified date should be current time");
     59 
     60  script.destroy();
     61  SimpleTest.finish();
     62 }
     63 
     64 </script>
     65 </pre>
     66 </body> </html>