Bug 1475859 [wpt PR 11993] - Create multiple files in single temp directory for upload tests, a=testonly
authorjimevans <james.h.evans.jr@gmail.com>
Wed, 25 Jul 2018 15:51:40 +0000
changeset 428974 c81098932ec0bbd5627286df5efb9dedc9252ad3
parent 428973 8d96cff86763ca68590bf6c57bef61ff24b3bf97
child 428975 ae3c6fe6b9d515f5d5b2bad2c03c26b1256b46cb
push id67065
push userapavel@mozilla.com
push dateMon, 30 Jul 2018 09:54:59 +0000
treeherderautoland@c8d19a0ec6b4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1475859, 11993
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1475859 [wpt PR 11993] - Create multiple files in single temp directory for upload tests, a=testonly Automatic update from web-platform-testswebdriver: create multiple files in single temp directory for upload tests (#11993) Some user agents do not support multiple files in input elements in the file upload state if the files selected are in different directories. This commit adds the ability to create multiple temporary files in a single temp directory instead of creating each file in its own directory. Additionally, it adds a test uploading multiple files in different directories for coverage of that case. -- wpt-commits: 2161258356b82724eb2a18b1267d2450884ac052 wpt-pr: 11993
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/webdriver/tests/element_send_keys/conftest.py
testing/web-platform/tests/webdriver/tests/element_send_keys/file_upload.py
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -624391,29 +624391,29 @@
    "4ddcd4198d33ba6ad1d4bdd7438cf146c26232cd",
    "support"
   ],
   "webdriver/tests/element_send_keys/__init__.py": [
    "da39a3ee5e6b4b0d3255bfef95601890afd80709",
    "support"
   ],
   "webdriver/tests/element_send_keys/conftest.py": [
-   "79ae8a3775c4f9e2339e202711f31f5a83409b75",
+   "5d5de26029cb9688631cb79ed0f2856c2ac4c615",
    "support"
   ],
   "webdriver/tests/element_send_keys/content_editable.py": [
    "9c071e60e1203cf31120f20874b5f38ba41dacc3",
    "wdspec"
   ],
   "webdriver/tests/element_send_keys/events.py": [
    "199c4fb5bfbe2f6f2a016cd96a99213b6e311c99",
    "wdspec"
   ],
   "webdriver/tests/element_send_keys/file_upload.py": [
-   "156d84b8c195a1ebe83e65ca2ed8a92bb405bf26",
+   "75774ebda6b4a43c7c5e143b9532572bd05a6738",
    "wdspec"
   ],
   "webdriver/tests/element_send_keys/form_controls.py": [
    "990dd9955f06d40c98185161bc4d991b73d86916",
    "wdspec"
   ],
   "webdriver/tests/element_send_keys/interactability.py": [
    "5374827c90845ded660d540d23bb7e07ac84e445",
--- a/testing/web-platform/tests/webdriver/tests/element_send_keys/conftest.py
+++ b/testing/web-platform/tests/webdriver/tests/element_send_keys/conftest.py
@@ -6,8 +6,24 @@ def create_file(tmpdir_factory):
     def inner(filename):
         fh = tmpdir_factory.mktemp("tmp").join(filename)
         fh.write(filename)
 
         return fh
 
     inner.__name__ = "create_file"
     return inner
+
+
+@pytest.fixture
+def create_files(tmpdir_factory):
+    def inner(filenames):
+        filelist = []
+        tmpdir = tmpdir_factory.mktemp("tmp")
+        for filename in filenames:
+            fh = tmpdir.join(filename)
+            fh.write(filename)
+            filelist.append(fh)
+
+        return filelist
+
+    inner.__name__ = "create_files"
+    return inner
--- a/testing/web-platform/tests/webdriver/tests/element_send_keys/file_upload.py
+++ b/testing/web-platform/tests/webdriver/tests/element_send_keys/file_upload.py
@@ -17,76 +17,90 @@ def element_send_keys(session, element, 
 def test_empty_text(session):
     session.url = inline("<input type=file>")
     element = session.find.css("input", all=False)
 
     response = element_send_keys(session, element, "")
     assert_error(response, "invalid argument")
 
 
-def test_multiple_files(session, create_file):
+def test_multiple_files(session, create_files):
+    files = create_files(["foo", "bar"])
+
+    session.url = inline("<input type=file multiple>")
+    element = session.find.css("input", all=False)
+
+    response = element_send_keys(session, element,
+                                 map_files_to_multiline_text(files))
+    assert_success(response)
+
+    assert_files_uploaded(session, element, files)
+
+
+def test_multiple_files_multiple_directories(session, create_file):
     files = [create_file("foo"), create_file("bar")]
 
     session.url = inline("<input type=file multiple>")
     element = session.find.css("input", all=False)
 
     response = element_send_keys(session, element,
                                  map_files_to_multiline_text(files))
     assert_success(response)
 
     assert_files_uploaded(session, element, files)
 
 
-def test_multiple_files_last_path_not_found(session, create_file):
-    files = [create_file("foo"), create_file("bar"), "foo bar"]
+def test_multiple_files_last_path_not_found(session, create_files):
+    files = create_files(["foo", "bar"])
+    files.append("foo bar")
 
     session.url = inline("<input type=file multiple>")
     element = session.find.css("input", all=False)
 
     response = element_send_keys(session, element,
                                  map_files_to_multiline_text(files))
     assert_error(response, "invalid argument")
 
     assert_files_uploaded(session, element, [])
 
 
-def test_multiple_files_without_multiple_attribute(session, create_file):
-    files = [create_file("foo"), create_file("bar")]
+def test_multiple_files_without_multiple_attribute(session, create_files):
+    files = create_files(["foo", "bar"])
 
     session.url = inline("<input type=file>")
     element = session.find.css("input", all=False)
 
     response = element_send_keys(session, element,
                                  map_files_to_multiline_text(files))
     assert_error(response, "invalid argument")
 
     assert_files_uploaded(session, element, [])
 
 
-def test_multiple_files_send_twice(session, create_file):
-    first_files = [create_file("foo"), create_file("bar")]
-    second_files = [create_file("john"), create_file("doe")]
+def test_multiple_files_send_twice(session, create_files):
+    first_files = create_files(["foo", "bar"])
+    second_files = create_files(["john", "doe"])
 
     session.url = inline("<input type=file multiple>")
     element = session.find.css("input", all=False)
 
     response = element_send_keys(session, element,
                                  map_files_to_multiline_text(first_files))
     assert_success(response)
 
     response = element_send_keys(session, element,
                                  map_files_to_multiline_text(second_files))
     assert_success(response)
 
     assert_files_uploaded(session, element, first_files + second_files)
 
 
-def test_multiple_files_reset_with_element_clear(session, create_file):
-    first_files = [create_file("foo"), create_file("bar")]
-    second_files = [create_file("john"), create_file("doe")]
+def test_multiple_files_reset_with_element_clear(session, create_files):
+    first_files = create_files(["foo", "bar"])
+    second_files = create_files(["john", "doe"])
 
     session.url = inline("<input type=file multiple>")
     element = session.find.css("input", all=False)
 
     response = element_send_keys(session, element,
                                  map_files_to_multiline_text(first_files))
     assert_success(response)
 
@@ -124,17 +138,32 @@ def test_single_file_replaces_without_mu
     assert_success(response)
 
     response = element_send_keys(session, element, str(second_file))
     assert_success(response)
 
     assert_files_uploaded(session, element, [second_file])
 
 
-def test_single_file_appends_with_multiple_attribute(session, create_file):
+def test_single_file_appends_with_multiple_attribute(session, create_files):
+    files = create_files(["foo", "bar"])
+
+    session.url = inline("<input type=file multiple>")
+    element = session.find.css("input", all=False)
+
+    response = element_send_keys(session, element, str(files[0]))
+    assert_success(response)
+
+    response = element_send_keys(session, element, str(files[1]))
+    assert_success(response)
+
+    assert_files_uploaded(session, element, files)
+
+
+def test_single_file_multiple_directory_appends_with_multiple_attribute(session, create_file):
     first_file = create_file("foo")
     second_file = create_file("bar")
 
     session.url = inline("<input type=file multiple>")
     element = session.find.css("input", all=False)
 
     response = element_send_keys(session, element, str(first_file))
     assert_success(response)