Title: [244101] trunk/LayoutTests
- Revision
- 244101
- Author
- wilan...@apple.com
- Date
- 2019-04-09 18:03:28 -0700 (Tue, 09 Apr 2019)
Log Message
Add Resource Load Statistics test case for Ping
https://bugs.webkit.org/show_bug.cgi?id=196748
Reviewed by Alex Christensen.
* http/tests/resourceLoadStatistics/ping-to-prevalent-resource-expected.txt: Added.
* http/tests/resourceLoadStatistics/ping-to-prevalent-resource.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (244100 => 244101)
--- trunk/LayoutTests/ChangeLog 2019-04-10 00:35:18 UTC (rev 244100)
+++ trunk/LayoutTests/ChangeLog 2019-04-10 01:03:28 UTC (rev 244101)
@@ -1,3 +1,13 @@
+2019-04-09 John Wilander <wilan...@apple.com>
+
+ Add Resource Load Statistics test case for Ping
+ https://bugs.webkit.org/show_bug.cgi?id=196748
+
+ Reviewed by Alex Christensen.
+
+ * http/tests/resourceLoadStatistics/ping-to-prevalent-resource-expected.txt: Added.
+ * http/tests/resourceLoadStatistics/ping-to-prevalent-resource.html: Added.
+
2019-04-09 Megan Gardner <megan_gard...@apple.com>
Turn on editing test that should pass now
Added: trunk/LayoutTests/http/tests/resourceLoadStatistics/ping-to-prevalent-resource-expected.txt (0 => 244101)
--- trunk/LayoutTests/http/tests/resourceLoadStatistics/ping-to-prevalent-resource-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/resourceLoadStatistics/ping-to-prevalent-resource-expected.txt 2019-04-10 01:03:28 UTC (rev 244101)
@@ -0,0 +1,24 @@
+Tests that cookie blocking is applied to ping loads.
+
+
+--------
+Frame: '<!--frame1-->'
+--------
+Should receive first-party cookie.
+Received cookie named 'firstPartyCookie'.
+Client-side document.cookie: firstPartyCookie=value
+
+--------
+Frame: '<!--frame2-->'
+--------
+Should receive no cookies.
+Did not receive cookie named 'firstPartyCookie'.
+Client-side document.cookie:
+
+--------
+Frame: '<!--frame3-->'
+--------
+Ping received.
+HTTP_HOST: localhost:8000
+REQUEST_URI: /contentextensions/resources/save-ping.php?test=ping-to-prevalent-resource
+No cookies in ping.
Added: trunk/LayoutTests/http/tests/resourceLoadStatistics/ping-to-prevalent-resource.html (0 => 244101)
--- trunk/LayoutTests/http/tests/resourceLoadStatistics/ping-to-prevalent-resource.html (rev 0)
+++ trunk/LayoutTests/http/tests/resourceLoadStatistics/ping-to-prevalent-resource.html 2019-04-10 01:03:28 UTC (rev 244101)
@@ -0,0 +1,97 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <script src=""
+ <script src=""
+</head>
+<body>
+<div id="description">Tests that cookie blocking is applied to ping loads.</div>
+<a id="targetLink" href="" ping="http://localhost:8000/contentextensions/resources/save-ping.php?test=ping-to-prevalent-resource">The link</a>
+<script>
+ if (testRunner)
+ testRunner.waitUntilDone();
+
+ const partitionHost = "127.0.0.1:8000";
+ const thirdPartyOrigin = "http://localhost:8000";
+ const resourcePath = "/resourceLoadStatistics/resources";
+ const thirdPartyBaseUrl = thirdPartyOrigin + resourcePath;
+ const firstPartyCookieName = "firstPartyCookie";
+ const subPathToSetFirstPartyCookie = "/set-cookie.php?name=" + firstPartyCookieName + "&value=value";
+ const returnUrl = "http://" + partitionHost + "/resourceLoadStatistics/ping-to-prevalent-resource.html";
+ const subPathToGetCookies = "/get-cookies.php?name1=" + firstPartyCookieName;
+
+ function activateElement(elementID, callback) {
+ var element = document.getElementById(elementID);
+ var centerX = element.offsetLeft + element.offsetWidth / 2;
+ var centerY = element.offsetTop + element.offsetHeight / 2;
+ UIHelper.activateAt(centerX, centerY).then(
+ function () {
+ callback();
+ },
+ function () {
+ testRunner.notifyDone();
+ }
+ );
+ }
+
+ function openIframe(url, onLoadHandler) {
+ const element = document.createElement("iframe");
+ element.src = ""
+ if (onLoadHandler) {
+ element._onload_ = onLoadHandler;
+ }
+ document.body.appendChild(element);
+ }
+
+ function runTest() {
+ switch (document.location.hash) {
+ case "#step1":
+ // Set first-party cookie for localhost.
+ document.location.href = "" + subPathToSetFirstPartyCookie + "#" + returnUrl + "#step2";
+ break;
+ case "#step2":
+ // Check that the cookie gets sent for localhost under 127.0.0.1 since localhost is not prevalent.
+ document.location.hash = "step3";
+ openIframe(thirdPartyBaseUrl + subPathToGetCookies + "&message=Should receive first-party cookie.", runTest);
+ break;
+ case "#step3":
+ // Set localhost as prevalent to put it in the blocking category.
+ document.location.hash = "step4";
+ testRunner.setStatisticsPrevalentResource(thirdPartyOrigin, true, function() {
+ testRunner.statisticsUpdateCookieBlocking(runTest);
+ });
+ break;
+ case "#step4":
+ // Check that no cookie gets sent for localhost under 127.0.0.1 since localhost's cookies are blocked.
+ document.location.hash = "step5";
+ openIframe(thirdPartyBaseUrl + subPathToGetCookies + "&message=Should receive no cookies.", runTest);
+ break;
+ case "#step5":
+ // Click the link to trigger the ping.
+ activateElement("targetLink", function() {
+ openIframe(thirdPartyOrigin + "/contentextensions/resources/get-ping-data.php?test=ping-to-prevalent-resource", function() {
+ document.body.removeChild(document.getElementById("targetLink"));
+ setEnableFeature(false, function() {
+ testRunner.notifyDone();
+ });
+ });
+ });
+ break;
+ }
+ }
+
+ if (document.location.hash === "") {
+ if (testRunner) {
+ setEnableFeature(true, function () {
+ testRunner.dumpChildFramesAsText();
+ document.location.hash = "step1";
+ runTest();
+ });
+ }
+ } else {
+ runTest();
+ }
+</script>
+</body>
+</html>
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes