浏览代码

LibWeb: Fixed IDL for HTMLInputElement

Use Enumerated for the form{Enctype, Method} attributes
samu698 2 天之前
父节点
当前提交
d08d305399

+ 52 - 0
Tests/LibWeb/Text/expected/form-formEnctype-attribute.txt

@@ -49,3 +49,55 @@ button.formEnctype == 'application/x-www-form-urlencoded'
 button.setAttribute('formEnctype', '5%')
 button.getAttribute('formEnctype') == '5%'
 button.formEnctype == 'application/x-www-form-urlencoded'
+
+input: unset
+input.getAttribute('formEnctype') == 'null'
+input.formEnctype == ''
+
+input.setAttribute('formEnctype', '')
+input.getAttribute('formEnctype') == ''
+input.formEnctype == 'application/x-www-form-urlencoded'
+
+input.setAttribute('formEnctype', 'undefined')
+input.getAttribute('formEnctype') == 'undefined'
+input.formEnctype == 'application/x-www-form-urlencoded'
+
+input.setAttribute('formEnctype', 'null')
+input.getAttribute('formEnctype') == 'null'
+input.formEnctype == 'application/x-www-form-urlencoded'
+
+input.setAttribute('formEnctype', 'application/x-www-form-urlencoded')
+input.getAttribute('formEnctype') == 'application/x-www-form-urlencoded'
+input.formEnctype == 'application/x-www-form-urlencoded'
+
+input.setAttribute('formEnctype', 'multipart/form-data')
+input.getAttribute('formEnctype') == 'multipart/form-data'
+input.formEnctype == 'multipart/form-data'
+
+input.setAttribute('formEnctype', 'text/plain')
+input.getAttribute('formEnctype') == 'text/plain'
+input.formEnctype == 'text/plain'
+
+input.setAttribute('formEnctype', 'APPLICATION/X-WWW-FORM-URLENCODED')
+input.getAttribute('formEnctype') == 'APPLICATION/X-WWW-FORM-URLENCODED'
+input.formEnctype == 'application/x-www-form-urlencoded'
+
+input.setAttribute('formEnctype', 'MULTIPART/FORM-DATA')
+input.getAttribute('formEnctype') == 'MULTIPART/FORM-DATA'
+input.formEnctype == 'multipart/form-data'
+
+input.setAttribute('formEnctype', 'tEXt/PlAIn')
+input.getAttribute('formEnctype') == 'tEXt/PlAIn'
+input.formEnctype == 'text/plain'
+
+input.setAttribute('formEnctype', 'text/plain ')
+input.getAttribute('formEnctype') == 'text/plain '
+input.formEnctype == 'application/x-www-form-urlencoded'
+
+input.setAttribute('formEnctype', '7')
+input.getAttribute('formEnctype') == '7'
+input.formEnctype == 'application/x-www-form-urlencoded'
+
+input.setAttribute('formEnctype', '5%')
+input.getAttribute('formEnctype') == '5%'
+input.formEnctype == 'application/x-www-form-urlencoded'

+ 52 - 0
Tests/LibWeb/Text/expected/form-formMethod-attribute.txt

@@ -49,3 +49,55 @@ button.formMethod == 'get'
 button.setAttribute('formMethod', '5%')
 button.getAttribute('formMethod') == '5%'
 button.formMethod == 'get'
+
+input: unset
+input.getAttribute('formMethod') == 'null'
+input.formMethod == ''
+
+input.setAttribute('formMethod', '')
+input.getAttribute('formMethod') == ''
+input.formMethod == 'get'
+
+input.setAttribute('formMethod', 'undefined')
+input.getAttribute('formMethod') == 'undefined'
+input.formMethod == 'get'
+
+input.setAttribute('formMethod', 'null')
+input.getAttribute('formMethod') == 'null'
+input.formMethod == 'get'
+
+input.setAttribute('formMethod', 'get')
+input.getAttribute('formMethod') == 'get'
+input.formMethod == 'get'
+
+input.setAttribute('formMethod', 'post')
+input.getAttribute('formMethod') == 'post'
+input.formMethod == 'post'
+
+input.setAttribute('formMethod', 'dialog')
+input.getAttribute('formMethod') == 'dialog'
+input.formMethod == 'dialog'
+
+input.setAttribute('formMethod', 'GeT')
+input.getAttribute('formMethod') == 'GeT'
+input.formMethod == 'get'
+
+input.setAttribute('formMethod', 'POST')
+input.getAttribute('formMethod') == 'POST'
+input.formMethod == 'post'
+
+input.setAttribute('formMethod', 'DIAlog')
+input.getAttribute('formMethod') == 'DIAlog'
+input.formMethod == 'dialog'
+
+input.setAttribute('formMethod', 'foo')
+input.getAttribute('formMethod') == 'foo'
+input.formMethod == 'get'
+
+input.setAttribute('formMethod', 'xpost')
+input.getAttribute('formMethod') == 'xpost'
+input.formMethod == 'get'
+
+input.setAttribute('formMethod', '5%')
+input.getAttribute('formMethod') == '5%'
+input.formMethod == 'get'

+ 13 - 0
Tests/LibWeb/Text/input/form-formEnctype-attribute.html

@@ -2,6 +2,7 @@
 <script>
     test(() => {
         const btn = document.createElement('button');
+        const input = document.createElement('input');
         const values = [
             '', undefined, null,
             'application/x-www-form-urlencoded',
@@ -23,5 +24,17 @@
             println(`button.getAttribute('formEnctype') == '${btn.getAttribute('formEnctype')}'`);
             println(`button.formEnctype == '${btn.formEnctype}'`);
         }
+
+        println('');
+        println('input: unset');
+        println(`input.getAttribute('formEnctype') == '${input.getAttribute('formEnctype')}'`);
+        println(`input.formEnctype == '${input.formEnctype}'`);
+        for (value of values) {
+            input.setAttribute('formEnctype', value);
+            println('');
+            println(`input.setAttribute('formEnctype', '${value}')`);
+            println(`input.getAttribute('formEnctype') == '${input.getAttribute('formEnctype')}'`);
+            println(`input.formEnctype == '${input.formEnctype}'`);
+        }
     });
 </script>

+ 13 - 0
Tests/LibWeb/Text/input/form-formMethod-attribute.html

@@ -2,6 +2,7 @@
 <script>
     test(() => {
         const btn = document.createElement('button');
+        const input = document.createElement('input');
         const values = [
             '', undefined, null,
             'get', 'post', 'dialog',
@@ -19,5 +20,17 @@
             println(`button.getAttribute('formMethod') == '${btn.getAttribute('formMethod')}'`);
             println(`button.formMethod == '${btn.formMethod}'`);
         }
+
+        println('');
+        println('input: unset')
+        println(`input.getAttribute('formMethod') == '${input.getAttribute('formMethod')}'`);
+        println(`input.formMethod == '${input.formMethod}'`);
+        for (value of values) {
+            input.setAttribute('formMethod', value);
+            println('');
+            println(`input.setAttribute('formMethod', '${value}')`);
+            println(`input.getAttribute('formMethod') == '${input.getAttribute('formMethod')}'`);
+            println(`input.formMethod == '${input.formMethod}'`);
+        }
     });
 </script>

+ 2 - 2
Userland/Libraries/LibWeb/HTML/HTMLInputElement.idl

@@ -18,8 +18,8 @@ interface HTMLInputElement : HTMLElement {
     readonly attribute HTMLFormElement? form;
     attribute FileList? files;
     [CEReactions] attribute USVString formAction;
-    [FIXME, CEReactions] attribute DOMString formEnctype;
-    [FIXME, CEReactions] attribute DOMString formMethod;
+    [CEReactions, Reflect=formenctype, Enumerated=FormEnctypeAttribute] attribute DOMString formEnctype;
+    [CEReactions, Reflect=formmethod, Enumerated=FormMethodAttribute] attribute DOMString formMethod;
     [CEReactions, Reflect=formnovalidate] attribute boolean formNoValidate;
     [CEReactions, Reflect=formtarget] attribute DOMString formTarget;
     [FIXME, CEReactions] attribute unsigned long height;