[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

commit-queue at webkit.org commit-queue at webkit.org
Wed Dec 22 15:51:24 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 19d2b9e753669c808edf4deec90cab60637c76af
Author: commit-queue at webkit.org <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Nov 15 12:43:05 2010 +0000

    2010-11-15  Dai Mikurube  <dmikurube at google.com>
    
            Reviewed by Kent Tamura.
    
            Implement formaction, formenctype, formmethod and formtarget attributes for input and button tags
            https://bugs.webkit.org/show_bug.cgi?id=49240
    
            * fast/forms/formaction-attribute-expected.txt: Added.
            * fast/forms/formaction-attribute.html: Added.
            * fast/forms/formmethod-attribute-button-html-expected.txt: Added.
            * fast/forms/formmethod-attribute-button-html.html: Added.
            * fast/forms/formmethod-attribute-input-html-expected.txt: Added.
            * fast/forms/formmethod-attribute-input-html.html: Added.
            * fast/forms/formtarget-attribute-button-html-expected.txt: Added.
            * fast/forms/formtarget-attribute-button-html.html: Added.
            * fast/forms/formtarget-attribute-input-html-expected.txt: Added.
            * fast/forms/formtarget-attribute-input-html.html: Added.
            * fast/forms/mailto/formenctype-attribute-button-html-expected.txt: Added.
            * fast/forms/mailto/formenctype-attribute-button-html.html: Added.
            * fast/forms/mailto/formenctype-attribute-input-html-expected.txt: Added.
            * fast/forms/mailto/formenctype-attribute-input-html.html: Added.
            * fast/forms/script-tests/submit-form-attributes.js: Added.
            * fast/forms/submit-form-attributes-expected.txt: Added.
            * fast/forms/submit-form-attributes.html: Added.
    2010-11-15  Dai Mikurube  <dmikurube at google.com>
    
            Reviewed by Kent Tamura.
    
            Implement formaction, formenctype, formmethod and formtarget attributes for input and button tags
            https://bugs.webkit.org/show_bug.cgi?id=49240
    
            Tests: fast/forms/formaction-attribute.html
                   fast/forms/formmethod-attribute-button-html.html
                   fast/forms/formmethod-attribute-input-html.html
                   fast/forms/formtarget-attribute-button-html.html
                   fast/forms/formtarget-attribute-input-html.html
                   fast/forms/mailto/formenctype-attribute-button-html.html
                   fast/forms/mailto/formenctype-attribute-input-html.html
                   fast/forms/submit-form-attributes.html
    
            * html/HTMLAttributeNames.in: Added formaction, formmethod, formtarget and formenctype attributes
            * html/HTMLButtonElement.idl:
            * html/HTMLInputElement.idl:
            * loader/FormSubmission.cpp: Modified to check the pressed button and its attributes
            (WebCore::FormSubmission::Attributes::copyFrom):
            (WebCore::FormSubmission::create):
            * loader/FormSubmission.h:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@72003 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index ab85529..b4ee8ea 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,28 @@
+2010-11-15  Dai Mikurube  <dmikurube at google.com>
+
+        Reviewed by Kent Tamura.
+
+        Implement formaction, formenctype, formmethod and formtarget attributes for input and button tags
+        https://bugs.webkit.org/show_bug.cgi?id=49240
+
+        * fast/forms/formaction-attribute-expected.txt: Added.
+        * fast/forms/formaction-attribute.html: Added.
+        * fast/forms/formmethod-attribute-button-html-expected.txt: Added.
+        * fast/forms/formmethod-attribute-button-html.html: Added.
+        * fast/forms/formmethod-attribute-input-html-expected.txt: Added.
+        * fast/forms/formmethod-attribute-input-html.html: Added.
+        * fast/forms/formtarget-attribute-button-html-expected.txt: Added.
+        * fast/forms/formtarget-attribute-button-html.html: Added.
+        * fast/forms/formtarget-attribute-input-html-expected.txt: Added.
+        * fast/forms/formtarget-attribute-input-html.html: Added.
+        * fast/forms/mailto/formenctype-attribute-button-html-expected.txt: Added.
+        * fast/forms/mailto/formenctype-attribute-button-html.html: Added.
+        * fast/forms/mailto/formenctype-attribute-input-html-expected.txt: Added.
+        * fast/forms/mailto/formenctype-attribute-input-html.html: Added.
+        * fast/forms/script-tests/submit-form-attributes.js: Added.
+        * fast/forms/submit-form-attributes-expected.txt: Added.
+        * fast/forms/submit-form-attributes.html: Added.
+
 2010-11-15  Alejandro G. Castro  <alex at igalia.com>
 
         Unreviewed.
diff --git a/LayoutTests/fast/forms/formaction-attribute-expected.txt b/LayoutTests/fast/forms/formaction-attribute-expected.txt
new file mode 100644
index 0000000..6520253
--- /dev/null
+++ b/LayoutTests/fast/forms/formaction-attribute-expected.txt
@@ -0,0 +1,11 @@
+Test for formaction attributes in input and button tags.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS The formaction attribute in the input tag was used.
+PASS The formaction attribute in the button tag was used.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+ 
diff --git a/LayoutTests/fast/forms/formaction-attribute.html b/LayoutTests/fast/forms/formaction-attribute.html
new file mode 100644
index 0000000..5907c6f
--- /dev/null
+++ b/LayoutTests/fast/forms/formaction-attribute.html
@@ -0,0 +1,51 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<form action="javascript: failTest(this)" method="get">
+<input id="button1" type="submit" formaction="javascript: passTest1(this)" />
+<button id="button2" type="submit" formaction="javascript: passTest2(this)" />
+</form>
+<script>
+description("Test for formaction attributes in input and button tags.");
+var doneAction = false;
+var doneAction2 = false;
+
+function failTest(ul)
+{
+    doneAction = true;
+    testFailed('The formaction attribute in the input or button tag was ignored.');
+}
+function passTest1(ul)
+{
+    doneAction = true;
+    testPassed('The formaction attribute in the input tag was used.');
+}
+function passTest2(ul)
+{
+    doneAction = true;
+    testPassed('The formaction attribute in the button tag was used.');
+}
+
+doneAction = false;
+var input = document.getElementById('button1');
+input.click();
+if (!doneAction)
+    testFailed('Both of the action and the formaction attributes were ignored.');
+
+doneAction = false;
+var button = document.getElementById('button2');
+button.click();
+if (!doneAction)
+    testFailed('Both of the action and the formaction attributes were ignored.');
+
+var successfullyParsed = true;
+</script>
+<script src="../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/forms/formmethod-attribute-button-html-expected.txt b/LayoutTests/fast/forms/formmethod-attribute-button-html-expected.txt
new file mode 100644
index 0000000..4774987
--- /dev/null
+++ b/LayoutTests/fast/forms/formmethod-attribute-button-html-expected.txt
@@ -0,0 +1,10 @@
+Test for the formmethod attribute in button tags.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS The formmethod attribute was successfully used
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/forms/formmethod-attribute-button-html.html b/LayoutTests/fast/forms/formmethod-attribute-button-html.html
new file mode 100644
index 0000000..e4ecb2c
--- /dev/null
+++ b/LayoutTests/fast/forms/formmethod-attribute-button-html.html
@@ -0,0 +1,40 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<form method="get" action="?">
+    <input type="hidden" name="hidden" value="I am hidden" />
+    <button id="button" formmethod="post" type="submit" name="button" value="value" />
+</form>
+<script>
+description("Test for the formmethod attribute in button tags.");
+if (window.layoutTestController) {
+    layoutTestController.waitUntilDone();
+}
+
+var button = document.getElementById('button');
+
+if (document.URL.substring(0, 4) == "file") {
+    if (document.URL.indexOf('?') == -1) {
+        button.click();
+    } else {
+        if (document.URL.substring(document.URL.indexOf('?') + 1, document.URL.length) == "")
+            testPassed('The formmethod attribute was successfully used');
+        else
+            testFailed('The formmethod attribute was not used');
+
+        if (window.layoutTestController)
+            layoutTestController.notifyDone();
+    }
+}
+
+var successfullyParsed = true;
+</script>
+<script src="../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/forms/formmethod-attribute-input-html-expected.txt b/LayoutTests/fast/forms/formmethod-attribute-input-html-expected.txt
new file mode 100644
index 0000000..cc769d8
--- /dev/null
+++ b/LayoutTests/fast/forms/formmethod-attribute-input-html-expected.txt
@@ -0,0 +1,10 @@
+Test for the formmethod attribute in input tags.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS The formmethod attribute was successfully used
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/forms/formmethod-attribute-input-html.html b/LayoutTests/fast/forms/formmethod-attribute-input-html.html
new file mode 100644
index 0000000..76f0074
--- /dev/null
+++ b/LayoutTests/fast/forms/formmethod-attribute-input-html.html
@@ -0,0 +1,40 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<form method="get" action="?">
+    <input type="hidden" name="hidden" value="I am hidden" />
+    <input id="button" formmethod="post" type="submit" name="button" />
+</form>
+<script>
+description("Test for the formmethod attribute in input tags.");
+if (window.layoutTestController) {
+    layoutTestController.waitUntilDone();
+}
+
+var button = document.getElementById('button');
+
+if (document.URL.substring(0, 4) == "file") {
+    if (document.URL.indexOf('?') == -1) {
+        button.click();
+    } else {
+        if (document.URL.substring(document.URL.indexOf('?') + 1, document.URL.length) == "")
+            testPassed('The formmethod attribute was successfully used');
+        else
+            testFailed('The formmethod attribute was not used');
+
+        if (window.layoutTestController)
+            layoutTestController.notifyDone();
+    }
+}
+
+var successfullyParsed = true;
+</script>
+<script src="../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/forms/formtarget-attribute-button-html-expected.txt b/LayoutTests/fast/forms/formtarget-attribute-button-html-expected.txt
new file mode 100644
index 0000000..b75928b
--- /dev/null
+++ b/LayoutTests/fast/forms/formtarget-attribute-button-html-expected.txt
@@ -0,0 +1,10 @@
+Test for the formtarget attribute in a button tag.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS The formtarget attribute was successfully used.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+ 
diff --git a/LayoutTests/fast/forms/formtarget-attribute-button-html.html b/LayoutTests/fast/forms/formtarget-attribute-button-html.html
new file mode 100644
index 0000000..3a3df50
--- /dev/null
+++ b/LayoutTests/fast/forms/formtarget-attribute-button-html.html
@@ -0,0 +1,54 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+<script src="../../fast/js/resources/js-test-post-function.js"></script>
+</head>
+<body onload="runTest()">
+<p id="description"></p>
+<div id="console"></div>
+<form action="resources/success.txt" method="GET" target="failFrame">
+<button type="submit" id="button" formtarget="passFrame">
+</form>
+<script>
+description("Test for the formtarget attribute in a button tag.");
+
+function runTest()
+{
+    if (window.layoutTestController) {
+        layoutTestController.setAllowUniversalAccessFromFileURLs(true);
+        layoutTestController.waitUntilDone();
+    }
+
+    // Not dumping as text since the DumpRenderTree does not dump the text content of child frames.                
+    var button = document.getElementById('button');
+    button.click();
+}
+
+function passFrameLoaded()
+{
+    if (document.getElementById('pass').contentDocument.URL == "about:blank")
+        return;
+    testPassed("The formtarget attribute was successfully used.");
+    isSuccessfullyParsed();
+    if (window.layoutTestController)
+        layoutTestController.notifyDone();
+}
+
+function failFrameLoaded()
+{
+    if (document.getElementById('fail').contentDocument.URL == "about:blank")
+        return;
+    testFailed("The formtarget attribute was not used.");
+    isSuccessfullyParsed();
+    if (window.layoutTestController)
+        layoutTestController.notifyDone();
+}
+
+var successfullyParsed = true;
+</script>
+<iframe src="about:blank" id="pass" name="passFrame" onload="passFrameLoaded()"></iframe>
+<iframe src="about:blank" id="fail" name="failFrame" onload="failFrameLoaded()"></iframe>
+</body>
+</html>
diff --git a/LayoutTests/fast/forms/formtarget-attribute-input-html-expected.txt b/LayoutTests/fast/forms/formtarget-attribute-input-html-expected.txt
new file mode 100644
index 0000000..9539a6b
--- /dev/null
+++ b/LayoutTests/fast/forms/formtarget-attribute-input-html-expected.txt
@@ -0,0 +1,11 @@
+Test for the formtarget attribute in an input tag.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS The formtarget attribute was successfully used.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
+ 
diff --git a/LayoutTests/fast/forms/formtarget-attribute-input-html.html b/LayoutTests/fast/forms/formtarget-attribute-input-html.html
new file mode 100644
index 0000000..33ceb5e
--- /dev/null
+++ b/LayoutTests/fast/forms/formtarget-attribute-input-html.html
@@ -0,0 +1,54 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+<script src="../../fast/js/resources/js-test-post-function.js"></script>
+</head>
+<body onload="runTest()">
+<p id="description"></p>
+<div id="console"></div>
+<form action="resources/success.txt" method="GET" target="failFrame">
+<input type="submit" id="button" formtarget="passFrame">
+</form>
+<script>
+description("Test for the formtarget attribute in an input tag.");
+
+function runTest()
+{
+    if (window.layoutTestController) {
+        layoutTestController.setAllowUniversalAccessFromFileURLs(true);
+        layoutTestController.waitUntilDone();
+    }
+
+    // Not dumping as text since the DumpRenderTree does not dump the text content of child frames.                
+    var button = document.getElementById('button');
+    button.click();
+}
+
+function passFrameLoaded()
+{
+    if (document.getElementById('pass').contentDocument.URL == "about:blank")
+        return;
+    testPassed("The formtarget attribute was successfully used.");
+    isSuccessfullyParsed();
+    if (window.layoutTestController)
+        layoutTestController.notifyDone();
+}
+
+function failFrameLoaded()
+{
+    if (document.getElementById('fail').contentDocument.URL == "about:blank")
+        return;
+    testFailed("The formtarget attribute was not used.");
+    isSuccessfullyParsed();
+    if (window.layoutTestController)
+        layoutTestController.notifyDone();
+}
+
+var successfullyParsed = true;
+</script>
+<iframe src="about:blank" id="pass" name="passFrame" onload="passFrameLoaded()"></iframe>
+<iframe src="about:blank" id="fail" name="failFrame" onload="failFrameLoaded()"></iframe>
+</body>
+</html>
diff --git a/LayoutTests/fast/forms/mailto/formenctype-attribute-button-html-expected.txt b/LayoutTests/fast/forms/mailto/formenctype-attribute-button-html-expected.txt
new file mode 100644
index 0000000..389b060
--- /dev/null
+++ b/LayoutTests/fast/forms/mailto/formenctype-attribute-button-html-expected.txt
@@ -0,0 +1,2 @@
+Policy delegate: attempt to load mailto:?body=to%3Done%40example.org%0D%0Abody%3DLine%201%0D%0ALine%202%0D%0A%40%26%3D%2C%3B%3F%22%2B%0D%0A with navigation type 'form submitted' originating from HTML > #document
+Field 1:  Field 2:  
diff --git a/LayoutTests/fast/forms/mailto/formenctype-attribute-button-html.html b/LayoutTests/fast/forms/mailto/formenctype-attribute-button-html.html
new file mode 100644
index 0000000..7929b95
--- /dev/null
+++ b/LayoutTests/fast/forms/mailto/formenctype-attribute-button-html.html
@@ -0,0 +1,26 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+</head>
+<body onload="test()">
+<p id="description"></p>
+<div id="console"></div>
+<form method="post" action="mailto:">
+Field 1: <input type="text" size="10" maxlength="40" name="to" value="one at example.org">
+Field 2: <textarea name="body">Line 1
+Line 2
+@&amp;=,;?"+</textarea>
+<button type="submit" id="submit" formenctype="text/plain" />
+</form>
+<script>
+function test()
+{
+    if (window.layoutTestController) {
+        layoutTestController.dumpAsText();
+        layoutTestController.waitForPolicyDelegate();
+    }
+    document.getElementById("submit").click();
+}
+</script>
+</body>
+</html>
diff --git a/LayoutTests/fast/forms/mailto/formenctype-attribute-input-html-expected.txt b/LayoutTests/fast/forms/mailto/formenctype-attribute-input-html-expected.txt
new file mode 100644
index 0000000..389b060
--- /dev/null
+++ b/LayoutTests/fast/forms/mailto/formenctype-attribute-input-html-expected.txt
@@ -0,0 +1,2 @@
+Policy delegate: attempt to load mailto:?body=to%3Done%40example.org%0D%0Abody%3DLine%201%0D%0ALine%202%0D%0A%40%26%3D%2C%3B%3F%22%2B%0D%0A with navigation type 'form submitted' originating from HTML > #document
+Field 1:  Field 2:  
diff --git a/LayoutTests/fast/forms/mailto/formenctype-attribute-input-html.html b/LayoutTests/fast/forms/mailto/formenctype-attribute-input-html.html
new file mode 100644
index 0000000..71f7719
--- /dev/null
+++ b/LayoutTests/fast/forms/mailto/formenctype-attribute-input-html.html
@@ -0,0 +1,26 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+</head>
+<body onload="test()">
+<p id="description"></p>
+<div id="console"></div>
+<form method="post" action="mailto:">
+Field 1: <input type="text" size="10" maxlength="40" name="to" value="one at example.org">
+Field 2: <textarea name="body">Line 1
+Line 2
+@&amp;=,;?"+</textarea>
+<input type="submit" id="submit" formenctype="text/plain" />
+</form>
+<script>
+function test()
+{
+    if (window.layoutTestController) {
+        layoutTestController.dumpAsText();
+        layoutTestController.waitForPolicyDelegate();
+    }
+    document.getElementById("submit").click();
+}
+</script>
+</body>
+</html>
diff --git a/LayoutTests/fast/forms/script-tests/submit-form-attributes.js b/LayoutTests/fast/forms/script-tests/submit-form-attributes.js
new file mode 100644
index 0000000..992c086
--- /dev/null
+++ b/LayoutTests/fast/forms/script-tests/submit-form-attributes.js
@@ -0,0 +1,191 @@
+description('Tests the behavior of .formaction, .formenctype, .formmethod and .formtarget of HTMLInputElement and HTMLButtonElement.');
+
+var input = document.createElement('input');
+
+debug('Ordinary values for input:');
+input.type = "submit";
+shouldBe('input.formAction', '""');
+shouldBe('input.formEnctype', '""');
+shouldBe('input.formMethod', '""');
+shouldBe('input.formTarget', '""');
+
+input.setAttribute('formAction', 'http://localhost');
+shouldBe('input.formAction', '"http://localhost/"');
+input.setAttribute('formAction', 'http://localhost/');
+shouldBe('input.formAction', '"http://localhost/"');
+input.setAttribute('formEnctype', 'text/plain');
+shouldBe('input.formEnctype', '"text/plain"');
+input.setAttribute('formEnctype', 'na');
+shouldBe('input.formEnctype', '"na"');
+input.setAttribute('formMethod', 'GET');
+shouldBe('input.formMethod', '"GET"');
+input.setAttribute('formMethod', 'ni');
+shouldBe('input.formMethod', '"ni"');
+input.setAttribute('formTarget', '_blank');
+shouldBe('input.formTarget', '"_blank"');
+input.setAttribute('formTarget', 'nu');
+shouldBe('input.formTarget', '"nu"');
+
+input.formAction = 'http://example.com';
+shouldBe('input.formAction', '"http://example.com/"');
+input.formAction = 'http://example.com/';
+shouldBe('input.formAction', '"http://example.com/"');
+input.formEnctype = 'text/plain';
+shouldBe('input.formEnctype', '"text/plain"');
+input.formEnctype = 'nota';
+shouldBe('input.formEnctype', '"nota"');
+input.formMethod = 'POST';
+shouldBe('input.formMethod', '"POST"');
+input.formMethod = 'neta';
+shouldBe('input.formMethod', '"neta"');
+input.formTarget = 'http://example.com';
+shouldBe('input.formTarget', '"http://example.com"');
+input.formTarget = 'nta';
+shouldBe('input.formTarget', '"nta"');
+
+debug('Setting null for input:');
+input.formEnctype = null;
+shouldBe('input.formEnctype', '""');
+shouldBe('input.getAttribute("formEnctype")', 'null');
+input.setAttribute('formEnctype', null);
+shouldBe('input.formEnctype', '"null"');
+input.formMethod = null;
+shouldBe('input.formMethod', '""');
+shouldBe('input.getAttribute("formMethod")', 'null');
+input.setAttribute('formMethod', null);
+shouldBe('input.formMethod', '"null"');
+input.formTarget = null;
+shouldBe('input.formTarget', '""');
+shouldBe('input.getAttribute("formTarget")', 'null');
+input.setAttribute('formTarget', null);
+shouldBe('input.formTarget', '"null"');
+
+debug('Setting undefined for input:');
+input.formEnctype = undefined;
+shouldBe('input.formEnctype', '"undefined"');
+shouldBe('input.getAttribute("formEnctype")', '"undefined"');
+input.setAttribute('formEnctype', undefined);
+shouldBe('input.formEnctype', '"undefined"');
+input.formMethod = undefined;
+shouldBe('input.formMethod', '"undefined"');
+shouldBe('input.getAttribute("formMethod")', '"undefined"');
+input.setAttribute('formMethod', undefined);
+shouldBe('input.formMethod', '"undefined"');
+input.formTarget = undefined;
+shouldBe('input.formTarget', '"undefined"');
+shouldBe('input.getAttribute("formTarget")', '"undefined"');
+input.setAttribute('formTarget', undefined);
+shouldBe('input.formTarget', '"undefined"');
+
+debug('Setting non-string for input:');
+input.formEnctype = 256;
+shouldBe('input.formEnctype', '"256"');
+shouldBe('input.getAttribute("formEnctype")', '"256"');
+input.setAttribute('formEnctype', 256);
+shouldBe('input.formEnctype', '"256"');
+input.formMethod = 256;
+shouldBe('input.formMethod', '"256"');
+shouldBe('input.getAttribute("formMethod")', '"256"');
+input.setAttribute('formMethod', 256);
+shouldBe('input.formMethod', '"256"');
+input.formTarget = 256;
+shouldBe('input.formTarget', '"256"');
+shouldBe('input.getAttribute("formTarget")', '"256"');
+input.setAttribute('formTarget', 256);
+shouldBe('input.formTarget', '"256"');
+
+var button = document.createElement('button');
+
+debug('Ordinary values for button:');
+button.type = "submit";
+shouldBe('button.formAction', '""');
+shouldBe('button.formEnctype', '""');
+shouldBe('button.formMethod', '""');
+shouldBe('button.formTarget', '""');
+
+button.setAttribute('formAction', 'http://localhost');
+shouldBe('button.formAction', '"http://localhost/"');
+button.setAttribute('formAction', 'http://localhost/');
+shouldBe('button.formAction', '"http://localhost/"');
+button.setAttribute('formEnctype', 'text/plain');
+shouldBe('button.formEnctype', '"text/plain"');
+button.setAttribute('formEnctype', 'na');
+shouldBe('button.formEnctype', '"na"');
+button.setAttribute('formMethod', 'GET');
+shouldBe('button.formMethod', '"GET"');
+button.setAttribute('formMethod', 'na');
+shouldBe('button.formMethod', '"na"');
+button.setAttribute('formTarget', '_blank');
+shouldBe('button.formTarget', '"_blank"');
+button.setAttribute('formTarget', 'na');
+shouldBe('button.formTarget', '"na"');
+
+button.formAction = 'http://example.com';
+shouldBe('button.formAction', '"http://example.com/"');
+button.formAction = 'http://example.com/';
+shouldBe('button.formAction', '"http://example.com/"');
+button.formEnctype = 'text/plain';
+shouldBe('button.formEnctype', '"text/plain"');
+button.formEnctype = 'nota';
+shouldBe('button.formEnctype', '"nota"');
+button.formMethod = 'POST';
+shouldBe('button.formMethod', '"POST"');
+button.formMethod = 'nota';
+shouldBe('button.formMethod', '"nota"');
+button.formTarget = 'http://example.com';
+shouldBe('button.formTarget', '"http://example.com"');
+button.formTarget = 'nota';
+shouldBe('button.formTarget', '"nota"');
+
+debug('Setting null for button:');
+button.formEnctype = null;
+shouldBe('button.formEnctype', '""');
+shouldBe('button.getAttribute("formEnctype")', 'null');
+button.setAttribute('formEnctype', null);
+shouldBe('button.formEnctype', '"null"');
+button.formMethod = null;
+shouldBe('button.formMethod', '""');
+shouldBe('button.getAttribute("formMethod")', 'null');
+button.setAttribute('formMethod', null);
+shouldBe('button.formMethod', '"null"');
+button.formTarget = null;
+shouldBe('button.formTarget', '""');
+shouldBe('button.getAttribute("formTarget")', 'null');
+button.setAttribute('formTarget', null);
+shouldBe('button.formTarget', '"null"');
+
+debug('Setting undefined for button:');
+button.formEnctype = undefined;
+shouldBe('button.formEnctype', '"undefined"');
+shouldBe('button.getAttribute("formEnctype")', '"undefined"');
+button.setAttribute('formEnctype', undefined);
+shouldBe('button.formEnctype', '"undefined"');
+button.formMethod = undefined;
+shouldBe('button.formMethod', '"undefined"');
+shouldBe('button.getAttribute("formMethod")', '"undefined"');
+button.setAttribute('formMethod', undefined);
+shouldBe('button.formMethod', '"undefined"');
+button.formTarget = undefined;
+shouldBe('button.formTarget', '"undefined"');
+shouldBe('button.getAttribute("formTarget")', '"undefined"');
+button.setAttribute('formTarget', undefined);
+shouldBe('button.formTarget', '"undefined"');
+
+debug('Setting non-string for button:');
+button.formEnctype = 256;
+shouldBe('button.formEnctype', '"256"');
+shouldBe('button.getAttribute("formEnctype")', '"256"');
+button.setAttribute('formEnctype', 512);
+shouldBe('button.formEnctype', '"512"');
+button.formMethod = 128;
+shouldBe('button.formMethod', '"128"');
+shouldBe('button.getAttribute("formMethod")', '"128"');
+button.setAttribute('formMethod', 17);
+shouldBe('button.formMethod', '"17"');
+button.formTarget = 100;
+shouldBe('button.formTarget', '"100"');
+shouldBe('button.getAttribute("formTarget")', '"100"');
+button.setAttribute('formTarget', 281);
+shouldBe('button.formTarget', '"281"');
+
+var successfullyParsed = true;
diff --git a/LayoutTests/fast/forms/submit-form-attributes-expected.txt b/LayoutTests/fast/forms/submit-form-attributes-expected.txt
new file mode 100644
index 0000000..930e53e
--- /dev/null
+++ b/LayoutTests/fast/forms/submit-form-attributes-expected.txt
@@ -0,0 +1,111 @@
+Tests the behavior of .formaction, .formenctype, .formmethod and .formtarget of HTMLInputElement and HTMLButtonElement.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Ordinary values for input:
+PASS input.formAction is ""
+PASS input.formEnctype is ""
+PASS input.formMethod is ""
+PASS input.formTarget is ""
+PASS input.formAction is "http://localhost/"
+PASS input.formAction is "http://localhost/"
+PASS input.formEnctype is "text/plain"
+PASS input.formEnctype is "na"
+PASS input.formMethod is "GET"
+PASS input.formMethod is "ni"
+PASS input.formTarget is "_blank"
+PASS input.formTarget is "nu"
+PASS input.formAction is "http://example.com/"
+PASS input.formAction is "http://example.com/"
+PASS input.formEnctype is "text/plain"
+PASS input.formEnctype is "nota"
+PASS input.formMethod is "POST"
+PASS input.formMethod is "neta"
+PASS input.formTarget is "http://example.com"
+PASS input.formTarget is "nta"
+Setting null for input:
+PASS input.formEnctype is ""
+PASS input.getAttribute("formEnctype") is null
+PASS input.formEnctype is "null"
+PASS input.formMethod is ""
+PASS input.getAttribute("formMethod") is null
+PASS input.formMethod is "null"
+PASS input.formTarget is ""
+PASS input.getAttribute("formTarget") is null
+PASS input.formTarget is "null"
+Setting undefined for input:
+PASS input.formEnctype is "undefined"
+PASS input.getAttribute("formEnctype") is "undefined"
+PASS input.formEnctype is "undefined"
+PASS input.formMethod is "undefined"
+PASS input.getAttribute("formMethod") is "undefined"
+PASS input.formMethod is "undefined"
+PASS input.formTarget is "undefined"
+PASS input.getAttribute("formTarget") is "undefined"
+PASS input.formTarget is "undefined"
+Setting non-string for input:
+PASS input.formEnctype is "256"
+PASS input.getAttribute("formEnctype") is "256"
+PASS input.formEnctype is "256"
+PASS input.formMethod is "256"
+PASS input.getAttribute("formMethod") is "256"
+PASS input.formMethod is "256"
+PASS input.formTarget is "256"
+PASS input.getAttribute("formTarget") is "256"
+PASS input.formTarget is "256"
+Ordinary values for button:
+PASS button.formAction is ""
+PASS button.formEnctype is ""
+PASS button.formMethod is ""
+PASS button.formTarget is ""
+PASS button.formAction is "http://localhost/"
+PASS button.formAction is "http://localhost/"
+PASS button.formEnctype is "text/plain"
+PASS button.formEnctype is "na"
+PASS button.formMethod is "GET"
+PASS button.formMethod is "na"
+PASS button.formTarget is "_blank"
+PASS button.formTarget is "na"
+PASS button.formAction is "http://example.com/"
+PASS button.formAction is "http://example.com/"
+PASS button.formEnctype is "text/plain"
+PASS button.formEnctype is "nota"
+PASS button.formMethod is "POST"
+PASS button.formMethod is "nota"
+PASS button.formTarget is "http://example.com"
+PASS button.formTarget is "nota"
+Setting null for button:
+PASS button.formEnctype is ""
+PASS button.getAttribute("formEnctype") is null
+PASS button.formEnctype is "null"
+PASS button.formMethod is ""
+PASS button.getAttribute("formMethod") is null
+PASS button.formMethod is "null"
+PASS button.formTarget is ""
+PASS button.getAttribute("formTarget") is null
+PASS button.formTarget is "null"
+Setting undefined for button:
+PASS button.formEnctype is "undefined"
+PASS button.getAttribute("formEnctype") is "undefined"
+PASS button.formEnctype is "undefined"
+PASS button.formMethod is "undefined"
+PASS button.getAttribute("formMethod") is "undefined"
+PASS button.formMethod is "undefined"
+PASS button.formTarget is "undefined"
+PASS button.getAttribute("formTarget") is "undefined"
+PASS button.formTarget is "undefined"
+Setting non-string for button:
+PASS button.formEnctype is "256"
+PASS button.getAttribute("formEnctype") is "256"
+PASS button.formEnctype is "512"
+PASS button.formMethod is "128"
+PASS button.getAttribute("formMethod") is "128"
+PASS button.formMethod is "17"
+PASS button.formTarget is "100"
+PASS button.getAttribute("formTarget") is "100"
+PASS button.formTarget is "281"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/forms/submit-form-attributes.html b/LayoutTests/fast/forms/submit-form-attributes.html
new file mode 100644
index 0000000..a7686a7
--- /dev/null
+++ b/LayoutTests/fast/forms/submit-form-attributes.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="script-tests/submit-form-attributes.js"></script>
+<script src="../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index e2375f6..f57fb49 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,27 @@
+2010-11-15  Dai Mikurube  <dmikurube at google.com>
+
+        Reviewed by Kent Tamura.
+
+        Implement formaction, formenctype, formmethod and formtarget attributes for input and button tags
+        https://bugs.webkit.org/show_bug.cgi?id=49240
+
+        Tests: fast/forms/formaction-attribute.html
+               fast/forms/formmethod-attribute-button-html.html
+               fast/forms/formmethod-attribute-input-html.html
+               fast/forms/formtarget-attribute-button-html.html
+               fast/forms/formtarget-attribute-input-html.html
+               fast/forms/mailto/formenctype-attribute-button-html.html
+               fast/forms/mailto/formenctype-attribute-input-html.html
+               fast/forms/submit-form-attributes.html
+
+        * html/HTMLAttributeNames.in: Added formaction, formmethod, formtarget and formenctype attributes
+        * html/HTMLButtonElement.idl:
+        * html/HTMLInputElement.idl:
+        * loader/FormSubmission.cpp: Modified to check the pressed button and its attributes
+        (WebCore::FormSubmission::Attributes::copyFrom):
+        (WebCore::FormSubmission::create):
+        * loader/FormSubmission.h:
+
 2010-11-15  Pavel Feldman  <pfeldman at chromium.org>
 
         Reviewed by Yury Semikhatsky.
diff --git a/WebCore/html/HTMLAttributeNames.in b/WebCore/html/HTMLAttributeNames.in
index 1881b6f..c6792f8 100644
--- a/WebCore/html/HTMLAttributeNames.in
+++ b/WebCore/html/HTMLAttributeNames.in
@@ -95,7 +95,11 @@ face
 focused
 for
 form
+formaction
+formenctype
+formmethod
 formnovalidate
+formtarget
 frame
 frameborder
 headers
diff --git a/WebCore/html/HTMLButtonElement.idl b/WebCore/html/HTMLButtonElement.idl
index 279e858..2fbba41 100644
--- a/WebCore/html/HTMLButtonElement.idl
+++ b/WebCore/html/HTMLButtonElement.idl
@@ -23,7 +23,11 @@ module html {
     interface HTMLButtonElement : HTMLElement {
         readonly attribute HTMLFormElement form;
 
+        attribute [Reflect, URL] DOMString formAction;
+        attribute [Reflect] DOMString formEnctype;
+        attribute [Reflect] DOMString formMethod;
         attribute [Reflect] boolean formNoValidate;
+        attribute [Reflect] DOMString formTarget;
         readonly attribute ValidityState validity;
 
         attribute [Reflect] DOMString accessKey;
diff --git a/WebCore/html/HTMLInputElement.idl b/WebCore/html/HTMLInputElement.idl
index 157989e..342e9b8 100644
--- a/WebCore/html/HTMLInputElement.idl
+++ b/WebCore/html/HTMLInputElement.idl
@@ -24,7 +24,11 @@ module html {
         attribute [ConvertNullToNullString] DOMString defaultValue;
         attribute [Reflect=checked] boolean defaultChecked;
         readonly attribute HTMLFormElement form;
+        attribute [Reflect, URL] DOMString formAction;
+        attribute [Reflect] DOMString formEnctype;
+        attribute [Reflect] DOMString formMethod;
         attribute [Reflect] boolean formNoValidate;
+        attribute [Reflect] DOMString formTarget;
         readonly attribute ValidityState validity;
         attribute [Reflect] DOMString accept;
         attribute [Reflect] DOMString accessKey;
diff --git a/WebCore/loader/FormSubmission.cpp b/WebCore/loader/FormSubmission.cpp
index f3f19d2..a9f2680 100644
--- a/WebCore/loader/FormSubmission.cpp
+++ b/WebCore/loader/FormSubmission.cpp
@@ -110,6 +110,17 @@ void FormSubmission::Attributes::parseMethodType(const String& type)
         m_method = FormSubmission::GetMethod;
 }
 
+void FormSubmission::Attributes::copyFrom(const Attributes& other)
+{
+    m_method = other.m_method;
+    m_isMultiPartForm = other.m_isMultiPartForm;
+
+    m_action = other.m_action;
+    m_target = other.m_target;
+    m_encodingType = other.m_encodingType;
+    m_acceptCharset = other.m_acceptCharset;
+}
+
 inline FormSubmission::FormSubmission(Method method, const KURL& action, const String& target, const String& contentType, PassRefPtr<FormState> state, PassRefPtr<FormData> data, const String& boundary, bool lockHistory, PassRefPtr<Event> event)
     : m_method(method)
     , m_action(action)
@@ -126,21 +137,40 @@ inline FormSubmission::FormSubmission(Method method, const KURL& action, const S
 PassRefPtr<FormSubmission> FormSubmission::create(HTMLFormElement* form, const Attributes& attributes, PassRefPtr<Event> event, bool lockHistory, FormSubmissionTrigger trigger)
 {
     ASSERT(form);
+
+    HTMLFormControlElement* submitButton = 0;
+    if (event && event->target() && event->target()->toNode())
+        submitButton = static_cast<HTMLFormControlElement*>(event->target()->toNode());
+
+    FormSubmission::Attributes copiedAttributes;
+    copiedAttributes.copyFrom(attributes);
+    if (submitButton) {
+        String attributeValue;
+        if (!(attributeValue = submitButton->getAttribute(formactionAttr)).isNull())
+            copiedAttributes.parseAction(attributeValue);
+        if (!(attributeValue = submitButton->getAttribute(formenctypeAttr)).isNull())
+            copiedAttributes.parseEncodingType(attributeValue);
+        if (!(attributeValue = submitButton->getAttribute(formmethodAttr)).isNull())
+            copiedAttributes.parseMethodType(attributeValue);
+        if (!(attributeValue = submitButton->getAttribute(formtargetAttr)).isNull())
+            copiedAttributes.setTarget(attributeValue);
+    }
+    
     Document* document = form->document();
-    KURL actionURL = document->completeURL(attributes.action().isEmpty() ? document->url().string() : attributes.action());
+    KURL actionURL = document->completeURL(copiedAttributes.action().isEmpty() ? document->url().string() : copiedAttributes.action());
     bool isMailtoForm = actionURL.protocolIs("mailto");
     bool isMultiPartForm = false;
-    String encodingType = attributes.encodingType();
+    String encodingType = copiedAttributes.encodingType();
 
-    if (attributes.method() == PostMethod) {
-        isMultiPartForm = attributes.isMultiPartForm();
+    if (copiedAttributes.method() == PostMethod) {
+        isMultiPartForm = copiedAttributes.isMultiPartForm();
         if (isMultiPartForm && isMailtoForm) {
             encodingType = "application/x-www-form-urlencoded";
             isMultiPartForm = false;
         }
     }
 
-    TextEncoding dataEncoding = isMailtoForm ? UTF8Encoding() : FormDataBuilder::encodingFromAcceptCharset(attributes.acceptCharset(), document);
+    TextEncoding dataEncoding = isMailtoForm ? UTF8Encoding() : FormDataBuilder::encodingFromAcceptCharset(copiedAttributes.acceptCharset(), document);
     RefPtr<DOMFormData> domFormData = DOMFormData::create(dataEncoding.encodingForFormSubmission());
     Vector<pair<String, String> > formValues;
 
@@ -166,7 +196,7 @@ PassRefPtr<FormSubmission> FormSubmission::create(HTMLFormElement* form, const A
         boundary = formData->boundary().data();
     } else {
         formData = FormData::create(*(static_cast<FormDataList*>(domFormData.get())), domFormData->encoding());
-        if (attributes.method() == PostMethod && isMailtoForm) {
+        if (copiedAttributes.method() == PostMethod && isMailtoForm) {
             // Convert the form data into a string that we put into the URL.
             appendMailtoPostFormDataToURL(actionURL, *formData, encodingType);
             formData = FormData::create();
@@ -174,9 +204,9 @@ PassRefPtr<FormSubmission> FormSubmission::create(HTMLFormElement* form, const A
     }
 
     formData->setIdentifier(generateFormDataIdentifier());
-    String targetOrBaseTarget = attributes.target().isEmpty() ? document->baseTarget() : attributes.target();
+    String targetOrBaseTarget = copiedAttributes.target().isEmpty() ? document->baseTarget() : copiedAttributes.target();
     RefPtr<FormState> formState = FormState::create(form, formValues, document->frame(), trigger);
-    return adoptRef(new FormSubmission(attributes.method(), actionURL, targetOrBaseTarget, encodingType, formState.release(), formData.release(), boundary, lockHistory, event));
+    return adoptRef(new FormSubmission(copiedAttributes.method(), actionURL, targetOrBaseTarget, encodingType, formState.release(), formData.release(), boundary, lockHistory, event));
 }
 
 KURL FormSubmission::requestURL() const
diff --git a/WebCore/loader/FormSubmission.h b/WebCore/loader/FormSubmission.h
index b935882..d724835 100644
--- a/WebCore/loader/FormSubmission.h
+++ b/WebCore/loader/FormSubmission.h
@@ -72,6 +72,8 @@ public:
         const String& acceptCharset() const { return m_acceptCharset; }
         void setAcceptCharset(const String& value) { m_acceptCharset = value; }
 
+        void copyFrom(const Attributes&);
+
     private:
         Method m_method;
         bool m_isMultiPartForm;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list