Skip to content

Commit

Permalink
Add a layout test verifying AppCache resource fetches have the docume…
Browse files Browse the repository at this point in the history
…nt'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.


Canonical link: https://commits.webkit.org/199391@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229733 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
beidson committed Mar 20, 2018
1 parent 659fc3e commit 7b32c90
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 0 deletions.
12 changes: 12 additions & 0 deletions LayoutTests/ChangeLog
@@ -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
Expand Down
3 changes: 3 additions & 0 deletions LayoutTests/http/tests/appcache/document-cookie-expected.txt
@@ -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'
28 changes: 28 additions & 0 deletions LayoutTests/http/tests/appcache/document-cookie.php
@@ -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>
@@ -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();
@@ -0,0 +1,4 @@
CACHE MANIFEST
/appcache/resources/cookie-protected-script.php
NETWORK:
/favicon.ico

0 comments on commit 7b32c90

Please sign in to comment.