Revalidation header blacklisting should be case-insensitive.
authorap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Sep 2013 20:04:19 +0000 (20:04 +0000)
committerap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Sep 2013 20:04:19 +0000 (20:04 +0000)
        https://bugs.webkit.org/show_bug.cgi?id=120832

        Reviewed by Alexey Proskuryakov.

        Adds a new test to verify that a CSS file served initially as type
        'text/css' maintains that type even if a revalidation response sends
        'text/plain' along with a 304 response.

        * http/tests/cache/content-type-ignored-during-revalidation-expected.txt: Added.
        * http/tests/cache/content-type-ignored-during-revalidation.html: Added.
        * http/tests/cache/resources/stylesheet304-bad-content-type.php: Added.

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

LayoutTests/ChangeLog
LayoutTests/http/tests/cache/content-type-ignored-during-revalidation-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/cache/content-type-ignored-during-revalidation.html [new file with mode: 0644]
LayoutTests/http/tests/cache/resources/stylesheet304-bad-content-type.php [new file with mode: 0644]

index 758b5f0..9f761f0 100644 (file)
@@ -1,3 +1,18 @@
+2013-09-06  Mike West  <mkwst@chromium.org>
+
+        Revalidation header blacklisting should be case-insensitive.
+        https://bugs.webkit.org/show_bug.cgi?id=120832
+
+        Reviewed by Alexey Proskuryakov.
+
+        Adds a new test to verify that a CSS file served initially as type
+        'text/css' maintains that type even if a revalidation response sends
+        'text/plain' along with a 304 response.
+
+        * http/tests/cache/content-type-ignored-during-revalidation-expected.txt: Added.
+        * http/tests/cache/content-type-ignored-during-revalidation.html: Added.
+        * http/tests/cache/resources/stylesheet304-bad-content-type.php: Added.
+
 2013-09-06  Filip Pizlo  <fpizlo@apple.com>
 
         fast/js/dfg-* tests should wait for the concurrent JIT
diff --git a/LayoutTests/http/tests/cache/content-type-ignored-during-revalidation-expected.txt b/LayoutTests/http/tests/cache/content-type-ignored-during-revalidation-expected.txt
new file mode 100644 (file)
index 0000000..f47a974
--- /dev/null
@@ -0,0 +1,10 @@
+Certain headers (such as 'content-type') ought to be ignored when resources like stylesheets are revalidated via a 304 response.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS window.getComputedStyle(document.getElementById('test')).backgroundColor is "rgb(0, 255, 0)"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+This div should have a green background.
diff --git a/LayoutTests/http/tests/cache/content-type-ignored-during-revalidation.html b/LayoutTests/http/tests/cache/content-type-ignored-during-revalidation.html
new file mode 100644 (file)
index 0000000..41a0ee7
--- /dev/null
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <link rel="stylesheet" href="resources/stylesheet304-bad-content-type.php">
+</head>
+<body>
+    <div id="test">This div should have a green background.</div>
+
+    <script src="/js-test-resources/js-test-pre.js"></script>
+    <script>
+        window.jsTestIsAsync = true;
+
+        description("Certain headers (such as 'content-type') ought to be ignored when resources like stylesheets are revalidated via a 304 response.");
+
+        window.onload = function () {
+            if (window.sessionStorage.reloaded) {
+                window.sessionStorage.removeItem("reloaded");
+                shouldBeEqualToString("window.getComputedStyle(document.getElementById('test')).backgroundColor", "rgb(0, 255, 0)"); 
+                finishJSTest();
+            } else {
+                window.sessionStorage.reloaded = 1;
+                window.location.reload();
+            }
+        };
+    </script>
+    <script src="/js-test-resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/cache/resources/stylesheet304-bad-content-type.php b/LayoutTests/http/tests/cache/resources/stylesheet304-bad-content-type.php
new file mode 100644 (file)
index 0000000..2adf6c8
--- /dev/null
@@ -0,0 +1,21 @@
+<?php
+require_once '../../resources/portabilityLayer.php';
+
+clearstatcache();
+
+if ($_SERVER["HTTP_IF_MODIFIED_SINCE"]) {
+    header("HTTP/1.0 304 Not Modified");
+    header("Content-Type: text/plain");
+    exit();
+}
+$one_year = 12 * 31 * 24 * 60 * 60;
+$last_modified = gmdate(DATE_RFC1123, time() - $one_year);
+$expires = gmdate(DATE_RFC1123, time() + $one_year);
+
+header('Cache-Control: public, max-age=' . $one_year);
+header('Expires: ' . $expires);
+header('Content-Type: text/css');
+header('Etag: 123456789');
+header('Last-Modified: ' . $last_modified);
+?>
+#test { background-color: rgb(0, 255, 0); }