diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs
index 71edf5c7abb..6c3b008bfc8 100644
--- a/components/script/dom/htmlinputelement.rs
+++ b/components/script/dom/htmlinputelement.rs
@@ -302,6 +302,14 @@ impl HTMLInputElementMethods for HTMLInputElement {
self.form_owner()
}
+ // https://html.spec.whatwg.org/multipage/#dom-input-files
+ fn GetFiles(&self) -> Option> {
+ match self.filelist.get() {
+ Some(ref fl) => Some(fl.clone()),
+ None => None,
+ }
+ }
+
// https://html.spec.whatwg.org/multipage/#dom-input-defaultchecked
make_bool_getter!(DefaultChecked, "checked");
@@ -796,6 +804,12 @@ impl VirtualMethods for HTMLInputElement {
el.set_read_write_state(false);
}
+ if new_type == InputType::InputFile {
+ let window = window_from_node(self);
+ let filelist = FileList::new(window.r(), vec![]);
+ self.filelist.set(Some(&filelist));
+ }
+
let new_value_mode = self.value_mode();
match (&old_value_mode, old_idl_value.is_empty(), new_value_mode) {
diff --git a/components/script/dom/webidls/HTMLInputElement.webidl b/components/script/dom/webidls/HTMLInputElement.webidl
index 48ec3c0ac7b..d145e498659 100644
--- a/components/script/dom/webidls/HTMLInputElement.webidl
+++ b/components/script/dom/webidls/HTMLInputElement.webidl
@@ -13,7 +13,7 @@ interface HTMLInputElement : HTMLElement {
attribute DOMString dirName;
attribute boolean disabled;
readonly attribute HTMLFormElement? form;
- //readonly attribute FileList? files;
+ readonly attribute FileList? files;
attribute DOMString formAction;
attribute DOMString formEnctype;
attribute DOMString formMethod;
diff --git a/tests/wpt/metadata/FileAPI/filelist-section/filelist.html.ini b/tests/wpt/metadata/FileAPI/filelist-section/filelist.html.ini
deleted file mode 100644
index 4c198fa1a2f..00000000000
--- a/tests/wpt/metadata/FileAPI/filelist-section/filelist.html.ini
+++ /dev/null
@@ -1,17 +0,0 @@
-[filelist.html]
- type: testharness
- [Check if item is a instanceof Function]
- expected: FAIL
-
- [Check if item is a method of fileList]
- expected: FAIL
-
- [Check if the item method returns null when no file selected]
- expected: FAIL
-
- [Check if length is fileList's attribute]
- expected: FAIL
-
- [Check if the fileList length is 0 when no file selected]
- expected: FAIL
-
diff --git a/tests/wpt/metadata/FileAPI/idlharness.html.ini b/tests/wpt/metadata/FileAPI/idlharness.html.ini
index c3099e70f38..96f7878d2f7 100644
--- a/tests/wpt/metadata/FileAPI/idlharness.html.ini
+++ b/tests/wpt/metadata/FileAPI/idlharness.html.ini
@@ -3,21 +3,6 @@
[URL interface: operation createFor(Blob)]
expected: FAIL
- [FileList must be primary interface of file_input.files]
- expected: FAIL
-
- [Stringification of file_input.files]
- expected: FAIL
-
- [FileList interface: file_input.files must inherit property "item" with the proper type (0)]
- expected: FAIL
-
- [FileList interface: calling item(unsigned long) on file_input.files with too few arguments must throw TypeError]
- expected: FAIL
-
- [FileList interface: file_input.files must inherit property "length" with the proper type (1)]
- expected: FAIL
-
[FileReaderSync interface: existence and properties of interface object]
expected: FAIL
diff --git a/tests/wpt/metadata/html/dom/interfaces.html.ini b/tests/wpt/metadata/html/dom/interfaces.html.ini
index 5c17f9f2f85..92990e9dab8 100644
--- a/tests/wpt/metadata/html/dom/interfaces.html.ini
+++ b/tests/wpt/metadata/html/dom/interfaces.html.ini
@@ -3570,9 +3570,6 @@
[HTMLInputElement interface: attribute autofocus]
expected: FAIL
- [HTMLInputElement interface: attribute files]
- expected: FAIL
-
[HTMLInputElement interface: attribute height]
expected: FAIL
@@ -3645,9 +3642,6 @@
[HTMLInputElement interface: document.createElement("input") must inherit property "autofocus" with the proper type (3)]
expected: FAIL
- [HTMLInputElement interface: document.createElement("input") must inherit property "files" with the proper type (9)]
- expected: FAIL
-
[HTMLInputElement interface: document.createElement("input") must inherit property "height" with the proper type (15)]
expected: FAIL
@@ -7590,9 +7584,6 @@
[HTMLInputElement interface: createInput("text") must inherit property "autofocus" with the proper type (3)]
expected: FAIL
- [HTMLInputElement interface: createInput("text") must inherit property "files" with the proper type (9)]
- expected: FAIL
-
[HTMLInputElement interface: createInput("text") must inherit property "height" with the proper type (15)]
expected: FAIL
@@ -7680,9 +7671,6 @@
[HTMLInputElement interface: createInput("hidden") must inherit property "autofocus" with the proper type (3)]
expected: FAIL
- [HTMLInputElement interface: createInput("hidden") must inherit property "files" with the proper type (9)]
- expected: FAIL
-
[HTMLInputElement interface: createInput("hidden") must inherit property "height" with the proper type (15)]
expected: FAIL
@@ -7770,9 +7758,6 @@
[HTMLInputElement interface: createInput("search") must inherit property "autofocus" with the proper type (3)]
expected: FAIL
- [HTMLInputElement interface: createInput("search") must inherit property "files" with the proper type (9)]
- expected: FAIL
-
[HTMLInputElement interface: createInput("search") must inherit property "height" with the proper type (15)]
expected: FAIL
@@ -7860,9 +7845,6 @@
[HTMLInputElement interface: createInput("tel") must inherit property "autofocus" with the proper type (3)]
expected: FAIL
- [HTMLInputElement interface: createInput("tel") must inherit property "files" with the proper type (9)]
- expected: FAIL
-
[HTMLInputElement interface: createInput("tel") must inherit property "height" with the proper type (15)]
expected: FAIL
@@ -7950,9 +7932,6 @@
[HTMLInputElement interface: createInput("url") must inherit property "autofocus" with the proper type (3)]
expected: FAIL
- [HTMLInputElement interface: createInput("url") must inherit property "files" with the proper type (9)]
- expected: FAIL
-
[HTMLInputElement interface: createInput("url") must inherit property "height" with the proper type (15)]
expected: FAIL
@@ -8040,9 +8019,6 @@
[HTMLInputElement interface: createInput("email") must inherit property "autofocus" with the proper type (3)]
expected: FAIL
- [HTMLInputElement interface: createInput("email") must inherit property "files" with the proper type (9)]
- expected: FAIL
-
[HTMLInputElement interface: createInput("email") must inherit property "height" with the proper type (15)]
expected: FAIL
@@ -8130,9 +8106,6 @@
[HTMLInputElement interface: createInput("password") must inherit property "autofocus" with the proper type (3)]
expected: FAIL
- [HTMLInputElement interface: createInput("password") must inherit property "files" with the proper type (9)]
- expected: FAIL
-
[HTMLInputElement interface: createInput("password") must inherit property "height" with the proper type (15)]
expected: FAIL
@@ -8220,9 +8193,6 @@
[HTMLInputElement interface: createInput("date") must inherit property "autofocus" with the proper type (3)]
expected: FAIL
- [HTMLInputElement interface: createInput("date") must inherit property "files" with the proper type (9)]
- expected: FAIL
-
[HTMLInputElement interface: createInput("date") must inherit property "height" with the proper type (15)]
expected: FAIL
@@ -8310,9 +8280,6 @@
[HTMLInputElement interface: createInput("month") must inherit property "autofocus" with the proper type (3)]
expected: FAIL
- [HTMLInputElement interface: createInput("month") must inherit property "files" with the proper type (9)]
- expected: FAIL
-
[HTMLInputElement interface: createInput("month") must inherit property "height" with the proper type (15)]
expected: FAIL
@@ -8400,9 +8367,6 @@
[HTMLInputElement interface: createInput("week") must inherit property "autofocus" with the proper type (3)]
expected: FAIL
- [HTMLInputElement interface: createInput("week") must inherit property "files" with the proper type (9)]
- expected: FAIL
-
[HTMLInputElement interface: createInput("week") must inherit property "height" with the proper type (15)]
expected: FAIL
@@ -8490,9 +8454,6 @@
[HTMLInputElement interface: createInput("time") must inherit property "autofocus" with the proper type (3)]
expected: FAIL
- [HTMLInputElement interface: createInput("time") must inherit property "files" with the proper type (9)]
- expected: FAIL
-
[HTMLInputElement interface: createInput("time") must inherit property "height" with the proper type (15)]
expected: FAIL
@@ -8580,9 +8541,6 @@
[HTMLInputElement interface: createInput("datetime-local") must inherit property "autofocus" with the proper type (3)]
expected: FAIL
- [HTMLInputElement interface: createInput("datetime-local") must inherit property "files" with the proper type (9)]
- expected: FAIL
-
[HTMLInputElement interface: createInput("datetime-local") must inherit property "height" with the proper type (15)]
expected: FAIL
@@ -8670,9 +8628,6 @@
[HTMLInputElement interface: createInput("number") must inherit property "autofocus" with the proper type (3)]
expected: FAIL
- [HTMLInputElement interface: createInput("number") must inherit property "files" with the proper type (9)]
- expected: FAIL
-
[HTMLInputElement interface: createInput("number") must inherit property "height" with the proper type (15)]
expected: FAIL
@@ -8760,9 +8715,6 @@
[HTMLInputElement interface: createInput("range") must inherit property "autofocus" with the proper type (3)]
expected: FAIL
- [HTMLInputElement interface: createInput("range") must inherit property "files" with the proper type (9)]
- expected: FAIL
-
[HTMLInputElement interface: createInput("range") must inherit property "height" with the proper type (15)]
expected: FAIL
@@ -8850,9 +8802,6 @@
[HTMLInputElement interface: createInput("color") must inherit property "autofocus" with the proper type (3)]
expected: FAIL
- [HTMLInputElement interface: createInput("color") must inherit property "files" with the proper type (9)]
- expected: FAIL
-
[HTMLInputElement interface: createInput("color") must inherit property "height" with the proper type (15)]
expected: FAIL
@@ -8940,9 +8889,6 @@
[HTMLInputElement interface: createInput("checkbox") must inherit property "autofocus" with the proper type (3)]
expected: FAIL
- [HTMLInputElement interface: createInput("checkbox") must inherit property "files" with the proper type (9)]
- expected: FAIL
-
[HTMLInputElement interface: createInput("checkbox") must inherit property "height" with the proper type (15)]
expected: FAIL
@@ -9030,9 +8976,6 @@
[HTMLInputElement interface: createInput("radio") must inherit property "autofocus" with the proper type (3)]
expected: FAIL
- [HTMLInputElement interface: createInput("radio") must inherit property "files" with the proper type (9)]
- expected: FAIL
-
[HTMLInputElement interface: createInput("radio") must inherit property "height" with the proper type (15)]
expected: FAIL
@@ -9210,9 +9153,6 @@
[HTMLInputElement interface: createInput("submit") must inherit property "autofocus" with the proper type (3)]
expected: FAIL
- [HTMLInputElement interface: createInput("submit") must inherit property "files" with the proper type (9)]
- expected: FAIL
-
[HTMLInputElement interface: createInput("submit") must inherit property "height" with the proper type (15)]
expected: FAIL
@@ -9300,9 +9240,6 @@
[HTMLInputElement interface: createInput("image") must inherit property "autofocus" with the proper type (3)]
expected: FAIL
- [HTMLInputElement interface: createInput("image") must inherit property "files" with the proper type (9)]
- expected: FAIL
-
[HTMLInputElement interface: createInput("image") must inherit property "height" with the proper type (15)]
expected: FAIL
@@ -9390,9 +9327,6 @@
[HTMLInputElement interface: createInput("reset") must inherit property "autofocus" with the proper type (3)]
expected: FAIL
- [HTMLInputElement interface: createInput("reset") must inherit property "files" with the proper type (9)]
- expected: FAIL
-
[HTMLInputElement interface: createInput("reset") must inherit property "height" with the proper type (15)]
expected: FAIL
@@ -9480,9 +9414,6 @@
[HTMLInputElement interface: createInput("button") must inherit property "autofocus" with the proper type (3)]
expected: FAIL
- [HTMLInputElement interface: createInput("button") must inherit property "files" with the proper type (9)]
- expected: FAIL
-
[HTMLInputElement interface: createInput("button") must inherit property "height" with the proper type (15)]
expected: FAIL
diff --git a/tests/wpt/metadata/html/semantics/forms/the-input-element/files.html.ini b/tests/wpt/metadata/html/semantics/forms/the-input-element/files.html.ini
deleted file mode 100644
index 37cc4c14fcd..00000000000
--- a/tests/wpt/metadata/html/semantics/forms/the-input-element/files.html.ini
+++ /dev/null
@@ -1,71 +0,0 @@
-[files.html]
- type: testharness
- [files for input type=hidden]
- expected: FAIL
-
- [files for input type=text]
- expected: FAIL
-
- [files for input type=search]
- expected: FAIL
-
- [files for input type=tel]
- expected: FAIL
-
- [files for input type=url]
- expected: FAIL
-
- [files for input type=email]
- expected: FAIL
-
- [files for input type=password]
- expected: FAIL
-
- [files for input type=datetime]
- expected: FAIL
-
- [files for input type=date]
- expected: FAIL
-
- [files for input type=month]
- expected: FAIL
-
- [files for input type=week]
- expected: FAIL
-
- [files for input type=time]
- expected: FAIL
-
- [files for input type=datetime-local]
- expected: FAIL
-
- [files for input type=number]
- expected: FAIL
-
- [files for input type=range]
- expected: FAIL
-
- [files for input type=color]
- expected: FAIL
-
- [files for input type=checkbox]
- expected: FAIL
-
- [files for input type=radio]
- expected: FAIL
-
- [files for input type=submit]
- expected: FAIL
-
- [files for input type=image]
- expected: FAIL
-
- [files for input type=reset]
- expected: FAIL
-
- [files for input type=button]
- expected: FAIL
-
- [files for input type=file]
- expected: FAIL
-
diff --git a/tests/wpt/metadata/html/semantics/forms/the-input-element/hidden.html.ini b/tests/wpt/metadata/html/semantics/forms/the-input-element/hidden.html.ini
index 5b29419eea0..2984d41afe7 100644
--- a/tests/wpt/metadata/html/semantics/forms/the-input-element/hidden.html.ini
+++ b/tests/wpt/metadata/html/semantics/forms/the-input-element/hidden.html.ini
@@ -1,8 +1,5 @@
[hidden.html]
type: testharness
- [files attribute must return null for hidden]
- expected: FAIL
-
[valueAsDate attribute must return null for hidden]
expected: FAIL
diff --git a/tests/wpt/metadata/html/semantics/forms/the-input-element/text.html.ini b/tests/wpt/metadata/html/semantics/forms/the-input-element/text.html.ini
index 593054f48b2..bc06afde4b9 100644
--- a/tests/wpt/metadata/html/semantics/forms/the-input-element/text.html.ini
+++ b/tests/wpt/metadata/html/semantics/forms/the-input-element/text.html.ini
@@ -3,9 +3,6 @@
[Value sanitization algorithm should strip line breaks for text]
expected: FAIL
- [files attribute must return null for text]
- expected: FAIL
-
[valueAsDate attribute must return null for text]
expected: FAIL
@@ -24,9 +21,6 @@
[Value sanitization algorithm should strip line breaks for search]
expected: FAIL
- [files attribute must return null for search]
- expected: FAIL
-
[valueAsDate attribute must return null for search]
expected: FAIL