WebKit Bugzilla
Attachment 347387 Details for
Bug 188706
: Resource Load Statistics: Add layout test for web workers importing cross-site scripts
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-188706-20180817133738.patch (text/plain), 8.16 KB, created by
John Wilander
on 2018-08-17 13:37:38 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
John Wilander
Created:
2018-08-17 13:37:38 PDT
Size:
8.16 KB
patch
obsolete
>Subversion Revision: 234860 >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index da4e8ed345ee2f1a5f690ae5b4914d99955e185d..9db869473820f7442d8b25012bc1a0805ae87084 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,18 @@ >+2018-08-17 John Wilander <wilander@apple.com> >+ >+ Resource Load Statistics: Add layout test for web workers importing cross-site scripts >+ https://bugs.webkit.org/show_bug.cgi?id=188706 >+ <rdar://problem/43437050> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * http/tests/resourceLoadStatistics/blocking-in-web-worker-script-import-expected.txt: Added. >+ * http/tests/resourceLoadStatistics/blocking-in-web-worker-script-import.html: Added. >+ * http/tests/resourceLoadStatistics/resources/iframe-report-back-loaded.html: >+ Fixed typo in URL. >+ * http/tests/resourceLoadStatistics/resources/script-revealing-cookies.php: Added. >+ * http/tests/resourceLoadStatistics/resources/worker-importing-localhost-script.js: Added. >+ > 2018-08-14 Yusuke Suzuki <yusukesuzuki@slowstart.org> > > Unhandled Promise Rejection logging in workers should not emit ErrorEvent to host Worker object >diff --git a/LayoutTests/http/tests/resourceLoadStatistics/blocking-in-web-worker-script-import-expected.txt b/LayoutTests/http/tests/resourceLoadStatistics/blocking-in-web-worker-script-import-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..9cb79943ed8b49a841bd129b3f5aca6e2a3b21bc >--- /dev/null >+++ b/LayoutTests/http/tests/resourceLoadStatistics/blocking-in-web-worker-script-import-expected.txt >@@ -0,0 +1,18 @@ >+Test for cookie blocking when web workers import cross-site scripts. >+ >+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". >+ >+ >+PASS Did receive firstPartyCookie == value >+PASS Did not receive cookie named firstPartyCookie >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+ >+ >+-------- >+Frame: '<!--frame1-->' >+-------- >+Should receive first-party cookie. >+Received cookie named 'firstPartyCookie'. >+Client-side document.cookie: firstPartyCookie=value >diff --git a/LayoutTests/http/tests/resourceLoadStatistics/blocking-in-web-worker-script-import.html b/LayoutTests/http/tests/resourceLoadStatistics/blocking-in-web-worker-script-import.html >new file mode 100644 >index 0000000000000000000000000000000000000000..ba016bad219990499a789f23c3301e24c73255d9 >--- /dev/null >+++ b/LayoutTests/http/tests/resourceLoadStatistics/blocking-in-web-worker-script-import.html >@@ -0,0 +1,87 @@ >+<!DOCTYPE html> >+<html lang="en"> >+<head> >+ <script src="/js-test-resources/js-test.js"></script> >+ <script src="resources/util.js"></script> >+</head> >+<body> >+<script> >+ description("Test for cookie blocking when web workers import cross-site scripts."); >+ jsTestIsAsync = true; >+ >+ const partitionHost = "127.0.0.1:8000"; >+ const thirdPartyOrigin = "http://localhost:8000"; >+ const thirdPartyBaseUrl = thirdPartyOrigin + "/resourceLoadStatistics/resources"; >+ const firstPartyCookieName = "firstPartyCookie"; >+ const subPathToSetFirstPartyCookie = "/set-cookie.php?name=" + firstPartyCookieName + "&value=value"; >+ const returnUrl = "http://127.0.0.1:8000/resourceLoadStatistics/blocking-in-web-worker-script-import.html"; >+ const subPathToGetCookies = "/get-cookies.php?name1=" + firstPartyCookieName; >+ >+ function openIframe(url, onLoadHandler) { >+ const element = document.createElement("iframe"); >+ element.src = url; >+ if (onLoadHandler) { >+ element.onload = onLoadHandler; >+ } >+ document.body.appendChild(element); >+ } >+ >+ let receivedMessages = 0; >+ function receiveMessage(event) { >+ if (event.data.indexOf("PASS") === -1) >+ testFailed(event.data.replace("FAIL ", "")); >+ else >+ testPassed(event.data.replace("PASS ", "")); >+ >+ ++receivedMessages; >+ if (receivedMessages >= 2) >+ setEnableFeature(false, finishJSTest); >+ else >+ runTest(); >+ } >+ >+ function runTest() { >+ switch (document.location.hash) { >+ case "#step1": >+ document.location.href = thirdPartyBaseUrl + subPathToSetFirstPartyCookie + "#" + returnUrl + "#step2"; >+ break; >+ case "#step2": >+ document.location.hash = "step3"; >+ openIframe(thirdPartyBaseUrl + subPathToGetCookies + "&message=Should receive first-party cookie.", runTest); >+ break; >+ case "#step3": >+ document.location.hash = "step4"; >+ let w1 = new Worker("resources/worker-importing-localhost-script.js"); >+ w1.onmessage = receiveMessage; >+ w1.postMessage("shouldReceiveCookies=true"); >+ break; >+ case "#step4": >+ document.location.hash = "step5"; >+ testRunner.setStatisticsPrevalentResource(thirdPartyOrigin, true, function() { >+ if (!testRunner.isStatisticsPrevalentResource(thirdPartyOrigin)) >+ testFailed("Host did not get set as prevalent resource."); >+ testRunner.statisticsUpdateCookieBlocking(runTest); >+ }); >+ break; >+ case "#step5": >+ let w2 = new Worker("resources/worker-importing-localhost-script.js"); >+ w2.onmessage = receiveMessage; >+ w2.postMessage("shouldNotReceiveCookies"); >+ break; >+ } >+ } >+ >+ if (document.location.host === partitionHost && document.location.hash === "" && window.testRunner && window.internals) { >+ setEnableFeature(true, function() { >+ document.location.hash = "step1"; >+ testRunner.dumpChildFramesAsText(); >+ if (testRunner.isStatisticsPrevalentResource(thirdPartyOrigin)) >+ testFailed("Localhost was classified as prevalent resource before the test starts."); >+ runTest(); >+ }); >+ } else { >+ runTest(); >+ } >+</script> >+</body> >+</html> >diff --git a/LayoutTests/http/tests/resourceLoadStatistics/resources/iframe-report-back-loaded.html b/LayoutTests/http/tests/resourceLoadStatistics/resources/iframe-report-back-loaded.html >index c83a60b6ace405d797fbf069627714093d2fde7d..75037464a89755f39ecc517a3d1abaf9b416689d 100644 >--- a/LayoutTests/http/tests/resourceLoadStatistics/resources/iframe-report-back-loaded.html >+++ b/LayoutTests/http/tests/resourceLoadStatistics/resources/iframe-report-back-loaded.html >@@ -5,7 +5,7 @@ > <body onload="reportBackLoadedToTopFrame()"> > <script> > function reportBackLoadedToTopFrame() { >- top.postMessage("PASS Frame loaded.", "http:127.0.0.1:8000"); >+ top.postMessage("PASS Frame loaded.", "http://127.0.0.1:8000"); > } > </script> > </body> >diff --git a/LayoutTests/http/tests/resourceLoadStatistics/resources/script-revealing-cookies.php b/LayoutTests/http/tests/resourceLoadStatistics/resources/script-revealing-cookies.php >new file mode 100644 >index 0000000000000000000000000000000000000000..c562e6d3360bccebd0f8445b4507c575e5416ac6 >--- /dev/null >+++ b/LayoutTests/http/tests/resourceLoadStatistics/resources/script-revealing-cookies.php >@@ -0,0 +1,9 @@ >+<?php >+$shouldReceiveCookies = $_GET["shouldReceiveCookies"]; >+if(isset($_COOKIE["firstPartyCookie"])) { >+ echo "let cookieResult = '". ($shouldReceiveCookies ? "PASS " : "FAIL ") . "Did receive firstPartyCookie == " . $_COOKIE["firstPartyCookie"] . "';"; >+} else { >+ echo "let cookieResult = '". ($shouldReceiveCookies ? "FAIL " : "PASS ") . "Did not receive cookie named firstPartyCookie';"; >+} >+?> >+postMessage(cookieResult); >diff --git a/LayoutTests/http/tests/resourceLoadStatistics/resources/worker-importing-localhost-script.js b/LayoutTests/http/tests/resourceLoadStatistics/resources/worker-importing-localhost-script.js >new file mode 100644 >index 0000000000000000000000000000000000000000..657bd47861a675a42be38b1bd2a75811d258f7e2 >--- /dev/null >+++ b/LayoutTests/http/tests/resourceLoadStatistics/resources/worker-importing-localhost-script.js >@@ -0,0 +1,3 @@ >+onmessage = function(e) { >+ importScripts("//localhost:8000/resourceLoadStatistics/resources/script-revealing-cookies.php?" + e.data); >+};
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 188706
: 347387