Title: [230328] trunk/LayoutTests
Revision
230328
Author
[email protected]
Date
2018-04-05 23:47:31 -0700 (Thu, 05 Apr 2018)

Log Message

Add a test for scoped cookies used to load AppCache resources
https://bugs.webkit.org/show_bug.cgi?id=184315

Reviewed by Ryosuke Niwa.

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

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (230327 => 230328)


--- trunk/LayoutTests/ChangeLog	2018-04-06 06:18:54 UTC (rev 230327)
+++ trunk/LayoutTests/ChangeLog	2018-04-06 06:47:31 UTC (rev 230328)
@@ -1,3 +1,16 @@
+2018-04-05  Youenn Fablet  <[email protected]>
+
+        Add a test for scoped cookies used to load AppCache resources
+        https://bugs.webkit.org/show_bug.cgi?id=184315
+
+        Reviewed by Ryosuke Niwa.
+
+        * http/tests/appcache/document-cookie-http-only-expected.txt:
+        * http/tests/appcache/document-cookie-http-only.php:
+        * http/tests/appcache/resources/manifest-protected-script.php: Added.
+        * http/tests/appcache/resources/scope1/cookie-protected-manifest.php: Added.
+        * http/tests/appcache/resources/scope2/cookie-protected-script.php: Added.
+
 2018-04-05  Zalan Bujtas  <[email protected]>
 
         Folding anonymous blocks should not result in deleting content.

Modified: trunk/LayoutTests/http/tests/appcache/document-cookie-http-only-expected.txt (230327 => 230328)


--- trunk/LayoutTests/http/tests/appcache/document-cookie-http-only-expected.txt	2018-04-06 06:18:54 UTC (rev 230327)
+++ trunk/LayoutTests/http/tests/appcache/document-cookie-http-only-expected.txt	2018-04-06 06:47:31 UTC (rev 230328)
@@ -1,4 +1,6 @@
 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_.
+This also tests that cookies used by appcache resource loading are scoped properly.
+PASSED: Some cookies should not be visible from _javascript_.
+PASSED: Script Cookie is set to 'script'
 PASSED: Cookie is set to 'bar'

Modified: trunk/LayoutTests/http/tests/appcache/document-cookie-http-only.php (230327 => 230328)


--- trunk/LayoutTests/http/tests/appcache/document-cookie-http-only.php	2018-04-06 06:18:54 UTC (rev 230327)
+++ trunk/LayoutTests/http/tests/appcache/document-cookie-http-only.php	2018-04-06 06:47:31 UTC (rev 230328)
@@ -1,10 +1,14 @@
 <?php
-setcookie("foo", "bar", 0, "/", null, null, true);
+setcookie("scope", "manifest", 0, "/appcache/resources/scope1", null, null, true);
+setcookie("scope", "script", 0, "/appcache/resources/scope2", null, null, true);
+setcookie("foo", "bar");
 ?>
-<html manifest="resources/document-cookie.manifest">
+<html manifest="resources/scope1/cookie-protected-manifest.php">
 
 <div>This tests that HttpOnly cookies set on the main document are used when accessing resources in the manifest.</div>
+<div>This also tests that cookies used by appcache resource loading are scoped properly.</div>
 <div id="log">Not checked cookie yet</div>
+<div id="result1">Not run yet</div>
 <div id="result">Not run yet</div>
 <script>
 if (window.testRunner) {
@@ -12,14 +16,21 @@
     testRunner.waitUntilDone();
 }
 
-var cookieTest = document.cookie === "" ? "PASSED" : "FAILED";
-log.innerHTML = cookieTest + ": Cookie should not be visible from _javascript_.";
+var cookieTest = document.cookie === "foo=bar" ? "PASSED" : "FAILED";
+log.innerHTML = cookieTest + ": Some cookies should not be visible from _javascript_.";
 
 function dynamicScriptLoad() {
     var script = document.createElement("script");
     script.type = "text/_javascript_";
-    script.src = ""
+    script.src = ""
     document.getElementsByTagName("head")[0].appendChild(script);
+
+    setTimeout(() => {
+        script = document.createElement("script");
+        script.type = "text/_javascript_";
+        script.src = ""
+        document.getElementsByTagName("head")[0].appendChild(script);
+    }, 0);
 }
 
 function cached()

Added: trunk/LayoutTests/http/tests/appcache/resources/manifest-protected-script.php (0 => 230328)


--- trunk/LayoutTests/http/tests/appcache/resources/manifest-protected-script.php	                        (rev 0)
+++ trunk/LayoutTests/http/tests/appcache/resources/manifest-protected-script.php	2018-04-06 06:47:31 UTC (rev 230328)
@@ -0,0 +1,12 @@
+<?php
+
+if (isset($_COOKIE['foo']) and $_COOKIE['foo'] == 'manifest') {
+    header('Content-Type: text/html; ' . $_COOKIE['foo']);
+    print("CACHE MANIFEST\n");
+    print("simple.txt\n");
+    return;
+}
+header('HTTP/1.0 404 Not Found');
+header('Content-Type: text/html; ' . count($_COOKIE));
+
+?>

Added: trunk/LayoutTests/http/tests/appcache/resources/scope1/cookie-protected-manifest.php (0 => 230328)


--- trunk/LayoutTests/http/tests/appcache/resources/scope1/cookie-protected-manifest.php	                        (rev 0)
+++ trunk/LayoutTests/http/tests/appcache/resources/scope1/cookie-protected-manifest.php	2018-04-06 06:47:31 UTC (rev 230328)
@@ -0,0 +1,14 @@
+<?php
+
+if (isset($_COOKIE['scope']) and $_COOKIE['scope'] == 'manifest') {
+    header('Content-Type: text/html; ' . $_COOKIE['scope']);
+    print("CACHE MANIFEST\n");
+    print("/appcache/resources/simple.txt\n");
+    print("/appcache/resources/scope2/cookie-protected-script.php\n");
+    print("/appcache/resources/cookie-protected-script.php\n");
+    return;
+}
+header('HTTP/1.0 404 Not Found');
+header('Content-Type: text/html; ' . $_COOKIE['scope']);
+
+?>

Added: trunk/LayoutTests/http/tests/appcache/resources/scope2/cookie-protected-script.php (0 => 230328)


--- trunk/LayoutTests/http/tests/appcache/resources/scope2/cookie-protected-script.php	                        (rev 0)
+++ trunk/LayoutTests/http/tests/appcache/resources/scope2/cookie-protected-script.php	2018-04-06 06:47:31 UTC (rev 230328)
@@ -0,0 +1,15 @@
+<?php
+header("Content-type:application/_javascript_");
+
+if (isset($_COOKIE["scope"])) {
+    echo "var cookieVal = '" . $_COOKIE["scope"] . "';";
+} else {
+    echo "var cookieVal = '<null>';";
+}
+
+?>
+
+if (cookieVal === "script")
+    document.getElementById("result1").innerHTML = "PASSED: Script Cookie is set to 'script'";
+else
+    document.getElementById("result1").innerHTML = "FAILED: Script Cookie should be 'script', is set to '" + cookieVal + "'";
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to