Bug 1283344 - Change the creation time of <input type="file"> in some dom/filesystem tests. a=test-only
authorAndrea Marchesini <amarchesini@mozilla.com>
Fri, 08 Jul 2016 09:08:47 +0200
changeset 342063 a8f92dcb4f9c55f7549fc09412da4f0eba1b6910
parent 342062 8d543f75538449a9a9a8479b50716fd18324b32f
child 342064 3a9a807db06d49a8359720915e6e0f672b893b3f
push id1183
push userraliiev@mozilla.com
push dateMon, 05 Sep 2016 20:01:49 +0000
treeherdermozilla-release@3148731bed45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstest-only
bugs1283344
milestone49.0a2
Bug 1283344 - Change the creation time of <input type="file"> in some dom/filesystem tests. a=test-only
dom/filesystem/tests/test_basic.html
dom/filesystem/tests/test_worker_basic.html
--- a/dom/filesystem/tests/test_basic.html
+++ b/dom/filesystem/tests/test_basic.html
@@ -3,27 +3,30 @@
 <head>
   <title>Test for Directory API</title>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="text/javascript" src="filesystem_commons.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 
 <body>
-<input id="fileList" type="file"></input>
 <script type="application/javascript;version=1.7">
 
 var directory;
+var fileList;
 
 function create_fileList(aPath) {
+  fileList = document.createElement('input');
+  fileList.setAttribute('type', 'file');
+  document.body.appendChild(fileList);
+
   var url = SimpleTest.getTestFileURL("script_fileList.js");
   var script = SpecialPowers.loadChromeScript(url);
 
   function onOpened(message) {
-    var fileList = document.getElementById('fileList');
     SpecialPowers.wrap(fileList).mozSetDirectory(message.dir);
 
     fileList.getFilesAndDirectories().then(function(array) {
       is(array.length, 1, "We want just 1 directory.");
       ok(array[0] instanceof Directory, "We want just 1 directory.");
 
       directory = array[0];
       script.destroy();
@@ -35,17 +38,16 @@ function create_fileList(aPath) {
   script.sendAsyncMessage("dir.open", { path: aPath });
 }
 
 function test_simpleFilePicker(aPath) {
   var url = SimpleTest.getTestFileURL("script_fileList.js");
   var script = SpecialPowers.loadChromeScript(url);
 
   function onOpened(message) {
-    var fileList = document.getElementById('fileList');
     SpecialPowers.wrap(fileList).mozSetFileArray([message.file]);
 
     is(fileList.files.length, 1, "we want 1 element");
     ok(fileList.files[0] instanceof File, "we want 1 file");
     ok("webkitRelativePath" in fileList.files[0], "we have webkitRelativePath attribute");
     is(fileList.files[0].webkitRelativePath, "", "No webkit relative path for normal filePicker");
 
     script.destroy();
@@ -56,17 +58,16 @@ function test_simpleFilePicker(aPath) {
   script.sendAsyncMessage("file.open");
 }
 
 function test_duplicateGetFilesAndDirectories() {
   var url = SimpleTest.getTestFileURL("script_fileList.js");
   var script = SpecialPowers.loadChromeScript(url);
 
   function onOpened(message) {
-    var fileList = document.getElementById('fileList');
     SpecialPowers.wrap(fileList).mozSetDirectory(message.dir);
 
     var p1 = fileList.getFilesAndDirectories();
     var p2 = fileList.getFilesAndDirectories();
 
     isnot(p1, p2, "We create 2 different promises");
 
     script.destroy();
@@ -77,17 +78,16 @@ function test_duplicateGetFilesAndDirect
   script.sendAsyncMessage("dir.open", { path: 'test' });
 }
 
 function test_inputGetFiles() {
   var url = SimpleTest.getTestFileURL("script_fileList.js");
   var script = SpecialPowers.loadChromeScript(url);
 
   function onOpened(message) {
-    var fileList = document.getElementById('fileList');
     SpecialPowers.wrap(fileList).mozSetDirectory(message.dir);
 
     fileList.getFilesAndDirectories()
     .then(function(result) {
        is(result.length, 1, "getFilesAndDirectories should return 1 element");
        ok(result[0] instanceof Directory, "getFilesAndDirectories should return 1 directory");
 
       return fileList.getFiles(false);
--- a/dom/filesystem/tests/test_worker_basic.html
+++ b/dom/filesystem/tests/test_worker_basic.html
@@ -3,36 +3,39 @@
 <head>
   <title>Test for Directory API in workers</title>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="text/javascript" src="filesystem_commons.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 
 <body>
-<input id="fileList" type="file"></input>
 <script type="application/javascript;version=1.7">
 
+var fileList;
+
 function create_fileList() {
+  fileList = document.createElement('input');
+  fileList.setAttribute('type', 'file');
+  document.body.appendChild(fileList);
+
   var url = SimpleTest.getTestFileURL("script_fileList.js");
   var script = SpecialPowers.loadChromeScript(url);
 
   function onOpened(message) {
-    var fileList = document.getElementById('fileList');
     SpecialPowers.wrap(fileList).mozSetDirectory(message.dir);
     script.destroy();
     next();
   }
 
   script.addMessageListener("dir.opened", onOpened);
   script.sendAsyncMessage("dir.open", { path: 'ProfD' });
 }
 
 function test_worker() {
-  var fileList = document.getElementById('fileList');
   fileList.getFilesAndDirectories().then(function(array) {
     var worker = new Worker('worker_basic.js');
     worker.onmessage = function(e) {
       if (e.data.type == 'finish') {
         next();
         return;
       }