Add a test for HttpOnly cookies used to load AppCache resources
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 4 Apr 2018 17:41:29 +0000 (17:41 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 4 Apr 2018 17:41:29 +0000 (17:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=184305
<rdar://problem/39175648>

Reviewed by Brady Eidson.

* http/tests/appcache/document-cookie-http-only-expected.txt: Added.
* http/tests/appcache/document-cookie-http-only.php: Added.

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

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

index bf8fe04..d2b0c1c 100644 (file)
@@ -1,3 +1,14 @@
+2018-04-04  Youenn Fablet  <youenn@apple.com>
+
+        Add a test for HttpOnly cookies used to load AppCache resources
+        https://bugs.webkit.org/show_bug.cgi?id=184305
+        <rdar://problem/39175648>
+
+        Reviewed by Brady Eidson.
+
+        * http/tests/appcache/document-cookie-http-only-expected.txt: Added.
+        * http/tests/appcache/document-cookie-http-only.php: Added.
+
 2018-04-04  Ms2ger  <Ms2ger@igalia.com>
 
         Test gardening for GTK.
diff --git a/LayoutTests/http/tests/appcache/document-cookie-http-only-expected.txt b/LayoutTests/http/tests/appcache/document-cookie-http-only-expected.txt
new file mode 100644 (file)
index 0000000..5346ae8
--- /dev/null
@@ -0,0 +1,4 @@
+CONSOLE MESSAGE: line 1: ApplicationCache is deprecated. Please use ServiceWorkers instead.
+This tests that HttpOnly cookies set on the main document are used when accessing resources in the manifest.
+PASSED: Cookie should not be visible from JavaScript.
+PASSED: Cookie is set to 'bar'
diff --git a/LayoutTests/http/tests/appcache/document-cookie-http-only.php b/LayoutTests/http/tests/appcache/document-cookie-http-only.php
new file mode 100644 (file)
index 0000000..cd36697
--- /dev/null
@@ -0,0 +1,32 @@
+<?php
+setcookie("foo", "bar", 0, "/", null, null, true);
+?>
+<html manifest="resources/document-cookie.manifest">
+
+<div>This tests that HttpOnly cookies set on the main document are used when accessing resources in the manifest.</div>
+<div id="log">Not checked cookie yet</div>
+<div id="result">Not run yet</div>
+<script>
+if (window.testRunner) {
+    testRunner.dumpAsText()
+    testRunner.waitUntilDone();
+}
+
+var cookieTest = document.cookie === "" ? "PASSED" : "FAILED";
+log.innerHTML = cookieTest + ": Cookie should not be visible from JavaScript.";
+
+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>