Reviewed by George Staikos.
authorzimmermann@webkit.org <zimmermann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 22 Dec 2008 02:04:51 +0000 (02:04 +0000)
committerzimmermann@webkit.org <zimmermann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 22 Dec 2008 02:04:51 +0000 (02:04 +0000)
Fixes: https://bugs.webkit.org/show_bug.cgi?id=22638

Add POST method support to WMLGoElement. GET & POST over HTTP
covered by a new set of WML HTTP layout tests.

Tests: http/tests/wml/go-task-get-method-accept-charset.html
       http/tests/wml/go-task-get-method.html
       http/tests/wml/go-task-post-method-accept-charset.html
       http/tests/wml/go-task-post-method.html

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@39431 268f45cc-cd09-0410-ab3c-d52691b4dbfc

31 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/wml/go-task-get-method-accept-charset-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/wml/go-task-get-method-accept-charset.html [new file with mode: 0644]
LayoutTests/http/tests/wml/go-task-get-method-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/wml/go-task-get-method.html [new file with mode: 0644]
LayoutTests/http/tests/wml/go-task-post-method-accept-charset-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/wml/go-task-post-method-accept-charset.html [new file with mode: 0644]
LayoutTests/http/tests/wml/go-task-post-method-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/wml/go-task-post-method.html [new file with mode: 0644]
LayoutTests/http/tests/wml/resources/TEMPLATE.html [new file with mode: 0644]
LayoutTests/http/tests/wml/resources/answer-utf8.cgi [new file with mode: 0755]
LayoutTests/http/tests/wml/resources/answer.cgi [new file with mode: 0755]
LayoutTests/http/tests/wml/resources/go-task-get-method-accept-charset.js [new file with mode: 0644]
LayoutTests/http/tests/wml/resources/go-task-get-method.js [new file with mode: 0644]
LayoutTests/http/tests/wml/resources/go-task-post-method-accept-charset.js [new file with mode: 0644]
LayoutTests/http/tests/wml/resources/go-task-post-method.js [new file with mode: 0644]
LayoutTests/wml/go-task-animation.html
LayoutTests/wml/go-task-get-method-external-deck-with-href.html
LayoutTests/wml/go-task-get-method-external-deck.html
LayoutTests/wml/go-task-get-method-same-deck.html
LayoutTests/wml/resources/TEMPLATE.html
LayoutTests/wml/resources/WMLTestCase.js
LayoutTests/wml/variable-reference-invalid-character.html
LayoutTests/wml/variable-reference-valid.html
WebCore/ChangeLog
WebCore/wml/WMLGoElement.cpp
WebCore/wml/WMLGoElement.h
WebCore/wml/WMLPostfieldElement.cpp
WebCore/wml/WMLPostfieldElement.h
WebKitTools/ChangeLog
WebKitTools/Scripts/run-webkit-tests

index 78dbe08..260f01f 100644 (file)
@@ -1,3 +1,37 @@
+2008-12-22  Nikolas Zimmermann  <nikolas.zimmermann@torchmobile.com>
+
+        Reviewed by George Staikos.
+
+        Add WML HTTP layout tests and an initital set of results.
+        Allow to reuse the existing WMLTestCase.js framework from another
+        LayoutTests/ top-level directory - modify TEMPLATE.html & WMLTestCase.js.
+
+        * http/tests/wml: Added.
+        * http/tests/wml/go-task-get-method-accept-charset-expected.txt: Added.
+        * http/tests/wml/go-task-get-method-accept-charset.html: Added.
+        * http/tests/wml/go-task-get-method-expected.txt: Added.
+        * http/tests/wml/go-task-get-method.html: Added.
+        * http/tests/wml/go-task-post-method-accept-charset-expected.txt: Added.
+        * http/tests/wml/go-task-post-method-accept-charset.html: Added.
+        * http/tests/wml/go-task-post-method-expected.txt: Added.
+        * http/tests/wml/go-task-post-method.html: Added.
+        * http/tests/wml/resources: Added.
+        * http/tests/wml/resources/TEMPLATE.html: Added.
+        * http/tests/wml/resources/answer-utf8.cgi: Added.
+        * http/tests/wml/resources/answer.cgi: Added.
+        * http/tests/wml/resources/go-task-get-method-accept-charset.js: Added.
+        * http/tests/wml/resources/go-task-get-method.js: Added.
+        * http/tests/wml/resources/go-task-post-method-accept-charset.js: Added.
+        * http/tests/wml/resources/go-task-post-method.js: Added.
+        * wml/go-task-animation.html:
+        * wml/go-task-get-method-external-deck-with-href.html:
+        * wml/go-task-get-method-external-deck.html:
+        * wml/go-task-get-method-same-deck.html:
+        * wml/resources/TEMPLATE.html:
+        * wml/resources/WMLTestCase.js:
+        * wml/variable-reference-invalid-character.html:
+        * wml/variable-reference-valid.html:
+
 2008-12-19  Zan Dobersek  <zandobersek@gmail.com>
 
         Reviewed by Holger Freyther.
diff --git a/LayoutTests/http/tests/wml/go-task-get-method-accept-charset-expected.txt b/LayoutTests/http/tests/wml/go-task-get-method-accept-charset-expected.txt
new file mode 100644 (file)
index 0000000..277e62b
--- /dev/null
@@ -0,0 +1,22 @@
+WML http navigation layout tests - using XHTML scripting
+
+
+Tests GET method of <go> element - accept-charset attribute
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
+
+--------
+Frame: '<!--framePath //<!--frame0-->-->'
+--------
+This page was requested with an HTTP GET
+
+The query parameters are: var1=Text%20with%20whitespace;var2=Text%20with%20non-latin1%20characters%3A%20Sch%C3%B6n%2C%20da%C3%9F%20es%20%C3%84%26Ouml%3B%C3%9C%20gibt%21
+Form content var1: 'Text with whitespace'
+Form content var2: 'Text with non-latin1 characters: Schön, daß es ÄÖÜ gibt!'
+
diff --git a/LayoutTests/http/tests/wml/go-task-get-method-accept-charset.html b/LayoutTests/http/tests/wml/go-task-get-method-accept-charset.html
new file mode 100644 (file)
index 0000000..6b82dd2
--- /dev/null
@@ -0,0 +1,15 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../../fast/js/resources/js-test-style.css">
+<script>var relativePathToLayoutTests = "../../..";</script>
+<script src="../../../wml/resources/WMLTestCase.js"></script>
+<script src="../../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<h1>WML http navigation layout tests - using XHTML scripting</h1>
+<p id="description"></p>
+<div id="console"></div>
+<script src="resources/go-task-get-method-accept-charset.js" charset="utf8"></script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/wml/go-task-get-method-expected.txt b/LayoutTests/http/tests/wml/go-task-get-method-expected.txt
new file mode 100644 (file)
index 0000000..7bdf1f8
--- /dev/null
@@ -0,0 +1,22 @@
+WML http navigation layout tests - using XHTML scripting
+
+
+Tests GET method of <go> element
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
+
+--------
+Frame: '<!--framePath //<!--frame0-->-->'
+--------
+This page was requested with an HTTP GET
+
+The query parameters are: var1=Text%20with%20whitespace;var2=Text%20with%20entities%3A%20%26auml%3B%20and%20%26ouml%3B
+Form content var1: 'Text with whitespace'
+Form content var2: 'Text with entities: ä and ö'
+
diff --git a/LayoutTests/http/tests/wml/go-task-get-method.html b/LayoutTests/http/tests/wml/go-task-get-method.html
new file mode 100644 (file)
index 0000000..6d1b8c4
--- /dev/null
@@ -0,0 +1,15 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../../fast/js/resources/js-test-style.css">
+<script>var relativePathToLayoutTests = "../../..";</script>
+<script src="../../../wml/resources/WMLTestCase.js"></script>
+<script src="../../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<h1>WML http navigation layout tests - using XHTML scripting</h1>
+<p id="description"></p>
+<div id="console"></div>
+<script src="resources/go-task-get-method.js" charset="utf8"></script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/wml/go-task-post-method-accept-charset-expected.txt b/LayoutTests/http/tests/wml/go-task-post-method-accept-charset-expected.txt
new file mode 100644 (file)
index 0000000..762b417
--- /dev/null
@@ -0,0 +1,22 @@
+WML http navigation layout tests - using XHTML scripting
+
+
+Tests POST method of <go> element - accept-charset attribute
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
+
+--------
+Frame: '<!--framePath //<!--frame0-->-->'
+--------
+This page was requested with an HTTP POST
+
+The query parameters are: var1=Text%20with%20whitespace;var2=Text%20with%20non-latin1%20characters%3A%20Sch%C3%B6n%2C%20da%C3%9F%20es%20%C3%84%26Ouml%3B%C3%9C%20gibt%21
+Form content var1: 'Text with whitespace'
+Form content var2: 'Text with non-latin1 characters: Schön, daß es ÄÖÜ gibt!'
+
diff --git a/LayoutTests/http/tests/wml/go-task-post-method-accept-charset.html b/LayoutTests/http/tests/wml/go-task-post-method-accept-charset.html
new file mode 100644 (file)
index 0000000..e2aac65
--- /dev/null
@@ -0,0 +1,15 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../../fast/js/resources/js-test-style.css">
+<script>var relativePathToLayoutTests = "../../..";</script>
+<script src="../../../wml/resources/WMLTestCase.js"></script>
+<script src="../../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<h1>WML http navigation layout tests - using XHTML scripting</h1>
+<p id="description"></p>
+<div id="console"></div>
+<script src="resources/go-task-post-method-accept-charset.js" charset="utf8"></script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/wml/go-task-post-method-expected.txt b/LayoutTests/http/tests/wml/go-task-post-method-expected.txt
new file mode 100644 (file)
index 0000000..0eaa2b7
--- /dev/null
@@ -0,0 +1,22 @@
+WML http navigation layout tests - using XHTML scripting
+
+
+Tests POST method of <go> element
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
+
+--------
+Frame: '<!--framePath //<!--frame0-->-->'
+--------
+This page was requested with an HTTP POST
+
+The query parameters are: var1=Text%20with%20whitespace;var2=Text%20with%20entities%3A%20%26auml%3B%20and%20%26ouml%3B
+Form content var1: 'Text with whitespace'
+Form content var2: 'Text with entities: ä and ö'
+
diff --git a/LayoutTests/http/tests/wml/go-task-post-method.html b/LayoutTests/http/tests/wml/go-task-post-method.html
new file mode 100644 (file)
index 0000000..ecd9fd6
--- /dev/null
@@ -0,0 +1,15 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../../fast/js/resources/js-test-style.css">
+<script>var relativePathToLayoutTests = "../../..";</script>
+<script src="../../../wml/resources/WMLTestCase.js"></script>
+<script src="../../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<h1>WML http navigation layout tests - using XHTML scripting</h1>
+<p id="description"></p>
+<div id="console"></div>
+<script src="resources/go-task-post-method.js" charset="utf8"></script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/wml/resources/TEMPLATE.html b/LayoutTests/http/tests/wml/resources/TEMPLATE.html
new file mode 100644 (file)
index 0000000..191704b
--- /dev/null
@@ -0,0 +1,15 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../../fast/js/resources/js-test-style.css">
+<script>var relativePathToLayoutTests = "../../..";</script>
+<script src="../../../wml/resources/WMLTestCase.js"></script>
+<script src="../../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<h1>WML http navigation layout tests - using XHTML scripting</h1>
+<p id="description"></p>
+<div id="console"></div>
+<script src="YOUR_JS_FILE_HERE" charset="utf8"></script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/wml/resources/answer-utf8.cgi b/LayoutTests/http/tests/wml/resources/answer-utf8.cgi
new file mode 100755 (executable)
index 0000000..67e225d
--- /dev/null
@@ -0,0 +1,24 @@
+#!/usr/bin/perl -w
+
+use CGI;
+
+$query = new CGI;
+$method = $query->request_method();
+$queryString = $query->query_string;
+$var1 = $query->param("var1");
+$var2 = $query->param("var2");
+
+print "Content-type: text/html;charset=utf-8\r\n";
+print "Cache-Control: no-store, no-cache, must-revalidate\r\n";
+print "\r\n";
+
+print <<HERE_DOC_END;
+<html>
+<body>
+This page was requested with an HTTP $method<br/><br/>
+The query parameters are: $queryString<br/>
+Form content var1: '$var1'<br/>
+Form content var2: '$var2'<br/>
+</body>
+</html>
+HERE_DOC_END
diff --git a/LayoutTests/http/tests/wml/resources/answer.cgi b/LayoutTests/http/tests/wml/resources/answer.cgi
new file mode 100755 (executable)
index 0000000..83d66fa
--- /dev/null
@@ -0,0 +1,24 @@
+#!/usr/bin/perl -w
+
+use CGI;
+
+$query = new CGI;
+$method = $query->request_method();
+$queryString = $query->query_string;
+$var1 = $query->param("var1");
+$var2 = $query->param("var2");
+
+print "Content-type: text/html\r\n";
+print "Cache-Control: no-store, no-cache, must-revalidate\r\n";
+print "\r\n";
+
+print <<HERE_DOC_END;
+<html>
+<body>
+This page was requested with an HTTP $method<br/><br/>
+The query parameters are: $queryString<br/>
+Form content var1: '$var1'<br/>
+Form content var2: '$var2'<br/>
+</body>
+</html>
+HERE_DOC_END
diff --git a/LayoutTests/http/tests/wml/resources/go-task-get-method-accept-charset.js b/LayoutTests/http/tests/wml/resources/go-task-get-method-accept-charset.js
new file mode 100644 (file)
index 0000000..52f440e
--- /dev/null
@@ -0,0 +1,38 @@
+// [Name] go-task-get-method-accept-charset.js
+
+createWMLTestCase("Tests GET method of &lt;go&gt; element - accept-charset attribute", false);
+
+function setupTestDocument() {
+    var cardElement = testDocument.documentElement.firstChild;
+
+    var anchorElement = createWMLElement("anchor");
+    anchorElement.appendChild(testDocument.createTextNode("Start test"));
+    cardElement.appendChild(anchorElement);
+
+    var goElement = createWMLElement("go");
+    goElement.setAttribute("method", "GET");
+    goElement.setAttribute("accept-charset", "utf-8");
+    goElement.setAttribute("href", "http://127.0.0.1:8000/wml/resources/answer-utf8.cgi");
+
+    var postfieldElement1 = createWMLElement("postfield");
+    postfieldElement1.setAttribute("name", "var1");
+    postfieldElement1.setAttribute("value", "Text with whitespace");
+    goElement.appendChild(postfieldElement1);
+
+    var postfieldElement2 = createWMLElement("postfield");
+    postfieldElement2.setAttribute("name", "var2");
+    postfieldElement2.setAttribute("value", "Text with non-latin1 characters: Schön, daß es Ä&Ouml;Ü gibt!");
+    goElement.appendChild(postfieldElement2);
+
+    anchorElement.appendChild(goElement);
+}
+
+function prepareTest() {
+    startTest(25, 15);
+}
+
+function executeTest() {
+    completeTest();
+}
+
+var successfullyParsed = true;
diff --git a/LayoutTests/http/tests/wml/resources/go-task-get-method.js b/LayoutTests/http/tests/wml/resources/go-task-get-method.js
new file mode 100644 (file)
index 0000000..d5fa8c3
--- /dev/null
@@ -0,0 +1,37 @@
+// [Name] go-task-get-method.js
+
+createWMLTestCase("Tests GET method of &lt;go&gt; element", false);
+
+function setupTestDocument() {
+    var cardElement = testDocument.documentElement.firstChild;
+
+    var anchorElement = createWMLElement("anchor");
+    anchorElement.appendChild(testDocument.createTextNode("Start test"));
+    cardElement.appendChild(anchorElement);
+
+    var goElement = createWMLElement("go");
+    goElement.setAttribute("method", "GET");
+    goElement.setAttribute("href", "http://127.0.0.1:8000/wml/resources/answer.cgi");
+
+    var postfieldElement1 = createWMLElement("postfield");
+    postfieldElement1.setAttribute("name", "var1");
+    postfieldElement1.setAttribute("value", "Text with whitespace");
+    goElement.appendChild(postfieldElement1);
+
+    var postfieldElement2 = createWMLElement("postfield");
+    postfieldElement2.setAttribute("name", "var2");
+    postfieldElement2.setAttribute("value", "Text with entities: &auml; and &ouml;");
+    goElement.appendChild(postfieldElement2);
+
+    anchorElement.appendChild(goElement);
+}
+
+function prepareTest() {
+    startTest(25, 15);
+}
+
+function executeTest() {
+    completeTest();
+}
+
+var successfullyParsed = true;
diff --git a/LayoutTests/http/tests/wml/resources/go-task-post-method-accept-charset.js b/LayoutTests/http/tests/wml/resources/go-task-post-method-accept-charset.js
new file mode 100644 (file)
index 0000000..7601ad8
--- /dev/null
@@ -0,0 +1,38 @@
+// [Name] go-task-post-method-accept-charset.js
+
+createWMLTestCase("Tests POST method of &lt;go&gt; element - accept-charset attribute", false);
+
+function setupTestDocument() {
+    var cardElement = testDocument.documentElement.firstChild;
+
+    var anchorElement = createWMLElement("anchor");
+    anchorElement.appendChild(testDocument.createTextNode("Start test"));
+    cardElement.appendChild(anchorElement);
+
+    var goElement = createWMLElement("go");
+    goElement.setAttribute("method", "POST");
+    goElement.setAttribute("accept-charset", "utf-8");
+    goElement.setAttribute("href", "http://127.0.0.1:8000/wml/resources/answer-utf8.cgi");
+
+    var postfieldElement1 = createWMLElement("postfield");
+    postfieldElement1.setAttribute("name", "var1");
+    postfieldElement1.setAttribute("value", "Text with whitespace");
+    goElement.appendChild(postfieldElement1);
+
+    var postfieldElement2 = createWMLElement("postfield");
+    postfieldElement2.setAttribute("name", "var2");
+    postfieldElement2.setAttribute("value", "Text with non-latin1 characters: Schön, daß es Ä&Ouml;Ü gibt!");
+    goElement.appendChild(postfieldElement2);
+
+    anchorElement.appendChild(goElement);
+}
+
+function prepareTest() {
+    startTest(25, 15);
+}
+
+function executeTest() {
+    completeTest();
+}
+
+var successfullyParsed = true;
diff --git a/LayoutTests/http/tests/wml/resources/go-task-post-method.js b/LayoutTests/http/tests/wml/resources/go-task-post-method.js
new file mode 100644 (file)
index 0000000..7803fde
--- /dev/null
@@ -0,0 +1,37 @@
+// [Name] go-task-post-method.js
+
+createWMLTestCase("Tests POST method of &lt;go&gt; element", false);
+
+function setupTestDocument() {
+    var cardElement = testDocument.documentElement.firstChild;
+
+    var anchorElement = createWMLElement("anchor");
+    anchorElement.appendChild(testDocument.createTextNode("Start test"));
+    cardElement.appendChild(anchorElement);
+
+    var goElement = createWMLElement("go");
+    goElement.setAttribute("method", "POST");
+    goElement.setAttribute("href", "http://127.0.0.1:8000/wml/resources/answer.cgi");
+
+    var postfieldElement1 = createWMLElement("postfield");
+    postfieldElement1.setAttribute("name", "var1");
+    postfieldElement1.setAttribute("value", "Text with whitespace");
+    goElement.appendChild(postfieldElement1);
+
+    var postfieldElement2 = createWMLElement("postfield");
+    postfieldElement2.setAttribute("name", "var2");
+    postfieldElement2.setAttribute("value", "Text with entities: &auml; and &ouml;");
+    goElement.appendChild(postfieldElement2);
+
+    anchorElement.appendChild(goElement);
+}
+
+function prepareTest() {
+    startTest(25, 15);
+}
+
+function executeTest() {
+    completeTest();
+}
+
+var successfullyParsed = true;
index 7b5bbcc..560dd45 100644 (file)
@@ -2,6 +2,7 @@
 <html>
 <head>
 <link rel="stylesheet" href="../fast/js/resources/js-test-style.css">
+<script>var relativePathToLayoutTests = "..";</script>
 <script src="resources/WMLTestCase.js"></script>
 <script src="../fast/js/resources/js-test-pre.js"></script>
 </head>
index 17ae00a..c697686 100644 (file)
@@ -2,6 +2,7 @@
 <html>
 <head>
 <link rel="stylesheet" href="../fast/js/resources/js-test-style.css">
+<script>var relativePathToLayoutTests = "..";</script>
 <script src="resources/WMLTestCase.js"></script>
 <script src="../fast/js/resources/js-test-pre.js"></script>
 </head>
index 75ea68a..a3c26b9 100644 (file)
@@ -2,6 +2,7 @@
 <html>
 <head>
 <link rel="stylesheet" href="../fast/js/resources/js-test-style.css">
+<script>var relativePathToLayoutTests = "..";</script>
 <script src="resources/WMLTestCase.js"></script>
 <script src="../fast/js/resources/js-test-pre.js"></script>
 </head>
index c12c449..8b0391d 100644 (file)
@@ -2,6 +2,7 @@
 <html>
 <head>
 <link rel="stylesheet" href="../fast/js/resources/js-test-style.css">
+<script>var relativePathToLayoutTests = "..";</script>
 <script src="resources/WMLTestCase.js"></script>
 <script src="../fast/js/resources/js-test-pre.js"></script>
 </head>
index 3c79f52..55e1cd0 100644 (file)
@@ -2,6 +2,7 @@
 <html>
 <head>
 <link rel="stylesheet" href="../fast/js/resources/js-test-style.css">
+<script>var relativePathToLayoutTests = "..";</script>
 <script src="resources/WMLTestCase.js"></script>
 <script src="../fast/js/resources/js-test-pre.js"></script>
 </head>
index e6ad6cd..a104527 100644 (file)
@@ -16,7 +16,7 @@ function createWMLTestCase(desc, substituteVariables, testName) {
     var defaultTest = true;
     if (testName == null) {
         defaultTest = false;
-        testName = "resources/test-document.wml";
+        testName = relativePathToLayoutTests + "/wml/resources/test-document.wml";
     }
 
     description(desc);
@@ -93,7 +93,7 @@ function completeTest() {
             window.setTimeout("layoutTestController.notifyDone()", 0);
     };
 
-    script.src = "../fast/js/resources/js-test-post.js";
+    script.src = relativePathToLayoutTests + "/fast/js/resources/js-test-post.js";
     successfullyParsed = true;
 
     bodyElement.appendChild(script);
index c200bcb..adc976e 100644 (file)
@@ -2,6 +2,7 @@
 <html>
 <head>
 <link rel="stylesheet" href="../fast/js/resources/js-test-style.css">
+<script>var relativePathToLayoutTests = "..";</script>
 <script src="resources/WMLTestCase.js"></script>
 <script src="../fast/js/resources/js-test-pre.js"></script>
 </head>
index 11878b6..c46e298 100644 (file)
@@ -2,6 +2,7 @@
 <html>
 <head>
 <link rel="stylesheet" href="../fast/js/resources/js-test-style.css">
+<script>var relativePathToLayoutTests = "..";</script>
 <script src="resources/WMLTestCase.js"></script>
 <script src="../fast/js/resources/js-test-pre.js"></script>
 </head>
index fba1853..2aef7cb 100644 (file)
@@ -1,4 +1,32 @@
-2008-12-20  Nikolas Zimmermann  <nikolas.zimmermann@torchmobile.com>
+2008-12-22  Nikolas Zimmermann  <nikolas.zimmermann@torchmobile.com>
+
+        Reviewed by George Staikos.
+
+        Fixes: https://bugs.webkit.org/show_bug.cgi?id=22638
+
+        Add POST method support to WMLGoElement. GET & POST over HTTP
+        covered by a new set of WML HTTP layout tests.
+
+        Tests: http/tests/wml/go-task-get-method-accept-charset.html
+               http/tests/wml/go-task-get-method.html
+               http/tests/wml/go-task-post-method-accept-charset.html
+               http/tests/wml/go-task-post-method.html
+
+        * wml/WMLGoElement.cpp:
+        (WebCore::WMLGoElement::WMLGoElement):
+        (WebCore::WMLGoElement::registerPostfieldElement):
+        (WebCore::WMLGoElement::parseMappedAttribute):
+        (WebCore::WMLGoElement::executeTask):
+        (WebCore::WMLGoElement::preparePOSTRequest):
+        (WebCore::WMLGoElement::prepareGETRequest):
+        (WebCore::WMLGoElement::createFormData):
+        * wml/WMLGoElement.h:
+        * wml/WMLPostfieldElement.cpp:
+        (WebCore::encodedString):
+        (WebCore::WMLPostfieldElement::encodeData):
+        * wml/WMLPostfieldElement.h:
+
+2008-12-21  Nikolas Zimmermann  <nikolas.zimmermann@torchmobile.com>
 
         Reviewed by Darin Adler and George Staikos.
 
index fb9c71b..4f45638 100644 (file)
 #if ENABLE(WML)
 #include "WMLGoElement.h"
 
+#include "CString.h"
+#include "FormData.h"
 #include "Frame.h"
 #include "FrameLoader.h"
 #include "HTMLNames.h"
 #include "ResourceRequest.h"
+#include "TextEncoding.h"
 #include "WMLCardElement.h"
 #include "WMLDocument.h"
 #include "WMLNames.h"
@@ -42,30 +45,22 @@ using namespace WMLNames;
 
 WMLGoElement::WMLGoElement(const QualifiedName& tagName, Document* doc)
     : WMLTaskElement(tagName, doc)
-    , m_contentType("application/x-www-form-urlencoded")
-    , m_isMultiPart(false)
-    , m_isPostMethod(false)
 {
 }
  
 void WMLGoElement::registerPostfieldElement(WMLPostfieldElement* postfield)
 {
-    m_postfieldElements.add(postfield);
+    m_postfieldElements.append(postfield);
 }
 
 void WMLGoElement::parseMappedAttribute(MappedAttribute* attr)
 {
-    if (attr->name() == HTMLNames::methodAttr) {
-        const AtomicString& value = attr->value();
-
-        if (value == "POST")
-            m_isPostMethod = true;
-        else if (value == "GET")
-            m_isPostMethod = false;
-    } else if (attr->name() == HTMLNames::enctypeAttr)
-        parseContentType(parseValueSubstitutingVariableReferences(attr->value()));
+    if (attr->name() == HTMLNames::methodAttr)
+        m_formDataBuilder.parseMethodType(attr->value());
+    else if (attr->name() == HTMLNames::enctypeAttr)
+        m_formDataBuilder.parseEncodingType(parseValueSubstitutingVariableReferences(attr->value()));
     else if (attr->name() == HTMLNames::accept_charsetAttr)
-        m_acceptCharset = parseValueForbiddingVariableReferences(attr->value());
+        m_formDataBuilder.setAcceptCharset(parseValueForbiddingVariableReferences(attr->value()));
     else
         WMLTaskElement::parseMappedAttribute(attr);
 }
@@ -124,15 +119,10 @@ void WMLGoElement::executeTask(Event* event)
 
     String cacheControl = getAttribute(cache_controlAttr);
 
-    if (m_isPostMethod)
+    if (m_formDataBuilder.isPostMethod())
         preparePOSTRequest(request, inSameDeck, cacheControl);
-    else {
-        // Eventually display error message?
-        if (m_isMultiPart)
-            return;
-
+    else
         prepareGETRequest(request, url);
-    }
 
     // Set HTTP cache-control header if needed
     if (!cacheControl.isEmpty()) {
@@ -145,17 +135,6 @@ void WMLGoElement::executeTask(Event* event)
     loader->load(request);
 }
 
-void WMLGoElement::parseContentType(const String& type)
-{
-    if (type.contains("multipart", false) || type.contains("form-data", false)) {
-        m_contentType = "multipart/form-data";
-        m_isMultiPart = true;
-    } else {
-        m_contentType = "application/x-www-form-urlencoded";
-        m_isMultiPart = false;
-    }
-}
-
 void WMLGoElement::preparePOSTRequest(ResourceRequest& request, bool inSameDeck, const String& cacheControl)
 {
     request.setHTTPMethod("POST");
@@ -165,49 +144,70 @@ void WMLGoElement::preparePOSTRequest(ResourceRequest& request, bool inSameDeck,
         return;
     }
 
-    // FIXME: Implement POST method.
-    /*
     RefPtr<FormData> data;
 
-    if (m_isMultiPart) { // multipart/form-data
-        Vector<char> boundary;
-        getUniqueBoundaryString(boundary);
-        data = createFormData(loader, boundary.data());
-        request.setHTTPContentType(m_contentType + "; boundary=" + boundary.data());
+    if (m_formDataBuilder.isMultiPartForm()) { // multipart/form-data
+        Vector<char> boundary = m_formDataBuilder.generateUniqueBoundaryString();
+        data = createFormData(boundary.data());
+        request.setHTTPContentType(m_formDataBuilder.encodingType() + "; boundary=" + boundary.data());
     } else {
         // text/plain or application/x-www-form-urlencoded
-        data = createFormData(loader, 0);
-        request.setHTTPContentType(m_contentType);
+        data = createFormData(CString());
+        request.setHTTPContentType(m_formDataBuilder.encodingType());
     }
 
     request.setHTTPBody(data.get());
-    */
 }
 
 void WMLGoElement::prepareGETRequest(ResourceRequest& request, const KURL& url)
 {
-    String queryString;
+    request.setHTTPMethod("GET");
 
-    HashSet<WMLPostfieldElement*>::iterator it = m_postfieldElements.begin();
-    HashSet<WMLPostfieldElement*>::iterator end = m_postfieldElements.end();
+    // Eventually display error message?
+    if (m_formDataBuilder.isMultiPartForm())
+        return;
 
-    for (; it != end; ++it) {
-        WMLPostfieldElement* postfield = (*it);
+    RefPtr<FormData> data = createFormData(CString());
 
-        if (!queryString.isEmpty())
-            queryString += "&";
+    KURL remoteURL(url);
+    remoteURL.setQuery(data->flattenToString());
+    request.setURL(remoteURL);
+}
 
-        queryString += encodeWithURLEscapeSequences(postfield->name()) + "m" +
-                       encodeWithURLEscapeSequences(postfield->value());
-    }
+PassRefPtr<FormData> WMLGoElement::createFormData(const CString& boundary)
+{
+    CString key;
+    CString value;
 
-    KURL remoteURL(url);
-    remoteURL.setQuery(queryString);
+    Vector<char> encodedData;
+    TextEncoding encoding = m_formDataBuilder.dataEncoding(document()).encodingForFormSubmission();
 
-    request.setURL(remoteURL);
-    request.setHTTPMethod("GET");
+    Vector<WMLPostfieldElement*>::iterator it = m_postfieldElements.begin();
+    Vector<WMLPostfieldElement*>::iterator end = m_postfieldElements.end();
+
+    RefPtr<FormData> result = FormData::create();
+    for (; it != end; ++it) {
+        (*it)->encodeData(encoding, key, value);
+
+        if (m_formDataBuilder.isMultiPartForm()) {
+            Vector<char> header;
+            m_formDataBuilder.beginMultiPartHeader(header, boundary, key);
+            m_formDataBuilder.finishMultiPartHeader(header);
+            result->appendData(header.data(), header.size());
+
+            if (size_t dataSize = value.length())
+                result->appendData(value.data(), dataSize);
+
+            result->appendData("\r\n", 2);
+        } else
+            m_formDataBuilder.addKeyValuePairAsFormData(encodedData, key, value);
+    }
 
+    if (m_formDataBuilder.isMultiPartForm())
+        m_formDataBuilder.addBoundaryToMultiPartHeader(encodedData, boundary, true);
 
+    result->appendData(encodedData.data(), encodedData.size());
+    return result;
 }
 
 }
index d81b4b0..ef2a3fd 100644 (file)
 #define WMLGoElement_h
 
 #if ENABLE(WML)
+#include "FormDataBuilder.h"
 #include "WMLTaskElement.h"
 
 namespace WebCore {
 
+class FormData;
 class ResourceRequest;
 class WMLPostfieldElement;
 
@@ -40,18 +42,13 @@ public:
     virtual void executeTask(Event*);
 
 private:
-    void parseContentType(const String&);
-
     void preparePOSTRequest(ResourceRequest&, bool inSameDeck, const String& cacheControl);
     void prepareGETRequest(ResourceRequest&, const KURL&);
 
-    HashSet<WMLPostfieldElement*> m_postfieldElements;
-
-    String m_contentType;
-    String m_acceptCharset;
+    PassRefPtr<FormData> createFormData(const CString& boundary);
 
-    bool m_isMultiPart;
-    bool m_isPostMethod;
+    Vector<WMLPostfieldElement*> m_postfieldElements;
+    FormDataBuilder m_formDataBuilder;
 };
 
 }
index ab18534..cf2c0a7 100644 (file)
@@ -24,6 +24,8 @@
 #if ENABLE(WML)
 #include "WMLPostfieldElement.h"
 
+#include "CString.h"
+#include "TextEncoding.h"
 #include "HTMLNames.h"
 #include "WMLDocument.h"
 #include "WMLGoElement.h"
@@ -61,6 +63,17 @@ void WMLPostfieldElement::insertedIntoDocument()
     static_cast<WMLGoElement*>(parent)->registerPostfieldElement(this);
 }
 
+static inline CString encodedString(const TextEncoding& encoding, const String& data)
+{
+    return encoding.encode(data.characters(), data.length(), EntitiesForUnencodables);
+}
+
+void WMLPostfieldElement::encodeData(const TextEncoding& encoding, CString& name, CString& value)
+{
+    name = encodedString(encoding, m_name);
+    value = encodedString(encoding, m_value);
+}
+
 }
 
 #endif
index 30449ec..6c9c38c 100644 (file)
@@ -25,8 +25,6 @@
 #if ENABLE(WML)
 #include "WMLElement.h"
 
-#include <wtf/HashSet.h>
-
 namespace WebCore {
 
 class WMLPostfieldElement : public WMLElement {
@@ -39,6 +37,9 @@ public:
     String name() const { return m_name; }
     String value() const { return m_value; }
 
+    // Encode name() and value() in a CString using the passed encoding
+    void encodeData(const TextEncoding&, CString& name, CString& value);
+
 private:
     String m_name;
     String m_value;
index c4b8ea6..75c0e11 100644 (file)
@@ -1,3 +1,12 @@
+2008-12-22  Nikolas Zimmermann  <nikolas.zimmermann@torchmobile.com>
+
+        Reviewed by George Staikos.
+
+        Ignore http/tests/wml, if no WML support is present.
+        Add http/tests/wml to list of HTTP tests, allowed to access local resources.
+
+        * Scripts/run-webkit-tests:
+
 2008-12-19  David Levin  <levin@chromium.org>
 
         Reviewed by Mark Rowe.
index 8facd15..b45caf8 100755 (executable)
@@ -346,6 +346,7 @@ if (checkWebCoreSVGSupport(0)) {
 if (checkWebCoreWMLSupport(0)) { 
     $supportedFileExtensions{'wml'} = 1;
 } else {
+    $ignoredDirectories{'http/tests/wml'} = 1;
     $ignoredDirectories{'fast/wml'} = 1;
     $ignoredDirectories{'wml'} = 1;
 }
@@ -571,7 +572,7 @@ for my $test (@tests) {
         print OUT "$testPath$suffixExpectedHash\n";
     } else {
         openHTTPDIfNeeded();
-        if ($test !~ /^http\/tests\/local\// && $test !~ /^http\/tests\/ssl\// && $test !~ /^http\/tests\/media\//) {
+        if ($test !~ /^http\/tests\/local\// && $test !~ /^http\/tests\/ssl\// && $test !~ /^http\/tests\/wml\// && $test !~ /^http\/tests\/media\//) {
             my $path = canonpath($test);
             $path =~ s/^http\/tests\///;
             print OUT "http://127.0.0.1:$httpdPort/$path$suffixExpectedHash\n";