Bug 24569: Add some cookies tests
authorddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 May 2009 04:52:42 +0000 (04:52 +0000)
committerddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 May 2009 04:52:42 +0000 (04:52 +0000)
        <https://bugs.webkit.org/show_bug.cgi?id=24569>

LayoutTests:

        Reviewed and tweaked by David Kilzer.

        This modification adds a cookie framework to check setting cookies.
        It is a simple modification over the js test framework. It uses some XHRs and custom server-side script
        to set / get / clear cookies.

        It also adds some very basic tests to check that everything works.

        * http/tests/cookies: Added.
        * http/tests/cookies/multiple-cookies-expected.txt: Added.
        * http/tests/cookies/multiple-cookies.html: Added.
        * http/tests/cookies/resources: Added.
        * http/tests/cookies/resources/TEMPLATE.html: Copied from LayoutTests/fast/js/resources/TEMPLATE.html.
        * http/tests/cookies/resources/clearCookies.cgi: Added.
        * http/tests/cookies/resources/cookies-test-post.js: Copied from LayoutTests/fast/js/resources/js-test-post.js.
        * http/tests/cookies/resources/cookies-test-pre.js: Copied from LayoutTests/fast/js/resources/js-test-pre.js.
        (setCookies): Internal method to set a cookie (multiple cookies are not supported).
        (testCookies): Internal method to check if the cookie were set.

        (clearAllCookies): Used to clear all pre-existing cookies for this domain.
        (clearCookies): Used to clear the cookies set with cookiesShouldBe.
        (cookiesShouldBe): Used to set a cookie and check the "Cookie" header sent. It is inspired from shouldBe from the js test framework.

        * http/tests/cookies/resources/cookies-test-style.css: Copied from LayoutTests/fast/js/resources/js-test-style.css.
        * http/tests/cookies/resources/getCookies.cgi: Added.
        * http/tests/cookies/resources/multiple-cookies.js: Added.
        * http/tests/cookies/resources/setCookies.cgi: Added.
        * http/tests/cookies/resources/simple-cookies-expired.js: Added.
        * http/tests/cookies/resources/simple-cookies-max-age.js: Added.
        * http/tests/cookies/simple-cookies-expired-expected.txt: Added.
        * http/tests/cookies/simple-cookies-expired.html: Added.
        * http/tests/cookies/simple-cookies-max-age-expected.txt: Added.
        * http/tests/cookies/simple-cookies-max-age.html: Added.
        * platform/mac-tiger/Skipped: Added
        http/tests/cookies/simple-cookies-max-age.html since CFNetwork
        on Tiger doesn't support expiring cookies with Max-Age=0.

WebKitTools:

        Patch by David Kilzer.

        * Scripts/make-js-test-wrappers: Added regex to skip
        cookies-test-(post|pre).js files.

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

20 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/cookies/multiple-cookies-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/cookies/multiple-cookies.html [new file with mode: 0644]
LayoutTests/http/tests/cookies/resources/TEMPLATE.html [new file with mode: 0644]
LayoutTests/http/tests/cookies/resources/clearCookies.cgi [new file with mode: 0755]
LayoutTests/http/tests/cookies/resources/cookies-test-post.js [new file with mode: 0644]
LayoutTests/http/tests/cookies/resources/cookies-test-pre.js [new file with mode: 0644]
LayoutTests/http/tests/cookies/resources/cookies-test-style.css [new file with mode: 0644]
LayoutTests/http/tests/cookies/resources/getCookies.cgi [new file with mode: 0755]
LayoutTests/http/tests/cookies/resources/multiple-cookies.js [new file with mode: 0644]
LayoutTests/http/tests/cookies/resources/setCookies.cgi [new file with mode: 0755]
LayoutTests/http/tests/cookies/resources/simple-cookies-expired.js [new file with mode: 0644]
LayoutTests/http/tests/cookies/resources/simple-cookies-max-age.js [new file with mode: 0644]
LayoutTests/http/tests/cookies/simple-cookies-expired-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/cookies/simple-cookies-expired.html [new file with mode: 0644]
LayoutTests/http/tests/cookies/simple-cookies-max-age-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/cookies/simple-cookies-max-age.html [new file with mode: 0644]
LayoutTests/platform/mac-tiger/Skipped
WebKitTools/ChangeLog
WebKitTools/Scripts/make-js-test-wrappers

index eef5e59..8587980 100644 (file)
@@ -1,3 +1,45 @@
+2009-05-18  Julien Chaffraix  <jchaffraix@webkit.org>
+
+        Reviewed and tweaked by David Kilzer.
+
+        Bug 24569: Add some cookies tests
+        <https://bugs.webkit.org/show_bug.cgi?id=24569>
+
+        This modification adds a cookie framework to check setting cookies.
+        It is a simple modification over the js test framework. It uses some XHRs and custom server-side script
+        to set / get / clear cookies.
+
+        It also adds some very basic tests to check that everything works.
+
+        * http/tests/cookies: Added.
+        * http/tests/cookies/multiple-cookies-expected.txt: Added.
+        * http/tests/cookies/multiple-cookies.html: Added.
+        * http/tests/cookies/resources: Added.
+        * http/tests/cookies/resources/TEMPLATE.html: Copied from LayoutTests/fast/js/resources/TEMPLATE.html.
+        * http/tests/cookies/resources/clearCookies.cgi: Added.
+        * http/tests/cookies/resources/cookies-test-post.js: Copied from LayoutTests/fast/js/resources/js-test-post.js.
+        * http/tests/cookies/resources/cookies-test-pre.js: Copied from LayoutTests/fast/js/resources/js-test-pre.js.
+        (setCookies): Internal method to set a cookie (multiple cookies are not supported).
+        (testCookies): Internal method to check if the cookie were set.
+
+        (clearAllCookies): Used to clear all pre-existing cookies for this domain.
+        (clearCookies): Used to clear the cookies set with cookiesShouldBe.
+        (cookiesShouldBe): Used to set a cookie and check the "Cookie" header sent. It is inspired from shouldBe from the js test framework.
+
+        * http/tests/cookies/resources/cookies-test-style.css: Copied from LayoutTests/fast/js/resources/js-test-style.css.
+        * http/tests/cookies/resources/getCookies.cgi: Added.
+        * http/tests/cookies/resources/multiple-cookies.js: Added.
+        * http/tests/cookies/resources/setCookies.cgi: Added.
+        * http/tests/cookies/resources/simple-cookies-expired.js: Added.
+        * http/tests/cookies/resources/simple-cookies-max-age.js: Added.
+        * http/tests/cookies/simple-cookies-expired-expected.txt: Added.
+        * http/tests/cookies/simple-cookies-expired.html: Added.
+        * http/tests/cookies/simple-cookies-max-age-expected.txt: Added.
+        * http/tests/cookies/simple-cookies-max-age.html: Added.
+        * platform/mac-tiger/Skipped: Added
+        http/tests/cookies/simple-cookies-max-age.html since CFNetwork
+        on Tiger doesn't support expiring cookies with Max-Age=0.
+
 2009-05-18  David Kilzer  <ddkilzer@apple.com>
 
         Bug 20652: WebKit doesn't display favicons with MIME type image/vnd.microsoft.icon
diff --git a/LayoutTests/http/tests/cookies/multiple-cookies-expected.txt b/LayoutTests/http/tests/cookies/multiple-cookies-expected.txt
new file mode 100644 (file)
index 0000000..ba67725
--- /dev/null
@@ -0,0 +1,13 @@
+This test checks that mulitple cookies are correctly set.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Check setting several cookies without clearing.
+PASS cookie is 'test=foobar'.
+PASS cookie is 'test=foobar; test2=foobar'.
+PASS cookie is 'test=foobar; test2=foobar; test3=foobar'.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/http/tests/cookies/multiple-cookies.html b/LayoutTests/http/tests/cookies/multiple-cookies.html
new file mode 100644 (file)
index 0000000..05c5f1e
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="resources/cookies-test-style.css">
+<script src="resources/cookies-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="resources/multiple-cookies.js"></script>
+<script src="resources/cookies-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/cookies/resources/TEMPLATE.html b/LayoutTests/http/tests/cookies/resources/TEMPLATE.html
new file mode 100644 (file)
index 0000000..6483f50
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="resources/cookies-test-style.css">
+<script src="resources/cookies-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="YOUR_JS_FILE_HERE"></script>
+<script src="resources/cookies-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/cookies/resources/clearCookies.cgi b/LayoutTests/http/tests/cookies/resources/clearCookies.cgi
new file mode 100755 (executable)
index 0000000..27896b7
--- /dev/null
@@ -0,0 +1,27 @@
+#!/usr/bin/perl -wT
+use strict;
+
+print "Content-Type: text/plain\n";
+print "Cache-Control: no-store\n";
+print 'Cache-Control: no-cache="set-cookie"' . "\n";
+
+my $cookie = $ENV{"HTTP_CLEAR_COOKIE"};
+
+if ($cookie =~ /Max-Age/i) {
+    $cookie =~ s/Max-Age *= *[0-9]+/Max-Age=0/i;
+} else {
+    $cookie .= ";" unless ($cookie =~ m/;$/);
+    $cookie .= " " unless ($cookie =~ m/ $/);
+    $cookie .= "Max-Age=0";
+}
+
+if ($cookie =~ /Expires/i) {
+    # Set the "Expires" field to UNIX epoch
+    $cookie =~ s/Expires *= *[^;]+/Expires=Thu, 01 Jan 1970 00:00:00 GMT/i;
+} else {
+    $cookie .= ";" unless ($cookie =~ m/;$/);
+    $cookie .= " " unless ($cookie =~ m/ $/);
+    $cookie .= "Expires=Thu, 01 Jan 1970 00:00:00 GMT";
+}
+
+print "Set-Cookie: $cookie\n\n";
diff --git a/LayoutTests/http/tests/cookies/resources/cookies-test-post.js b/LayoutTests/http/tests/cookies/resources/cookies-test-post.js
new file mode 100644 (file)
index 0000000..6970120
--- /dev/null
@@ -0,0 +1,5 @@
+shouldBeTrue("successfullyParsed");
+debug('<br /><span class="pass">TEST COMPLETE</span>');
+
+// Make sure that we do not leak any cookies.
+clearCookies();
diff --git a/LayoutTests/http/tests/cookies/resources/cookies-test-pre.js b/LayoutTests/http/tests/cookies/resources/cookies-test-pre.js
new file mode 100644 (file)
index 0000000..da8e3a5
--- /dev/null
@@ -0,0 +1,227 @@
+if (window.layoutTestController)
+    layoutTestController.dumpAsText();
+
+function description(msg)
+{
+    // For MSIE 6 compatibility
+    var span = document.createElement("span");
+    span.innerHTML = '<p>' + msg + '</p><p>On success, you will see a series of "<span class="pass">PASS</span>" messages, followed by "<span class="pass">TEST COMPLETE</span>".</p>';
+    var description = document.getElementById("description");
+    if (description.firstChild)
+        description.replaceChild(span, description.firstChild);
+    else
+        description.appendChild(span);
+}
+
+function debug(msg)
+{
+    var span = document.createElement("span");
+    document.getElementById("console").appendChild(span); // insert it first so XHTML knows the namespace
+    span.innerHTML = msg + '<br />';
+}
+
+function escapeHTML(text)
+{
+    return text.replace(/&/g, "&amp;").replace(/</g, "&lt;");
+}
+
+function testPassed(msg)
+{
+    debug('<span><span class="pass">PASS</span> ' + escapeHTML(msg) + '</span>');
+}
+
+function testFailed(msg)
+{
+    debug('<span><span class="fail">FAIL</span> ' + escapeHTML(msg) + '</span>');
+}
+
+function areArraysEqual(_a, _b)
+{
+    if (_a.length !== _b.length)
+        return false;
+    for (var i = 0; i < _a.length; i++)
+        if (_a[i] !== _b[i])
+            return false;
+    return true;
+}
+
+function isMinusZero(n)
+{
+    // the only way to tell 0 from -0 in JS is the fact that 1/-0 is
+    // -Infinity instead of Infinity
+    return n === 0 && 1/n < 0;
+}
+
+function isResultCorrect(_actual, _expected)
+{
+    if (_expected === 0)
+        return _actual === _expected && (1/_actual) === (1/_expected);
+    if (_actual === _expected)
+        return true;
+    if (typeof(_expected) == "number" && isNaN(_expected))
+        return typeof(_actual) == "number" && isNaN(_actual);
+    if (Object.prototype.toString.call(_expected) == Object.prototype.toString.call([]))
+        return areArraysEqual(_actual, _expected);
+    return false;
+}
+
+function stringify(v)
+{
+    if (v === 0 && 1/v < 0)
+        return "-0";
+    else return "" + v;
+}
+
+function shouldBe(_a, _b)
+{
+    if (typeof _a != "string" || typeof _b != "string")
+        debug("WARN: shouldBe() expects string arguments");
+    var exception;
+    var _av;
+    try {
+        _av = eval(_a);
+    } catch (e) {
+        exception = e;
+    }
+    var _bv = eval(_b);
+
+    if (exception)
+        testFailed(_a + " should be " + _bv + ". Threw exception " + exception);
+    else if (isResultCorrect(_av, _bv))
+        testPassed(_a + " is " + _b);
+    else if (typeof(_av) == typeof(_bv))
+        testFailed(_a + " should be " + _bv + ". Was " + stringify(_av) + ".");
+    else
+        testFailed(_a + " should be " + _bv + " (of type " + typeof _bv + "). Was " + _av + " (of type " + typeof _av + ").");
+}
+
+function shouldBeTrue(_a) { shouldBe(_a, "true"); }
+function shouldBeFalse(_a) { shouldBe(_a, "false"); }
+function shouldBeNaN(_a) { shouldBe(_a, "NaN"); }
+function shouldBeNull(_a) { shouldBe(_a, "null"); }
+
+function shouldBeEqualToString(a, b)
+{
+    var unevaledString = '"' + b.replace(/"/g, "\"") + '"';
+    shouldBe(a, unevaledString);
+}
+
+function shouldBeUndefined(_a)
+{
+    var exception;
+    var _av;
+    try {
+        _av = eval(_a);
+    } catch (e) {
+        exception = e;
+    }
+
+    if (exception)
+        testFailed(_a + " should be undefined. Threw exception " + exception);
+    else if (typeof _av == "undefined")
+        testPassed(_a + " is undefined.");
+    else
+        testFailed(_a + " should be undefined. Was " + _av);
+}
+
+function shouldThrow(_a, _e)
+{
+    var exception;
+    var _av;
+    try {
+        _av = eval(_a);
+    } catch (e) {
+        exception = e;
+    }
+
+    var _ev;
+    if (_e)
+        _ev =  eval(_e);
+
+    if (exception) {
+        if (typeof _e == "undefined" || exception == _ev)
+            testPassed(_a + " threw exception " + exception + ".");
+        else
+            testFailed(_a + " should throw " + (typeof _e == "undefined" ? "an exception" : _ev) + ". Threw exception " + exception + ".");
+    } else if (typeof _av == "undefined")
+        testFailed(_a + " should throw " + (typeof _e == "undefined" ? "an exception" : _ev) + ". Was undefined.");
+    else
+        testFailed(_a + " should throw " + (typeof _e == "undefined" ? "an exception" : _ev) + ". Was " + _av + ".");
+}
+
+var cookies = new Array();
+
+// This method sets the cookies using XMLHttpRequest.
+// We do not set the cookie right away as it is forbidden by the XHR spec.
+// FIXME: Add the possibility to set multiple cookies in a row.
+function setCookies(cookie)
+{
+    try {
+        var xhr = new XMLHttpRequest();
+        xhr.open("GET", "resources/setCookies.cgi", false);
+        xhr.setRequestHeader("SET_COOKIE", cookie);
+        xhr.send(null);
+        if (xhr.status == 200) {
+            // This is to clear them later.
+            cookies.push(cookie);
+            return true;
+        } else
+            return false;
+    } catch (e) {
+        return false;
+    }
+}
+
+// We get the cookies throught an XMLHttpRequest.
+function testCookies(result)
+{
+    var xhr = new XMLHttpRequest();
+    xhr.open("GET", "resources/getCookies.cgi", false);
+    xhr.send(null);
+    var cookie = xhr.getResponseHeader("HTTP_COOKIE") == null ? '"null"' : xhr.getResponseHeader("HTTP_COOKIE");
+    if (cookie === result)
+        testPassed("cookie is '" + cookie + "'.");
+    else
+        testFailed("cookie was '" + cookie + "'. Expected '" + result + "'.");
+}
+
+function clearAllCookies()
+{
+    var cookieString;
+    while (cookieString = document.cookie) {
+        var cookieName = cookieString.substr(0, cookieString.indexOf("=") || cookieString.length());
+        cookies.push(cookieName);
+        clearCookies();
+    }
+}
+
+function clearCookies()
+{
+    if (!cookies.length)
+        return;
+
+    try {
+        var xhr = new XMLHttpRequest();
+        var cookie;
+        // We need to clean one cookie at a time because to be cleared the
+        // cookie must be exactly the same except for the "Max-Age"
+        // and "Expires" fields.
+        while (cookie = cookies.pop()) {
+            xhr.open("GET", "resources/clearCookies.cgi", false);
+            xhr.setRequestHeader("CLEAR_COOKIE", cookie);
+            xhr.send(null);
+        }
+    } catch (e) {
+        debug("Could not clear the cookies expect the following results to fail");
+    }
+}
+
+// This method check one cookie at a time.
+function cookiesShouldBe(cookiesToSet, result)
+{
+    if (!setCookies(cookiesToSet)) {
+        testFailed("could not set cookie(s) " + cookiesToSet);
+        return;
+    }
+    testCookies(result);
+}
diff --git a/LayoutTests/http/tests/cookies/resources/cookies-test-style.css b/LayoutTests/http/tests/cookies/resources/cookies-test-style.css
new file mode 100644 (file)
index 0000000..f12147c
--- /dev/null
@@ -0,0 +1,12 @@
+.pass {
+    font-weight: bold;
+    color: green;
+}
+.fail {
+    font-weight: bold;
+    color: red;
+}
+#console {
+    white-space: pre-wrap;
+    font-family: monospace;
+}
diff --git a/LayoutTests/http/tests/cookies/resources/getCookies.cgi b/LayoutTests/http/tests/cookies/resources/getCookies.cgi
new file mode 100755 (executable)
index 0000000..c4377c3
--- /dev/null
@@ -0,0 +1,8 @@
+#!/usr/bin/perl -wT
+use strict;
+
+print "Content-Type: text/plain\n";
+print "Cache-Control: no-store\n";
+print 'Cache-Control: no-cache="set-cookie"' . "\n";
+
+print "HTTP_COOKIE: " . ($ENV{HTTP_COOKIE} || "") . "\n\n";
diff --git a/LayoutTests/http/tests/cookies/resources/multiple-cookies.js b/LayoutTests/http/tests/cookies/resources/multiple-cookies.js
new file mode 100644 (file)
index 0000000..618e224
--- /dev/null
@@ -0,0 +1,13 @@
+description(
+"This test checks that mulitple cookies are correctly set."
+);
+
+clearAllCookies();
+
+debug("Check setting several cookies without clearing.");
+cookiesShouldBe("test=foobar;", "test=foobar");
+cookiesShouldBe("test2=foobar;", "test=foobar; test2=foobar");
+cookiesShouldBe("test3=foobar;", "test=foobar; test2=foobar; test3=foobar");
+clearCookies();
+
+successfullyParsed = true;
diff --git a/LayoutTests/http/tests/cookies/resources/setCookies.cgi b/LayoutTests/http/tests/cookies/resources/setCookies.cgi
new file mode 100755 (executable)
index 0000000..b9c4b21
--- /dev/null
@@ -0,0 +1,9 @@
+#!/usr/bin/perl -wT
+use strict;
+
+print "Content-Type: text/plain\n";
+print "Cache-Control: no-store\n";
+print 'Cache-Control: no-cache="set-cookie"' . "\n";
+
+# We only map the SET_COOKIE request header to "Set-Cookie"
+print "Set-Cookie: " . $ENV{"HTTP_SET_COOKIE"} . "\n\n";
diff --git a/LayoutTests/http/tests/cookies/resources/simple-cookies-expired.js b/LayoutTests/http/tests/cookies/resources/simple-cookies-expired.js
new file mode 100644 (file)
index 0000000..61b70fb
--- /dev/null
@@ -0,0 +1,18 @@
+description(
+"This test checks that cookies are correctly set using Expires."
+);
+
+clearAllCookies();
+
+debug("Check that setting a simple cookie works.");
+var date = new Date();
+date.setTime(date.getTime() + 60 * 1000);
+cookiesShouldBe("test=foobar; Expires=" + date.toGMTString(), "test=foobar");
+clearCookies();
+
+debug("Check setting a cookie that timed out.");
+date.setTime(date.getTime() - 2 * 60 * 1000);
+cookiesShouldBe("test2=foobar; Expires=" + date.toGMTString(), "");
+clearCookies();
+
+successfullyParsed = true;
diff --git a/LayoutTests/http/tests/cookies/resources/simple-cookies-max-age.js b/LayoutTests/http/tests/cookies/resources/simple-cookies-max-age.js
new file mode 100644 (file)
index 0000000..1d87b13
--- /dev/null
@@ -0,0 +1,15 @@
+description(
+"This test checks that cookies are correctly set using Max-Age."
+);
+
+clearAllCookies();
+
+debug("Check that setting a simple cookie works.");
+cookiesShouldBe("test=foobar; Max-Age=90000000", "test=foobar");
+clearCookies();
+
+debug("Check setting a cookie that timed out.");
+cookiesShouldBe("test2=foobar; Max-Age=0", "");
+clearCookies();
+
+successfullyParsed = true;
diff --git a/LayoutTests/http/tests/cookies/simple-cookies-expired-expected.txt b/LayoutTests/http/tests/cookies/simple-cookies-expired-expected.txt
new file mode 100644 (file)
index 0000000..d0a5c55
--- /dev/null
@@ -0,0 +1,13 @@
+This test checks that cookies are correctly set using Expires.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Check that setting a simple cookie works.
+PASS cookie is 'test=foobar'.
+Check setting a cookie that timed out.
+PASS cookie is ''.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/http/tests/cookies/simple-cookies-expired.html b/LayoutTests/http/tests/cookies/simple-cookies-expired.html
new file mode 100644 (file)
index 0000000..bf22211
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="resources/cookies-test-style.css">
+<script src="resources/cookies-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="resources/simple-cookies-expired.js"></script>
+<script src="resources/cookies-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/cookies/simple-cookies-max-age-expected.txt b/LayoutTests/http/tests/cookies/simple-cookies-max-age-expected.txt
new file mode 100644 (file)
index 0000000..859c392
--- /dev/null
@@ -0,0 +1,13 @@
+This test checks that cookies are correctly set using Max-Age.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Check that setting a simple cookie works.
+PASS cookie is 'test=foobar'.
+Check setting a cookie that timed out.
+PASS cookie is ''.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/http/tests/cookies/simple-cookies-max-age.html b/LayoutTests/http/tests/cookies/simple-cookies-max-age.html
new file mode 100644 (file)
index 0000000..708c658
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="resources/cookies-test-style.css">
+<script src="resources/cookies-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="resources/simple-cookies-max-age.js"></script>
+<script src="resources/cookies-test-post.js"></script>
+</body>
+</html>
index 6c3b2fc..31ec2a7 100644 (file)
@@ -43,3 +43,7 @@ media/video-size-intrinsic-scale.html
 
 # New results needed after r43759, see <https://bugs.webkit.org/show_bug.cgi?id=25816>
 fast/text/international/thai-baht-space.html
+
+# <rdar://problem/5524766> Set-Cookie header field (RFC 2109) not supported correctly (15128)
+# Tiger would need a new CFNetwork to support expiration of cookies using "Max-Age=0"
+http/tests/cookies/simple-cookies-max-age.html
index 0c028cb..d23d7e9 100644 (file)
@@ -1,3 +1,14 @@
+2009-05-18  Julien Chaffraix  <jchaffraix@webkit.org>
+
+        Bug 24569: Add some cookies tests
+
+        <https://bugs.webkit.org/show_bug.cgi?id=24569>
+
+        Patch by David Kilzer.
+
+        * Scripts/make-js-test-wrappers: Added regex to skip
+        cookies-test-(post|pre).js files.
+
 2009-05-18  Kevin Ollivier  <kevino@theolliviers.com>
 
         wx build fix. Use python-config to get Python linking info on Unix OSes. 
index 7d6b640..b040487 100755 (executable)
@@ -88,6 +88,7 @@ for my $tfile (@templates) {
 
     for my $file (@files) {
         next if $file =~ /js-test-.*\.js$/;
+        next if $file =~ /cookies-test-(post|pre)\.js$/;
         next if $file =~ /standalone-.*\.js$/;
         next if $file =~ /SVGTestCase\.js/;
         next if $file =~ /WMLTestCase\.js/;