Add a layout test verifying AppCache resource fetches have the document's cookie...
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Mar 2018 02:27:57 +0000 (02:27 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Mar 2018 02:27:57 +0000 (02:27 +0000)
https://bugs.webkit.org/show_bug.cgi?id=183757

Reviewed by Alex Christensen.

* http/tests/appcache/document-cookie-expected.txt: Added.
* http/tests/appcache/document-cookie.php: Added.
* http/tests/appcache/resources/cookie-protected-script.php: Added.
* http/tests/appcache/resources/document-cookie.manifest: Added.

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

LayoutTests/ChangeLog
LayoutTests/http/tests/appcache/document-cookie-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/appcache/document-cookie.php [new file with mode: 0644]
LayoutTests/http/tests/appcache/resources/cookie-protected-script.php [new file with mode: 0644]
LayoutTests/http/tests/appcache/resources/document-cookie.manifest [new file with mode: 0644]

index e9b7fda..df6d2ff 100644 (file)
@@ -1,3 +1,15 @@
+2018-03-19  Brady Eidson  <beidson@apple.com>
+
+        Add a layout test verifying AppCache resource fetches have the document's cookie in place.
+        https://bugs.webkit.org/show_bug.cgi?id=183757
+
+        Reviewed by Alex Christensen.
+
+        * http/tests/appcache/document-cookie-expected.txt: Added.
+        * http/tests/appcache/document-cookie.php: Added.
+        * http/tests/appcache/resources/cookie-protected-script.php: Added.
+        * http/tests/appcache/resources/document-cookie.manifest: Added.
+
 2018-03-19  Chris Dumez  <cdumez@apple.com>
 
         Make policy decisions asynchronous
diff --git a/LayoutTests/http/tests/appcache/document-cookie-expected.txt b/LayoutTests/http/tests/appcache/document-cookie-expected.txt
new file mode 100644 (file)
index 0000000..02235e6
--- /dev/null
@@ -0,0 +1,3 @@
+CONSOLE MESSAGE: line 1: ApplicationCache is deprecated. Please use ServiceWorkers instead.
+This tests that cookies set on the main document are used when accessing resources in the manifest.
+PASSED: Cookie is set to 'bar'
diff --git a/LayoutTests/http/tests/appcache/document-cookie.php b/LayoutTests/http/tests/appcache/document-cookie.php
new file mode 100644 (file)
index 0000000..17e15e3
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+setcookie("foo", "bar", 0, "/");
+?>
+<html manifest="resources/document-cookie.manifest">
+
+<div>This tests that cookies set on the main document are used when accessing resources in the manifest.</div>
+<div id="result">Not run yet</div>
+<script>
+if (window.testRunner) {
+    testRunner.dumpAsText()
+    testRunner.waitUntilDone();
+}
+
+function dynamicScriptLoad() {
+       var script = document.createElement("script");
+       script.type = "text/javascript";
+       script.src = "./resources/cookie-protected-script.php"; 
+       document.getElementsByTagName("head")[0].appendChild(script);
+}
+
+function cached()
+{
+       setTimeout("dynamicScriptLoad();", 0);
+}
+
+applicationCache.addEventListener('cached', cached, false);
+</script>
+</html>
diff --git a/LayoutTests/http/tests/appcache/resources/cookie-protected-script.php b/LayoutTests/http/tests/appcache/resources/cookie-protected-script.php
new file mode 100644 (file)
index 0000000..3763124
--- /dev/null
@@ -0,0 +1,18 @@
+<?php
+header("Content-type:application/javascript");
+
+if (isset($_COOKIE["foo"])) {
+    echo "var cookieVal = '" . $_COOKIE["foo"] . "';";
+} else {
+    echo "var cookieVal = '<null>';";
+}
+
+?>
+
+if (cookieVal == "bar")
+       document.getElementById("result").innerHTML = "PASSED: Cookie is set to 'bar'";
+else
+       document.getElementById("result").innerHTML = "FAILED: Cookie should be 'bar', is set to '" + cookieVal + "'";
+
+if (window.testRunner)
+       testRunner.notifyDone();
diff --git a/LayoutTests/http/tests/appcache/resources/document-cookie.manifest b/LayoutTests/http/tests/appcache/resources/document-cookie.manifest
new file mode 100644 (file)
index 0000000..013566c
--- /dev/null
@@ -0,0 +1,4 @@
+CACHE MANIFEST
+/appcache/resources/cookie-protected-script.php
+NETWORK:
+/favicon.ico