Diff
Modified: branches/safari-607-branch/LayoutTests/ChangeLog (243096 => 243097)
--- branches/safari-607-branch/LayoutTests/ChangeLog 2019-03-18 20:29:03 UTC (rev 243096)
+++ branches/safari-607-branch/LayoutTests/ChangeLog 2019-03-18 20:56:41 UTC (rev 243097)
@@ -1,3 +1,28 @@
+2019-03-18 Kocsen Chung <[email protected]>
+
+ Apply patch. rdar://problem/48839387
+
+ 2019-03-18 John Wilander <[email protected]>
+
+ Resource Load Statistics: Further restrict client-side cookie persistence after cross-site navigations with link decoration (branch patch)
+ https://bugs.webkit.org/show_bug.cgi?id=195711
+ <rdar://problem/48839387>
+ <rdar://problem/48832278>
+
+ Reviewed by Brent Fulgham.
+
+ * http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-with-link-decoration-same-site-expected.txt: Added.
+ * http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-with-link-decoration-same-site.html: Added.
+ * http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-with-link-fragment-from-prevalent-resource-expected.txt: Added.
+ * http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-with-link-fragment-from-prevalent-resource.html: Added.
+ * http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-with-link-query-and-fragment-from-prevalent-resource-expected.txt: Added.
+ * http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-with-link-query-and-fragment-from-prevalent-resource.html: Added.
+ * http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-with-link-query-from-prevalent-resource-expected.txt: Added.
+ * http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-with-link-query-from-prevalent-resource.html: Added.
+ * http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-without-link-decoration-from-prevalent-resource-expected.txt: Added.
+ * http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-without-link-decoration-from-prevalent-resource.html: Added.
+ * http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js.html:
+
2019-03-13 Babak Shafiei <[email protected]>
Cherry-pick r242749. rdar://problem/48839358
Added: branches/safari-607-branch/LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-with-link-decoration-same-site-expected.txt (0 => 243097)
--- branches/safari-607-branch/LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-with-link-decoration-same-site-expected.txt (rev 0)
+++ branches/safari-607-branch/LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-with-link-decoration-same-site-expected.txt 2019-03-18 20:56:41 UTC (rev 243097)
@@ -0,0 +1,10 @@
+Check that cookies created by _javascript_ after a same-site navigation with link decoration don't get capped to 24 hours.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS The two long-lived cookies expire after more than 86430 seconds.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: branches/safari-607-branch/LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-with-link-decoration-same-site.html (0 => 243097)
--- branches/safari-607-branch/LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-with-link-decoration-same-site.html (rev 0)
+++ branches/safari-607-branch/LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-with-link-decoration-same-site.html 2019-03-18 20:56:41 UTC (rev 243097)
@@ -0,0 +1,85 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script src=""
+ <script src=""
+ <script src=""
+</head>
+<body _onload_="setTimeout('runTest()', 0)">
+<script>
+ description("Check that cookies created by _javascript_ after a same-site navigation with link decoration don't get capped to 24 hours.");
+ jsTestIsAsync = true;
+
+ function testCookies() {
+ let passedTests = 0;
+
+ function checkThatCookieDoesExpireAfter(cookieData, maxAgeInSeconds) {
+ let now = new Date();
+ let maxExpiryDateInMilliseconds = now.getTime() + (maxAgeInSeconds * 1000);
+
+ if (maxExpiryDateInMilliseconds < cookieData["expires"])
+ ++passedTests;
+ else
+ testFailed("Cookie named " + cookieData["name"] + " expires in less than " + maxAgeInSeconds + " seconds.");
+ }
+
+ const _oneDayInSeconds_ = 24 * 60 * 60;
+ const twoDaysInSeconds = 2 * oneDayInSeconds;
+ const longLivedCookieMaxAge = { name : "longLivedCookieMaxAge", lifetime : "Max-Age=" + twoDaysInSeconds + ";" };
+ document.cookie = longLivedCookieMaxAge.name + "=foobar; " + longLivedCookieMaxAge.lifetime + " path=/";
+
+ const twoDaysAsExpiresDate = createExpiresDateFromMaxAge(twoDaysInSeconds);
+ const longLivedCookieExpires = { name : "longLivedCookieExpires", lifetime : "Expires=" + twoDaysAsExpiresDate + ";" };
+ document.cookie = longLivedCookieExpires.name + "=foobar; " + longLivedCookieExpires.lifetime + " path=/";
+
+ const overOneDayInSeconds = oneDayInSeconds + 30;
+ if (internals) {
+ let cookies = internals.getCookies();
+ if (!cookies.length)
+ testFailed("No cookies found.");
+ for (let cookie of cookies) {
+ switch (cookie.name) {
+ case longLivedCookieMaxAge.name:
+ checkThatCookieDoesExpireAfter(cookie, overOneDayInSeconds);
+ break;
+ case longLivedCookieExpires.name:
+ checkThatCookieDoesExpireAfter(cookie, overOneDayInSeconds);
+ break;
+ }
+ }
+
+ resetCookiesForCurrentOrigin();
+
+ if (passedTests === 2) {
+ testPassed("The two long-lived cookies expire after more than " + overOneDayInSeconds + " seconds.");
+ } else
+ testFailed("At least one cookie's expiry attribute was below the test thresholds.");
+ } else
+ testFailed("No internals object.");
+
+ setEnableFeature(false, finishJSTest);
+ }
+
+ function navigateCrossOrigin() {
+ document.location.href = "" + "/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-with-link-decoration-same-site.html?link=decoration#fragment";
+ }
+
+ const destinationOrigin = "http://localhost:8000";
+ const prevalentResourceOrigin = "http://127.0.0.1:8000";
+ function runTest() {
+ if (document.location.origin === prevalentResourceOrigin && document.location.hash !== "#fragment") {
+ setEnableFeature(true, function () {
+ testRunner.setStatisticsPrevalentResource(prevalentResourceOrigin, true, function() {
+ if (!testRunner.isStatisticsPrevalentResource(prevalentResourceOrigin))
+ testFailed("Host did not get set as prevalent resource.");
+ testRunner.statisticsUpdateCookieBlocking(navigateCrossOrigin);
+ });
+
+ });
+ } else {
+ testCookies();
+ }
+ }
+</script>
+</body>
+</html>
Added: branches/safari-607-branch/LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-with-link-fragment-from-prevalent-resource-expected.txt (0 => 243097)
--- branches/safari-607-branch/LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-with-link-fragment-from-prevalent-resource-expected.txt (rev 0)
+++ branches/safari-607-branch/LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-with-link-fragment-from-prevalent-resource-expected.txt 2019-03-18 20:56:41 UTC (rev 243097)
@@ -0,0 +1,11 @@
+Check that cookies created by _javascript_ after a cross-site navigation with link fragment get capped to 24 hours.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS The two short-lived cookies don't expire after more than 43230 seconds.
+PASS The two long-lived cookies don't expire after more than 86430 seconds.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: branches/safari-607-branch/LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-with-link-fragment-from-prevalent-resource.html (0 => 243097)
--- branches/safari-607-branch/LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-with-link-fragment-from-prevalent-resource.html (rev 0)
+++ branches/safari-607-branch/LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-with-link-fragment-from-prevalent-resource.html 2019-03-18 20:56:41 UTC (rev 243097)
@@ -0,0 +1,100 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script src=""
+ <script src=""
+ <script src=""
+</head>
+<body _onload_="setTimeout('runTest()', 0)">
+<script>
+ description("Check that cookies created by _javascript_ after a cross-site navigation with link fragment get capped to 24 hours.");
+ jsTestIsAsync = true;
+
+ function testCookies() {
+ let passedTests = 0;
+ function checkThatCookieDoesNotExpireAfter(cookieData, maxAgeInSeconds) {
+ let now = new Date();
+ let maxExpiryDateInMilliseconds = now.getTime() + (maxAgeInSeconds * 1000);
+
+ if (maxExpiryDateInMilliseconds > cookieData["expires"])
+ ++passedTests;
+ else
+ testFailed("Cookie named " + cookieData["name"] + " expires in more than " + maxAgeInSeconds + " seconds.");
+ }
+
+ const twelveHoursInSeconds = 12 * 60 * 60;
+ const shortLivedCookieMaxAge = { name : "shortLivedCookieMaxAge", lifetime : "Max-Age=" + twelveHoursInSeconds + ";" };
+ document.cookie = shortLivedCookieMaxAge.name + "=foobar; " + shortLivedCookieMaxAge.lifetime + " path=/";
+
+ const twelveHoursAsExpiresDate = createExpiresDateFromMaxAge(twelveHoursInSeconds);
+ const shortLivedCookieExpires = { name : "shortLivedCookieExpires", lifetime : "Expires=" + twelveHoursAsExpiresDate + ";" };
+ document.cookie = shortLivedCookieExpires.name + "=foobar; " + shortLivedCookieExpires.lifetime + " path=/";
+
+ const _oneDayInSeconds_ = 2 * twelveHoursInSeconds;
+ const twoDaysInSeconds = 2 * oneDayInSeconds;
+ const longLivedCookieMaxAge = { name : "longLivedCookieMaxAge", lifetime : "Max-Age=" + twoDaysInSeconds + ";" };
+ document.cookie = longLivedCookieMaxAge.name + "=foobar; " + longLivedCookieMaxAge.lifetime + " path=/";
+
+ const twoDaysAsExpiresDate = createExpiresDateFromMaxAge(twoDaysInSeconds);
+ const longLivedCookieExpires = { name : "longLivedCookieExpires", lifetime : "Expires=" + twoDaysAsExpiresDate + ";" };
+ document.cookie = longLivedCookieExpires.name + "=foobar; " + longLivedCookieExpires.lifetime + " path=/";
+
+ const overTwelveHoursInSeconds = twelveHoursInSeconds + 30;
+ const overOneDayInSeconds = oneDayInSeconds + 30;
+ if (internals) {
+ let cookies = internals.getCookies();
+ if (!cookies.length)
+ testFailed("No cookies found.");
+ for (let cookie of cookies) {
+ switch (cookie.name) {
+ case shortLivedCookieMaxAge.name:
+ checkThatCookieDoesNotExpireAfter(cookie, overTwelveHoursInSeconds);
+ break;
+ case shortLivedCookieExpires.name:
+ checkThatCookieDoesNotExpireAfter(cookie, overTwelveHoursInSeconds);
+ break;
+ case longLivedCookieMaxAge.name:
+ checkThatCookieDoesNotExpireAfter(cookie, overOneDayInSeconds);
+ break;
+ case longLivedCookieExpires.name:
+ checkThatCookieDoesNotExpireAfter(cookie, overOneDayInSeconds);
+ break;
+ }
+ }
+
+ resetCookiesForCurrentOrigin();
+
+ if (passedTests === 4) {
+ testPassed("The two short-lived cookies don't expire after more than " + overTwelveHoursInSeconds + " seconds.");
+ testPassed("The two long-lived cookies don't expire after more than " + overOneDayInSeconds + " seconds.");
+ } else
+ testFailed("At least one cookie's expiry attribute was beyond the test thresholds.");
+ } else
+ testFailed("No internals object.");
+
+ setEnableFeature(false, finishJSTest);
+ }
+
+ function navigateCrossOrigin() {
+ document.location.href = "" + "/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-with-link-fragment-from-prevalent-resource.html#link=fragment";
+ }
+
+ const destinationOrigin = "http://localhost:8000";
+ const prevalentResourceOrigin = "http://127.0.0.1:8000";
+ function runTest() {
+ if (document.location.origin === prevalentResourceOrigin) {
+ setEnableFeature(true, function () {
+ testRunner.setStatisticsPrevalentResource(prevalentResourceOrigin, true, function() {
+ if (!testRunner.isStatisticsPrevalentResource(prevalentResourceOrigin))
+ testFailed("Host did not get set as prevalent resource.");
+ testRunner.statisticsUpdateCookieBlocking(navigateCrossOrigin);
+ });
+
+ });
+ } else {
+ testCookies();
+ }
+ }
+</script>
+</body>
+</html>
Added: branches/safari-607-branch/LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-with-link-query-and-fragment-from-prevalent-resource-expected.txt (0 => 243097)
--- branches/safari-607-branch/LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-with-link-query-and-fragment-from-prevalent-resource-expected.txt (rev 0)
+++ branches/safari-607-branch/LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-with-link-query-and-fragment-from-prevalent-resource-expected.txt 2019-03-18 20:56:41 UTC (rev 243097)
@@ -0,0 +1,11 @@
+Check that cookies created by _javascript_ after a cross-site navigation with link query and fragment get capped to 24 hours.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS The two short-lived cookies don't expire after more than 43230 seconds.
+PASS The two long-lived cookies don't expire after more than 86430 seconds.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: branches/safari-607-branch/LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-with-link-query-and-fragment-from-prevalent-resource.html (0 => 243097)
--- branches/safari-607-branch/LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-with-link-query-and-fragment-from-prevalent-resource.html (rev 0)
+++ branches/safari-607-branch/LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-with-link-query-and-fragment-from-prevalent-resource.html 2019-03-18 20:56:41 UTC (rev 243097)
@@ -0,0 +1,100 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script src=""
+ <script src=""
+ <script src=""
+</head>
+<body _onload_="setTimeout('runTest()', 0)">
+<script>
+ description("Check that cookies created by _javascript_ after a cross-site navigation with link query and fragment get capped to 24 hours.");
+ jsTestIsAsync = true;
+
+ function testCookies() {
+ let passedTests = 0;
+ function checkThatCookieDoesNotExpireAfter(cookieData, maxAgeInSeconds) {
+ let now = new Date();
+ let maxExpiryDateInMilliseconds = now.getTime() + (maxAgeInSeconds * 1000);
+
+ if (maxExpiryDateInMilliseconds > cookieData["expires"])
+ ++passedTests;
+ else
+ testFailed("Cookie named " + cookieData["name"] + " expires in more than " + maxAgeInSeconds + " seconds.");
+ }
+
+ const twelveHoursInSeconds = 12 * 60 * 60;
+ const shortLivedCookieMaxAge = { name : "shortLivedCookieMaxAge", lifetime : "Max-Age=" + twelveHoursInSeconds + ";" };
+ document.cookie = shortLivedCookieMaxAge.name + "=foobar; " + shortLivedCookieMaxAge.lifetime + " path=/";
+
+ const twelveHoursAsExpiresDate = createExpiresDateFromMaxAge(twelveHoursInSeconds);
+ const shortLivedCookieExpires = { name : "shortLivedCookieExpires", lifetime : "Expires=" + twelveHoursAsExpiresDate + ";" };
+ document.cookie = shortLivedCookieExpires.name + "=foobar; " + shortLivedCookieExpires.lifetime + " path=/";
+
+ const _oneDayInSeconds_ = 2 * twelveHoursInSeconds;
+ const twoDaysInSeconds = 2 * oneDayInSeconds;
+ const longLivedCookieMaxAge = { name : "longLivedCookieMaxAge", lifetime : "Max-Age=" + twoDaysInSeconds + ";" };
+ document.cookie = longLivedCookieMaxAge.name + "=foobar; " + longLivedCookieMaxAge.lifetime + " path=/";
+
+ const twoDaysAsExpiresDate = createExpiresDateFromMaxAge(twoDaysInSeconds);
+ const longLivedCookieExpires = { name : "longLivedCookieExpires", lifetime : "Expires=" + twoDaysAsExpiresDate + ";" };
+ document.cookie = longLivedCookieExpires.name + "=foobar; " + longLivedCookieExpires.lifetime + " path=/";
+
+ const overTwelveHoursInSeconds = twelveHoursInSeconds + 30;
+ const overOneDayInSeconds = oneDayInSeconds + 30;
+ if (internals) {
+ let cookies = internals.getCookies();
+ if (!cookies.length)
+ testFailed("No cookies found.");
+ for (let cookie of cookies) {
+ switch (cookie.name) {
+ case shortLivedCookieMaxAge.name:
+ checkThatCookieDoesNotExpireAfter(cookie, overTwelveHoursInSeconds);
+ break;
+ case shortLivedCookieExpires.name:
+ checkThatCookieDoesNotExpireAfter(cookie, overTwelveHoursInSeconds);
+ break;
+ case longLivedCookieMaxAge.name:
+ checkThatCookieDoesNotExpireAfter(cookie, overOneDayInSeconds);
+ break;
+ case longLivedCookieExpires.name:
+ checkThatCookieDoesNotExpireAfter(cookie, overOneDayInSeconds);
+ break;
+ }
+ }
+
+ resetCookiesForCurrentOrigin();
+
+ if (passedTests === 4) {
+ testPassed("The two short-lived cookies don't expire after more than " + overTwelveHoursInSeconds + " seconds.");
+ testPassed("The two long-lived cookies don't expire after more than " + overOneDayInSeconds + " seconds.");
+ } else
+ testFailed("At least one cookie's expiry attribute was beyond the test thresholds.");
+ } else
+ testFailed("No internals object.");
+
+ setEnableFeature(false, finishJSTest);
+ }
+
+ function navigateCrossOrigin() {
+ document.location.href = "" + "/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-with-link-query-and-fragment-from-prevalent-resource.html?link=query#link=fragment";
+ }
+
+ const destinationOrigin = "http://localhost:8000";
+ const prevalentResourceOrigin = "http://127.0.0.1:8000";
+ function runTest() {
+ if (document.location.origin === prevalentResourceOrigin) {
+ setEnableFeature(true, function () {
+ testRunner.setStatisticsPrevalentResource(prevalentResourceOrigin, true, function() {
+ if (!testRunner.isStatisticsPrevalentResource(prevalentResourceOrigin))
+ testFailed("Host did not get set as prevalent resource.");
+ testRunner.statisticsUpdateCookieBlocking(navigateCrossOrigin);
+ });
+
+ });
+ } else {
+ testCookies();
+ }
+ }
+</script>
+</body>
+</html>
Added: branches/safari-607-branch/LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-with-link-query-from-prevalent-resource-expected.txt (0 => 243097)
--- branches/safari-607-branch/LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-with-link-query-from-prevalent-resource-expected.txt (rev 0)
+++ branches/safari-607-branch/LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-with-link-query-from-prevalent-resource-expected.txt 2019-03-18 20:56:41 UTC (rev 243097)
@@ -0,0 +1,11 @@
+Check that cookies created by _javascript_ after a cross-site navigation with link query get capped to 24 hours.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS The two short-lived cookies don't expire after more than 43230 seconds.
+PASS The two long-lived cookies don't expire after more than 86430 seconds.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: branches/safari-607-branch/LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-with-link-query-from-prevalent-resource.html (0 => 243097)
--- branches/safari-607-branch/LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-with-link-query-from-prevalent-resource.html (rev 0)
+++ branches/safari-607-branch/LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-with-link-query-from-prevalent-resource.html 2019-03-18 20:56:41 UTC (rev 243097)
@@ -0,0 +1,100 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script src=""
+ <script src=""
+ <script src=""
+</head>
+<body _onload_="setTimeout('runTest()', 0)">
+<script>
+ description("Check that cookies created by _javascript_ after a cross-site navigation with link query get capped to 24 hours.");
+ jsTestIsAsync = true;
+
+ function testCookies() {
+ let passedTests = 0;
+ function checkThatCookieDoesNotExpireAfter(cookieData, maxAgeInSeconds) {
+ let now = new Date();
+ let maxExpiryDateInMilliseconds = now.getTime() + (maxAgeInSeconds * 1000);
+
+ if (maxExpiryDateInMilliseconds > cookieData["expires"])
+ ++passedTests;
+ else
+ testFailed("Cookie named " + cookieData["name"] + " expires in more than " + maxAgeInSeconds + " seconds.");
+ }
+
+ const twelveHoursInSeconds = 12 * 60 * 60;
+ const shortLivedCookieMaxAge = { name : "shortLivedCookieMaxAge", lifetime : "Max-Age=" + twelveHoursInSeconds + ";" };
+ document.cookie = shortLivedCookieMaxAge.name + "=foobar; " + shortLivedCookieMaxAge.lifetime + " path=/";
+
+ const twelveHoursAsExpiresDate = createExpiresDateFromMaxAge(twelveHoursInSeconds);
+ const shortLivedCookieExpires = { name : "shortLivedCookieExpires", lifetime : "Expires=" + twelveHoursAsExpiresDate + ";" };
+ document.cookie = shortLivedCookieExpires.name + "=foobar; " + shortLivedCookieExpires.lifetime + " path=/";
+
+ const _oneDayInSeconds_ = 2 * twelveHoursInSeconds;
+ const twoDaysInSeconds = 2 * oneDayInSeconds;
+ const longLivedCookieMaxAge = { name : "longLivedCookieMaxAge", lifetime : "Max-Age=" + twoDaysInSeconds + ";" };
+ document.cookie = longLivedCookieMaxAge.name + "=foobar; " + longLivedCookieMaxAge.lifetime + " path=/";
+
+ const twoDaysAsExpiresDate = createExpiresDateFromMaxAge(twoDaysInSeconds);
+ const longLivedCookieExpires = { name : "longLivedCookieExpires", lifetime : "Expires=" + twoDaysAsExpiresDate + ";" };
+ document.cookie = longLivedCookieExpires.name + "=foobar; " + longLivedCookieExpires.lifetime + " path=/";
+
+ const overTwelveHoursInSeconds = twelveHoursInSeconds + 30;
+ const overOneDayInSeconds = oneDayInSeconds + 30;
+ if (internals) {
+ let cookies = internals.getCookies();
+ if (!cookies.length)
+ testFailed("No cookies found.");
+ for (let cookie of cookies) {
+ switch (cookie.name) {
+ case shortLivedCookieMaxAge.name:
+ checkThatCookieDoesNotExpireAfter(cookie, overTwelveHoursInSeconds);
+ break;
+ case shortLivedCookieExpires.name:
+ checkThatCookieDoesNotExpireAfter(cookie, overTwelveHoursInSeconds);
+ break;
+ case longLivedCookieMaxAge.name:
+ checkThatCookieDoesNotExpireAfter(cookie, overOneDayInSeconds);
+ break;
+ case longLivedCookieExpires.name:
+ checkThatCookieDoesNotExpireAfter(cookie, overOneDayInSeconds);
+ break;
+ }
+ }
+
+ resetCookiesForCurrentOrigin();
+
+ if (passedTests === 4) {
+ testPassed("The two short-lived cookies don't expire after more than " + overTwelveHoursInSeconds + " seconds.");
+ testPassed("The two long-lived cookies don't expire after more than " + overOneDayInSeconds + " seconds.");
+ } else
+ testFailed("At least one cookie's expiry attribute was beyond the test thresholds.");
+ } else
+ testFailed("No internals object.");
+
+ setEnableFeature(false, finishJSTest);
+ }
+
+ function navigateCrossOrigin() {
+ document.location.href = "" + "/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-with-link-query-from-prevalent-resource.html?link=query";
+ }
+
+ const destinationOrigin = "http://localhost:8000";
+ const prevalentResourceOrigin = "http://127.0.0.1:8000";
+ function runTest() {
+ if (document.location.origin === prevalentResourceOrigin) {
+ setEnableFeature(true, function () {
+ testRunner.setStatisticsPrevalentResource(prevalentResourceOrigin, true, function() {
+ if (!testRunner.isStatisticsPrevalentResource(prevalentResourceOrigin))
+ testFailed("Host did not get set as prevalent resource.");
+ testRunner.statisticsUpdateCookieBlocking(navigateCrossOrigin);
+ });
+
+ });
+ } else {
+ testCookies();
+ }
+ }
+</script>
+</body>
+</html>
Added: branches/safari-607-branch/LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-without-link-decoration-from-prevalent-resource-expected.txt (0 => 243097)
--- branches/safari-607-branch/LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-without-link-decoration-from-prevalent-resource-expected.txt (rev 0)
+++ branches/safari-607-branch/LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-without-link-decoration-from-prevalent-resource-expected.txt 2019-03-18 20:56:41 UTC (rev 243097)
@@ -0,0 +1,10 @@
+Check that cookies created by _javascript_ after a cross-site navigation without link decoration don't get capped to 24 hours.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS The two long-lived cookies expire after more than 86430 seconds.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: branches/safari-607-branch/LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-without-link-decoration-from-prevalent-resource.html (0 => 243097)
--- branches/safari-607-branch/LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-without-link-decoration-from-prevalent-resource.html (rev 0)
+++ branches/safari-607-branch/LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-without-link-decoration-from-prevalent-resource.html 2019-03-18 20:56:41 UTC (rev 243097)
@@ -0,0 +1,85 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script src=""
+ <script src=""
+ <script src=""
+</head>
+<body _onload_="setTimeout('runTest()', 0)">
+<script>
+ description("Check that cookies created by _javascript_ after a cross-site navigation without link decoration don't get capped to 24 hours.");
+ jsTestIsAsync = true;
+
+ function testCookies() {
+ let passedTests = 0;
+
+ function checkThatCookieDoesExpireAfter(cookieData, maxAgeInSeconds) {
+ let now = new Date();
+ let maxExpiryDateInMilliseconds = now.getTime() + (maxAgeInSeconds * 1000);
+
+ if (maxExpiryDateInMilliseconds < cookieData["expires"])
+ ++passedTests;
+ else
+ testFailed("Cookie named " + cookieData["name"] + " expires in less than " + maxAgeInSeconds + " seconds.");
+ }
+
+ const _oneDayInSeconds_ = 24 * 60 * 60;
+ const twoDaysInSeconds = 2 * oneDayInSeconds;
+ const longLivedCookieMaxAge = { name : "longLivedCookieMaxAge", lifetime : "Max-Age=" + twoDaysInSeconds + ";" };
+ document.cookie = longLivedCookieMaxAge.name + "=foobar; " + longLivedCookieMaxAge.lifetime + " path=/";
+
+ const twoDaysAsExpiresDate = createExpiresDateFromMaxAge(twoDaysInSeconds);
+ const longLivedCookieExpires = { name : "longLivedCookieExpires", lifetime : "Expires=" + twoDaysAsExpiresDate + ";" };
+ document.cookie = longLivedCookieExpires.name + "=foobar; " + longLivedCookieExpires.lifetime + " path=/";
+
+ const overOneDayInSeconds = oneDayInSeconds + 30;
+ if (internals) {
+ let cookies = internals.getCookies();
+ if (!cookies.length)
+ testFailed("No cookies found.");
+ for (let cookie of cookies) {
+ switch (cookie.name) {
+ case longLivedCookieMaxAge.name:
+ checkThatCookieDoesExpireAfter(cookie, overOneDayInSeconds);
+ break;
+ case longLivedCookieExpires.name:
+ checkThatCookieDoesExpireAfter(cookie, overOneDayInSeconds);
+ break;
+ }
+ }
+
+ resetCookiesForCurrentOrigin();
+
+ if (passedTests === 2) {
+ testPassed("The two long-lived cookies expire after more than " + overOneDayInSeconds + " seconds.");
+ } else
+ testFailed("At least one cookie's expiry attribute was below the test thresholds.");
+ } else
+ testFailed("No internals object.");
+
+ setEnableFeature(false, finishJSTest);
+ }
+
+ function navigateCrossOrigin() {
+ document.location.href = "" + "/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-without-link-decoration-from-prevalent-resource.html";
+ }
+
+ const destinationOrigin = "http://localhost:8000";
+ const prevalentResourceOrigin = "http://127.0.0.1:8000";
+ function runTest() {
+ if (document.location.origin === prevalentResourceOrigin) {
+ setEnableFeature(true, function () {
+ testRunner.setStatisticsPrevalentResource(prevalentResourceOrigin, true, function() {
+ if (!testRunner.isStatisticsPrevalentResource(prevalentResourceOrigin))
+ testFailed("Host did not get set as prevalent resource.");
+ testRunner.statisticsUpdateCookieBlocking(navigateCrossOrigin);
+ });
+
+ });
+ } else {
+ testCookies();
+ }
+ }
+</script>
+</body>
+</html>
Modified: branches/safari-607-branch/LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js.html (243096 => 243097)
--- branches/safari-607-branch/LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js.html 2019-03-18 20:29:03 UTC (rev 243096)
+++ branches/safari-607-branch/LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js.html 2019-03-18 20:56:41 UTC (rev 243097)
@@ -62,6 +62,9 @@
break;
}
}
+
+ resetCookiesForCurrentOrigin();
+
if (passedTests === 4) {
testPassed("The two short-lived cookies don't expire after more than " + overTwoDaysInSeconds + " seconds.");
testPassed("The two long-lived cookies don't expire after more than " + overOneWeekInSeconds + " seconds.");
Modified: branches/safari-607-branch/Source/WebCore/ChangeLog (243096 => 243097)
--- branches/safari-607-branch/Source/WebCore/ChangeLog 2019-03-18 20:29:03 UTC (rev 243096)
+++ branches/safari-607-branch/Source/WebCore/ChangeLog 2019-03-18 20:56:41 UTC (rev 243097)
@@ -1,3 +1,54 @@
+2019-03-18 Kocsen Chung <[email protected]>
+
+ Apply patch. rdar://problem/48839387
+
+ 2019-03-18 John Wilander <[email protected]>
+
+ Resource Load Statistics: Further restrict client-side cookie persistence after cross-site navigations with link decoration (branch patch)
+ https://bugs.webkit.org/show_bug.cgi?id=195711
+ <rdar://problem/48839387>
+ <rdar://problem/48832278>
+
+ Reviewed by Brent Fulgham.
+
+ Tests: http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-with-link-decoration-same-site.html
+ http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-with-link-fragment-from-prevalent-resource.html
+ http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-with-link-query-and-fragment-from-prevalent-resource.html
+ http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-with-link-query-from-prevalent-resource.html
+ http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-without-link-decoration-from-prevalent-resource.html
+
+ This patch does three things:
+
+ 1) Applies the changes in https://trac.webkit.org/changeset/242288 to
+ a branch. The only meaningful difference is the use of String instead
+ of WebCore::RegistrableDomain. Tracked by <rdar://problem/48839387>.
+
+ 2) Set the lifetime cap for client-side cookies in the call to
+ NetworkStorageSession::setPrevalentDomainsToBlockCookiesFor(). This
+ change makes sure that if ITP is enabled, the cap will be applied.
+ Previously, the cap was set when WebProcessPool::ensureNetworkProcess()
+ called WebsiteDataStore::didCreateNetworkProcess() which might fail if
+ the website data store's m_resourceLoadStatistics object is not created
+ yet. Tracked by <rdar://problem/48832278>.
+
+ 3) Makes sure WebProcessPool::ensureNetworkProcess() calls
+ WebsiteDataStore::didCreateNetworkProcess() also if there was an
+ existing website data store object supplied (the withWebsiteDataStore
+ parameter). Tracked by <rdar://problem/48832278>.
+
+ * platform/network/NetworkStorageSession.cpp:
+ (WebCore::NetworkStorageSession::setAgeCapForClientSideCookies):
+ (WebCore::NetworkStorageSession::setPrevalentDomainsToBlockCookiesFor):
+ (WebCore::NetworkStorageSession::clearPageSpecificDataForResourceLoadStatistics):
+ (WebCore::NetworkStorageSession::committedCrossSiteLoadWithLinkDecoration):
+ (WebCore::NetworkStorageSession::resetCrossSiteLoadsWithLinkDecorationForTesting):
+ (WebCore::NetworkStorageSession::clientSideCookieCap const):
+ (WebCore::NetworkStorageSession::removeStorageAccessForAllFramesOnPage): Deleted.
+ * platform/network/NetworkStorageSession.h:
+ * platform/network/cocoa/NetworkStorageSessionCocoa.mm:
+ (WebCore::filterCookies):
+ (WebCore::NetworkStorageSession::setCookiesFromDOM const):
+
2019-03-13 Babak Shafiei <[email protected]>
Cherry-pick r242749. rdar://problem/48839358
Modified: branches/safari-607-branch/Source/WebCore/platform/network/NetworkStorageSession.cpp (243096 => 243097)
--- branches/safari-607-branch/Source/WebCore/platform/network/NetworkStorageSession.cpp 2019-03-18 20:29:03 UTC (rev 243096)
+++ branches/safari-607-branch/Source/WebCore/platform/network/NetworkStorageSession.cpp 2019-03-18 20:56:41 UTC (rev 243097)
@@ -137,6 +137,7 @@
void NetworkStorageSession::setAgeCapForClientSideCookies(Optional<Seconds> seconds)
{
m_ageCapForClientSideCookies = seconds;
+ m_ageCapForClientSideCookiesShort = seconds ? Seconds { seconds->seconds() / 7. } : seconds;
}
void NetworkStorageSession::setPrevalentDomainsToBlockCookiesFor(const Vector<String>& domains)
@@ -143,6 +144,12 @@
{
m_topPrivatelyControlledDomainsToBlock.clear();
m_topPrivatelyControlledDomainsToBlock.add(domains.begin(), domains.end());
+
+ static NeverDestroyed<Seconds> _oneWeekInSeconds_ = 24_h * 7;
+ if (!m_ageCapForClientSideCookies)
+ setAgeCapForClientSideCookies({ oneWeekInSeconds });
+ if (!m_cacheMaxAgeCapForPrevalentResources)
+ setCacheMaxAgeCapForPrevalentResources(oneWeekInSeconds);
}
void NetworkStorageSession::removePrevalentDomains(const Vector<String>& domains)
@@ -227,10 +234,12 @@
iteration->value.remove(frameID);
}
-void NetworkStorageSession::removeStorageAccessForAllFramesOnPage(uint64_t pageID)
+void NetworkStorageSession::clearPageSpecificDataForResourceLoadStatistics(uint64_t pageID)
{
m_pagesGrantedStorageAccess.remove(pageID);
m_framesGrantedStorageAccess.remove(pageID);
+ if (!m_navigationWithLinkDecorationTestMode)
+ m_navigatedToWithLinkDecorationByPrevalentResource.remove(pageID);
}
void NetworkStorageSession::removeAllStorageAccess()
@@ -248,6 +257,38 @@
{
m_cacheMaxAgeCapForPrevalentResources = WTF::nullopt;
}
+
+void NetworkStorageSession::committedCrossSiteLoadWithLinkDecoration(const String& fromRegistrableDomain, const String& toRegistrableDomain, uint64_t pageID)
+{
+ if (shouldBlockThirdPartyCookies(fromRegistrableDomain))
+ m_navigatedToWithLinkDecorationByPrevalentResource.add(pageID, toRegistrableDomain);
+}
+
+void NetworkStorageSession::resetCrossSiteLoadsWithLinkDecorationForTesting()
+{
+ m_navigatedToWithLinkDecorationByPrevalentResource.clear();
+ m_navigationWithLinkDecorationTestMode = true;
+}
+
+Optional<Seconds> NetworkStorageSession::clientSideCookieCap(const URL& url, Optional<uint64_t> pageID) const
+{
+ if (!m_ageCapForClientSideCookies || !pageID || m_navigatedToWithLinkDecorationByPrevalentResource.isEmpty())
+ return m_ageCapForClientSideCookies;
+
+ auto domainIterator = m_navigatedToWithLinkDecorationByPrevalentResource.find(*pageID);
+ if (domainIterator == m_navigatedToWithLinkDecorationByPrevalentResource.end())
+ return m_ageCapForClientSideCookies;
+
+ auto domain = url.host().toString();
+#if ENABLE(PUBLIC_SUFFIX_LIST)
+ domain = topPrivatelyControlledDomain(domain);
+#endif
+
+ if (domainIterator->value == domain)
+ return m_ageCapForClientSideCookiesShort;
+
+ return m_ageCapForClientSideCookies;
+}
#endif // ENABLE(RESOURCE_LOAD_STATISTICS)
}
Modified: branches/safari-607-branch/Source/WebCore/platform/network/NetworkStorageSession.h (243096 => 243097)
--- branches/safari-607-branch/Source/WebCore/platform/network/NetworkStorageSession.h 2019-03-18 20:29:03 UTC (rev 243096)
+++ branches/safari-607-branch/Source/WebCore/platform/network/NetworkStorageSession.h 2019-03-18 20:56:41 UTC (rev 243097)
@@ -158,11 +158,13 @@
WEBCORE_EXPORT Vector<String> getAllStorageAccessEntries() const;
WEBCORE_EXPORT void grantStorageAccess(const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID);
WEBCORE_EXPORT void removeStorageAccessForFrame(uint64_t frameID, uint64_t pageID);
- WEBCORE_EXPORT void removeStorageAccessForAllFramesOnPage(uint64_t pageID);
+ WEBCORE_EXPORT void clearPageSpecificDataForResourceLoadStatistics(uint64_t pageID);
WEBCORE_EXPORT void removeAllStorageAccess();
WEBCORE_EXPORT void setCacheMaxAgeCapForPrevalentResources(Seconds);
WEBCORE_EXPORT void resetCacheMaxAgeCapForPrevalentResources();
WEBCORE_EXPORT Optional<Seconds> maxAgeCacheCap(const ResourceRequest&);
+ WEBCORE_EXPORT void committedCrossSiteLoadWithLinkDecoration(const String& fromRegistrableDomain, const String& toRegistrableDomain, uint64_t pageID);
+ WEBCORE_EXPORT void resetCrossSiteLoadsWithLinkDecorationForTesting();
#endif
private:
@@ -191,11 +193,15 @@
#if ENABLE(RESOURCE_LOAD_STATISTICS)
bool shouldBlockThirdPartyCookies(const String& topPrivatelyControlledDomain) const;
+ Optional<Seconds> clientSideCookieCap(const URL&, Optional<uint64_t> pageID) const;
HashSet<String> m_topPrivatelyControlledDomainsToBlock;
HashMap<uint64_t, HashMap<uint64_t, String, DefaultHash<uint64_t>::Hash, WTF::UnsignedWithZeroKeyHashTraits<uint64_t>>, DefaultHash<uint64_t>::Hash, WTF::UnsignedWithZeroKeyHashTraits<uint64_t>> m_framesGrantedStorageAccess;
HashMap<uint64_t, HashMap<String, String>, DefaultHash<uint64_t>::Hash, WTF::UnsignedWithZeroKeyHashTraits<uint64_t>> m_pagesGrantedStorageAccess;
Optional<Seconds> m_cacheMaxAgeCapForPrevalentResources { };
Optional<Seconds> m_ageCapForClientSideCookies { };
+ Optional<Seconds> m_ageCapForClientSideCookiesShort { };
+ HashMap<uint64_t, String, DefaultHash<uint64_t>::Hash, WTF::UnsignedWithZeroKeyHashTraits<uint64_t>> m_navigatedToWithLinkDecorationByPrevalentResource;
+ bool m_navigationWithLinkDecorationTestMode = false;
#endif
#if PLATFORM(COCOA)
Modified: branches/safari-607-branch/Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm (243096 => 243097)
--- branches/safari-607-branch/Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm 2019-03-18 20:29:03 UTC (rev 243096)
+++ branches/safari-607-branch/Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm 2019-03-18 20:56:41 UTC (rev 243097)
@@ -404,7 +404,7 @@
#endif
#if ENABLE(RESOURCE_LOAD_STATISTICS)
- RetainPtr<NSArray> filteredCookies = filterCookies(unfilteredCookies, m_ageCapForClientSideCookies);
+ RetainPtr<NSArray> filteredCookies = filterCookies(unfilteredCookies, clientSideCookieCap(firstParty, pageID));
#else
RetainPtr<NSArray> filteredCookies = filterCookies(unfilteredCookies, false);
#endif
Modified: branches/safari-607-branch/Source/WebKit/ChangeLog (243096 => 243097)
--- branches/safari-607-branch/Source/WebKit/ChangeLog 2019-03-18 20:29:03 UTC (rev 243096)
+++ branches/safari-607-branch/Source/WebKit/ChangeLog 2019-03-18 20:56:41 UTC (rev 243097)
@@ -1,3 +1,98 @@
+2019-03-18 Kocsen Chung <[email protected]>
+
+ Apply patch. rdar://problem/48839387
+
+ 2019-03-18 John Wilander <[email protected]>
+
+ Resource Load Statistics: Further restrict client-side cookie persistence after cross-site navigations with link decoration (branch patch)
+ https://bugs.webkit.org/show_bug.cgi?id=195711
+ <rdar://problem/48839387>
+ <rdar://problem/48832278>
+
+ Reviewed by Brent Fulgham.
+
+ This patch does three things:
+
+ 1) Applies the changes in https://trac.webkit.org/changeset/242288 to
+ a branch. The only meaningful difference is the use of String instead
+ of WebCore::RegistrableDomain. Tracked by <rdar://problem/48839387>.
+
+ 2) Set the lifetime cap for client-side cookies in the call to
+ NetworkStorageSession::setPrevalentDomainsToBlockCookiesFor(). This
+ change makes sure that if ITP is enabled, the cap will be applied.
+ Previously, the cap was set when WebProcessPool::ensureNetworkProcess()
+ called WebsiteDataStore::didCreateNetworkProcess() which might fail if
+ the website data store's m_resourceLoadStatistics object is not created
+ yet. Tracked by <rdar://problem/48832278>.
+
+ 3) Makes sure WebProcessPool::ensureNetworkProcess() calls
+ WebsiteDataStore::didCreateNetworkProcess() also if there was an
+ existing website data store object supplied (the withWebsiteDataStore
+ parameter). Tracked by <rdar://problem/48832278>.
+
+ * NetworkProcess/NetworkConnectionToWebProcess.cpp:
+ (WebKit::NetworkConnectionToWebProcess::clearPageSpecificDataForResourceLoadStatistics):
+ (WebKit::NetworkConnectionToWebProcess::removeStorageAccessForAllFramesOnPage): Deleted.
+ * NetworkProcess/NetworkConnectionToWebProcess.h:
+ * NetworkProcess/NetworkConnectionToWebProcess.messages.in:
+ * NetworkProcess/NetworkProcess.cpp:
+ (WebKit::NetworkProcess::committedCrossSiteLoadWithLinkDecoration):
+ (WebKit::NetworkProcess::resetCrossSiteLoadsWithLinkDecorationForTesting):
+ * NetworkProcess/NetworkProcess.h:
+ * NetworkProcess/NetworkProcess.messages.in:
+ * UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
+ (WKWebsiteDataStoreStatisticsResetToConsistentState):
+ * UIProcess/Network/NetworkProcessProxy.cpp:
+ (WebKit::NetworkProcessProxy::resetCrossSiteLoadsWithLinkDecorationForTesting):
+ * UIProcess/Network/NetworkProcessProxy.h:
+ * UIProcess/ResourceLoadStatisticsMemoryStore.cpp:
+ (WebKit::ResourceLoadStatisticsMemoryStore::didCreateNetworkProcess):
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::isNonUniqueNavigationWithLinkDecoration):
+ (WebKit::WebPageProxy::didCommitLoadForFrame):
+ * UIProcess/WebProcessPool.cpp:
+ (WebKit::WebProcessPool::ensureNetworkProcess):
+ * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+ (WebKit::WebsiteDataStore::resetCrossSiteLoadsWithLinkDecorationForTesting):
+ * UIProcess/WebsiteData/WebsiteDataStore.h:
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::close):
+
+2019-03-06 Kocsen Chung <[email protected]>
+
+ Cherry-pick r242554. rdar://problem/48647490
+
+ REGRESSION (r238490): YouTube.com: Returning PiP to Safari after sleeping device loses page
+ https://bugs.webkit.org/show_bug.cgi?id=195364
+ <rdar://problem/48538837>
+
+ Reviewed by Geoffrey Garen.
+
+ Make sure we unset the LayerTreeFreezeReason::ProcessSuspended layer tree freeze reason
+ when WebPage::applicationWillEnterForeground() is called. This restores pre-r238490
+ behavior and addresses the issue with PiP on youtube.com.
+
+ * WebProcess/WebPage/ios/WebPageIOS.mm:
+ (WebKit::WebPage::applicationWillEnterForeground):
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242554 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2019-03-06 Chris Dumez <[email protected]>
+
+ REGRESSION (r238490): YouTube.com: Returning PiP to Safari after sleeping device loses page
+ https://bugs.webkit.org/show_bug.cgi?id=195364
+ <rdar://problem/48538837>
+
+ Reviewed by Geoffrey Garen.
+
+ Make sure we unset the LayerTreeFreezeReason::ProcessSuspended layer tree freeze reason
+ when WebPage::applicationWillEnterForeground() is called. This restores pre-r238490
+ behavior and addresses the issue with PiP on youtube.com.
+
+ * WebProcess/WebPage/ios/WebPageIOS.mm:
+ (WebKit::WebPage::applicationWillEnterForeground):
+
2019-03-13 Babak Shafiei <[email protected]>
Apply patch. rdar://problem/48839383
Modified: branches/safari-607-branch/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp (243096 => 243097)
--- branches/safari-607-branch/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp 2019-03-18 20:29:03 UTC (rev 243096)
+++ branches/safari-607-branch/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp 2019-03-18 20:56:41 UTC (rev 243097)
@@ -567,11 +567,11 @@
#endif
}
-void NetworkConnectionToWebProcess::removeStorageAccessForAllFramesOnPage(PAL::SessionID sessionID, uint64_t pageID)
+void NetworkConnectionToWebProcess::clearPageSpecificDataForResourceLoadStatistics(PAL::SessionID sessionID, uint64_t pageID)
{
#if ENABLE(RESOURCE_LOAD_STATISTICS)
if (auto* storageSession = NetworkStorageSession::storageSession(sessionID))
- storageSession->removeStorageAccessForAllFramesOnPage(pageID);
+ storageSession->clearPageSpecificDataForResourceLoadStatistics(pageID);
#else
UNUSED_PARAM(sessionID);
UNUSED_PARAM(pageID);
Modified: branches/safari-607-branch/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h (243096 => 243097)
--- branches/safari-607-branch/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h 2019-03-18 20:29:03 UTC (rev 243096)
+++ branches/safari-607-branch/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h 2019-03-18 20:56:41 UTC (rev 243097)
@@ -191,7 +191,7 @@
CacheStorageEngineConnection& cacheStorageConnection();
void removeStorageAccessForFrame(PAL::SessionID, uint64_t frameID, uint64_t pageID);
- void removeStorageAccessForAllFramesOnPage(PAL::SessionID, uint64_t pageID);
+ void clearPageSpecificDataForResourceLoadStatistics(PAL::SessionID, uint64_t pageID);
void addOriginAccessWhitelistEntry(const String& sourceOrigin, const String& destinationProtocol, const String& destinationHost, bool allowDestinationSubdomains);
void removeOriginAccessWhitelistEntry(const String& sourceOrigin, const String& destinationProtocol, const String& destinationHost, bool allowDestinationSubdomains);
Modified: branches/safari-607-branch/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in (243096 => 243097)
--- branches/safari-607-branch/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in 2019-03-18 20:29:03 UTC (rev 243096)
+++ branches/safari-607-branch/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in 2019-03-18 20:56:41 UTC (rev 243097)
@@ -57,7 +57,7 @@
EnsureLegacyPrivateBrowsingSession()
RemoveStorageAccessForFrame(PAL::SessionID sessionID, uint64_t frameID, uint64_t pageID);
- RemoveStorageAccessForAllFramesOnPage(PAL::SessionID sessionID, uint64_t pageID);
+ ClearPageSpecificDataForResourceLoadStatistics(PAL::SessionID sessionID, uint64_t pageID);
AddOriginAccessWhitelistEntry(String sourceOrigin, String destinationProtocol, String destinationHost, bool allowDestinationSubdomains);
RemoveOriginAccessWhitelistEntry(String sourceOrigin, String destinationProtocol, String destinationHost, bool allowDestinationSubdomains);
Modified: branches/safari-607-branch/Source/WebKit/NetworkProcess/NetworkProcess.cpp (243096 => 243097)
--- branches/safari-607-branch/Source/WebKit/NetworkProcess/NetworkProcess.cpp 2019-03-18 20:29:03 UTC (rev 243096)
+++ branches/safari-607-branch/Source/WebKit/NetworkProcess/NetworkProcess.cpp 2019-03-18 20:56:41 UTC (rev 243097)
@@ -555,6 +555,23 @@
ASSERT_NOT_REACHED();
parentProcessConnection()->send(Messages::NetworkProcessProxy::DidResetCacheMaxAgeCapForPrevalentResources(contextId), 0);
}
+
+void NetworkProcess::committedCrossSiteLoadWithLinkDecoration(PAL::SessionID sessionID, const String& fromRegistrableDomain, const String& toRegistrableDomain, uint64_t pageID)
+{
+ if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID))
+ networkStorageSession->committedCrossSiteLoadWithLinkDecoration(fromRegistrableDomain, toRegistrableDomain, pageID);
+ else
+ ASSERT_NOT_REACHED();
+}
+
+void NetworkProcess::resetCrossSiteLoadsWithLinkDecorationForTesting(PAL::SessionID sessionID, CompletionHandler<void()>&& completionHandler)
+{
+ if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID))
+ networkStorageSession->resetCrossSiteLoadsWithLinkDecorationForTesting();
+ else
+ ASSERT_NOT_REACHED();
+ completionHandler();
+}
#endif // ENABLE(RESOURCE_LOAD_STATISTICS)
bool NetworkProcess::sessionIsControlledByAutomation(PAL::SessionID sessionID) const
Modified: branches/safari-607-branch/Source/WebKit/NetworkProcess/NetworkProcess.h (243096 => 243097)
--- branches/safari-607-branch/Source/WebKit/NetworkProcess/NetworkProcess.h 2019-03-18 20:29:03 UTC (rev 243096)
+++ branches/safari-607-branch/Source/WebKit/NetworkProcess/NetworkProcess.h 2019-03-18 20:56:41 UTC (rev 243097)
@@ -162,6 +162,8 @@
void removePrevalentDomains(PAL::SessionID, const Vector<String>& domains);
void setCacheMaxAgeCapForPrevalentResources(PAL::SessionID, Seconds, uint64_t contextId);
void resetCacheMaxAgeCapForPrevalentResources(PAL::SessionID, uint64_t contextId);
+ void committedCrossSiteLoadWithLinkDecoration(PAL::SessionID, const String& fromRegistrableDomain, const String& toRegistrableDomain, uint64_t pageID);
+ void resetCrossSiteLoadsWithLinkDecorationForTesting(PAL::SessionID, CompletionHandler<void()>&&);
#endif
using CacheStorageParametersCallback = CompletionHandler<void(const String&, uint64_t quota)>;
Modified: branches/safari-607-branch/Source/WebKit/NetworkProcess/NetworkProcess.messages.in (243096 => 243097)
--- branches/safari-607-branch/Source/WebKit/NetworkProcess/NetworkProcess.messages.in 2019-03-18 20:29:03 UTC (rev 243096)
+++ branches/safari-607-branch/Source/WebKit/NetworkProcess/NetworkProcess.messages.in 2019-03-18 20:56:41 UTC (rev 243097)
@@ -94,6 +94,8 @@
RemovePrevalentDomains(PAL::SessionID sessionID, Vector<String> domainsWithInteraction)
SetCacheMaxAgeCapForPrevalentResources(PAL::SessionID sessionID, Seconds seconds, uint64_t contextId)
ResetCacheMaxAgeCapForPrevalentResources(PAL::SessionID sessionID, uint64_t contextId)
+ CommittedCrossSiteLoadWithLinkDecoration(PAL::SessionID sessionID, String fromRegistrableDomain, String toRegistrableDomain, uint64_t pageID)
+ ResetCrossSiteLoadsWithLinkDecorationForTesting(PAL::SessionID sessionID) -> () Async
#endif
SetSessionIsControlledByAutomation(PAL::SessionID sessionID, bool controlled);
Modified: branches/safari-607-branch/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp (243096 => 243097)
--- branches/safari-607-branch/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp 2019-03-18 20:29:03 UTC (rev 243096)
+++ branches/safari-607-branch/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp 2019-03-18 20:56:41 UTC (rev 243097)
@@ -482,6 +482,7 @@
auto& store = WebKit::toImpl(dataStoreRef)->websiteDataStore();
store.clearResourceLoadStatisticsInWebProcesses([callbackAggregator = callbackAggregator.copyRef()] { });
store.resetCacheMaxAgeCapForPrevalentResources([callbackAggregator = callbackAggregator.copyRef()] { });
+ store.resetCrossSiteLoadsWithLinkDecorationForTesting([callbackAggregator = callbackAggregator.copyRef()] { });
auto* statisticsStore = store.resourceLoadStatistics();
if (!statisticsStore)
Modified: branches/safari-607-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp (243096 => 243097)
--- branches/safari-607-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp 2019-03-18 20:29:03 UTC (rev 243096)
+++ branches/safari-607-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp 2019-03-18 20:56:41 UTC (rev 243097)
@@ -531,6 +531,16 @@
auto completionHandler = m_updateRuntimeSettingsCallbackMap.take(contextId);
completionHandler();
}
+
+void NetworkProcessProxy::resetCrossSiteLoadsWithLinkDecorationForTesting(PAL::SessionID sessionID, CompletionHandler<void()>&& completionHandler)
+{
+ if (!canSendMessage()) {
+ completionHandler();
+ return;
+ }
+
+ sendWithAsyncReply(Messages::NetworkProcess::ResetCrossSiteLoadsWithLinkDecorationForTesting(sessionID), WTFMove(completionHandler));
+}
#endif // ENABLE(RESOURCE_LOAD_STATISTICS)
void NetworkProcessProxy::sendProcessWillSuspendImminently()
Modified: branches/safari-607-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h (243096 => 243097)
--- branches/safari-607-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h 2019-03-18 20:29:03 UTC (rev 243096)
+++ branches/safari-607-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h 2019-03-18 20:56:41 UTC (rev 243097)
@@ -85,6 +85,7 @@
void removeAllStorageAccess(PAL::SessionID, CompletionHandler<void()>&&);
void setCacheMaxAgeCapForPrevalentResources(PAL::SessionID, Seconds, CompletionHandler<void()>&&);
void resetCacheMaxAgeCapForPrevalentResources(PAL::SessionID, CompletionHandler<void()>&&);
+ void resetCrossSiteLoadsWithLinkDecorationForTesting(PAL::SessionID, CompletionHandler<void()>&&);
#endif
void writeBlobToFilePath(const URL&, const String& path, CompletionHandler<void(bool)>&&);
Modified: branches/safari-607-branch/Source/WebKit/UIProcess/ResourceLoadStatisticsMemoryStore.cpp (243096 => 243097)
--- branches/safari-607-branch/Source/WebKit/UIProcess/ResourceLoadStatisticsMemoryStore.cpp 2019-03-18 20:29:03 UTC (rev 243096)
+++ branches/safari-607-branch/Source/WebKit/UIProcess/ResourceLoadStatisticsMemoryStore.cpp 2019-03-18 20:56:41 UTC (rev 243097)
@@ -1290,8 +1290,6 @@
ASSERT(!RunLoop::isMain());
updateCookieBlocking([]() { });
- updateCacheMaxAgeCap();
- updateClientSideCookiesAgeCap();
}
} // namespace WebKit
Modified: branches/safari-607-branch/Source/WebKit/UIProcess/WebPageProxy.cpp (243096 => 243097)
--- branches/safari-607-branch/Source/WebKit/UIProcess/WebPageProxy.cpp 2019-03-18 20:29:03 UTC (rev 243096)
+++ branches/safari-607-branch/Source/WebKit/UIProcess/WebPageProxy.cpp 2019-03-18 20:56:41 UTC (rev 243097)
@@ -4027,6 +4027,13 @@
}
}
+#if ENABLE(RESOURCE_LOAD_STATISTICS)
+static bool isNonUniqueNavigationWithLinkDecoration(const SecurityOriginData requesterOrigin, const URL& currentURL)
+{
+ return !requesterOrigin.securityOrigin()->isUnique() && (!currentURL.query().isEmpty() || !currentURL.fragmentIdentifier().isEmpty());
+}
+#endif
+
void WebPageProxy::didCommitLoadForFrame(uint64_t frameID, uint64_t navigationID, const String& mimeType, bool frameHasCustomContentProvider, uint32_t opaqueFrameLoadType, const WebCore::CertificateInfo& certificateInfo, bool containsPluginDocument, Optional<HasInsecureContent> hasInsecureContent, const UserData& userData)
{
LOG(Loading, "(Loading) WebPageProxy %" PRIu64 " didCommitLoadForFrame in navigation %" PRIu64, m_pageID, m_navigationID);
@@ -4040,8 +4047,19 @@
// FIXME: We should message check that navigationID is not zero here, but it's currently zero for some navigations through the page cache.
RefPtr<API::Navigation> navigation;
- if (frame->isMainFrame() && navigationID)
+ if (frame->isMainFrame() && navigationID) {
navigation = navigationState().navigation(navigationID);
+#if ENABLE(RESOURCE_LOAD_STATISTICS)
+ auto requesterOrigin = navigation->lastNavigationAction().requesterOrigin;
+ auto currentURL = navigation->currentRequest().url();
+ if (isNonUniqueNavigationWithLinkDecoration(requesterOrigin, currentURL)) {
+ String fromRegistrableDomain = WebCore::topPrivatelyControlledDomain(requesterOrigin.host);
+ String toRegistrableDomain = WebCore::topPrivatelyControlledDomain(currentURL.host().toString());
+ if (fromRegistrableDomain != toRegistrableDomain)
+ m_process->processPool().sendToNetworkingProcess(Messages::NetworkProcess::CommittedCrossSiteLoadWithLinkDecoration(m_websiteDataStore->sessionID(), fromRegistrableDomain, toRegistrableDomain, m_pageID));
+ }
+ #endif
+ }
m_hasCommittedAnyProvisionalLoads = true;
m_process->didCommitProvisionalLoad();
Modified: branches/safari-607-branch/Source/WebKit/UIProcess/WebProcessPool.cpp (243096 => 243097)
--- branches/safari-607-branch/Source/WebKit/UIProcess/WebProcessPool.cpp 2019-03-18 20:29:03 UTC (rev 243096)
+++ branches/safari-607-branch/Source/WebKit/UIProcess/WebProcessPool.cpp 2019-03-18 20:56:41 UTC (rev 243097)
@@ -596,6 +596,8 @@
if (m_websiteDataStore)
m_websiteDataStore->websiteDataStore().didCreateNetworkProcess();
+ else if (withWebsiteDataStore)
+ withWebsiteDataStore->didCreateNetworkProcess();
return *m_networkProcess;
}
Modified: branches/safari-607-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp (243096 => 243097)
--- branches/safari-607-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp 2019-03-18 20:29:03 UTC (rev 243096)
+++ branches/safari-607-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp 2019-03-18 20:56:41 UTC (rev 243097)
@@ -1371,6 +1371,16 @@
m_resourceLoadStatistics->grantStorageAccess(WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, userWasPrompted, WTFMove(completionHandler));
}
+
+void WebsiteDataStore::resetCrossSiteLoadsWithLinkDecorationForTesting(CompletionHandler<void()>&& completionHandler)
+{
+ auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
+
+ for (auto& processPool : processPools()) {
+ if (auto* networkProcess = processPool->networkProcess())
+ networkProcess->resetCrossSiteLoadsWithLinkDecorationForTesting(m_sessionID, [callbackAggregator = callbackAggregator.copyRef()] { });
+ }
+}
#endif // ENABLE(RESOURCE_LOAD_STATISTICS)
void WebsiteDataStore::setCacheMaxAgeCapForPrevalentResources(Seconds seconds, CompletionHandler<void()>&& completionHandler)
Modified: branches/safari-607-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h (243096 => 243097)
--- branches/safari-607-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h 2019-03-18 20:29:03 UTC (rev 243096)
+++ branches/safari-607-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h 2019-03-18 20:56:41 UTC (rev 243097)
@@ -126,6 +126,7 @@
void hasStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&&);
void requestStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(StorageAccessStatus)>&&);
void grantStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool userWasPrompted, CompletionHandler<void(bool)>&&);
+ void resetCrossSiteLoadsWithLinkDecorationForTesting(CompletionHandler<void()>&&);
#endif
void setCacheMaxAgeCapForPrevalentResources(Seconds, CompletionHandler<void()>&&);
void resetCacheMaxAgeCapForPrevalentResources(CompletionHandler<void()>&&);
Modified: branches/safari-607-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp (243096 => 243097)
--- branches/safari-607-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2019-03-18 20:29:03 UTC (rev 243096)
+++ branches/safari-607-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2019-03-18 20:56:41 UTC (rev 243097)
@@ -1208,7 +1208,7 @@
if (m_isClosed)
return;
- WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::RemoveStorageAccessForAllFramesOnPage(sessionID(), m_pageID), 0);
+ WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::ClearPageSpecificDataForResourceLoadStatistics(sessionID(), m_pageID), 0);
m_isClosed = true;