WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-236837-20220224144345.patch (text/plain), 6.42 KB, created by
youenn fablet
on 2022-02-24 05:43:47 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
youenn fablet
Created:
2022-02-24 05:43:47 PST
Size:
6.42 KB
patch
obsolete
>Subversion Revision: 290426 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index e5d749dbe478019803bffd35a64d0757e5319882..4e09b800e702060598b0f8947cd6ea30c021958b 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,17 @@ >+2022-02-24 Youenn Fablet <youenn@apple.com> >+ >+ Non-simple CORS preflight fails due to cache-control header >+ https://bugs.webkit.org/show_bug.cgi?id=236837 >+ <rdar://problem/89382796> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ We fixed cache-control in https://bugs.webkit.org/show_bug.cgi?id=233916. >+ The fix to make the website work is to ensure that Content-Type is not cleared when going to service worker. >+ Covered by updated tests. >+ >+ * Modules/beacon/NavigatorBeacon.cpp: >+ > 2022-02-24 Youenn Fablet <youenn@apple.com> > > Optimize black frame sending in MediaRecorderPrivate >diff --git a/Source/WebCore/Modules/beacon/NavigatorBeacon.cpp b/Source/WebCore/Modules/beacon/NavigatorBeacon.cpp >index de5c81f9a7a9d6696a21290c379e4c8ac956b931..eea828b4c9a5222a17d34de39bc75ded2d18ddca 100644 >--- a/Source/WebCore/Modules/beacon/NavigatorBeacon.cpp >+++ b/Source/WebCore/Modules/beacon/NavigatorBeacon.cpp >@@ -145,8 +145,10 @@ ExceptionOr<bool> NavigatorBeacon::sendBeacon(Document& document, const String& > request.setHTTPBody(fetchBody.bodyAsFormData()); > if (!mimeType.isEmpty()) { > request.setHTTPContentType(mimeType); >- if (!isCrossOriginSafeRequestHeader(HTTPHeaderName::ContentType, mimeType)) >+ if (!isCrossOriginSafeRequestHeader(HTTPHeaderName::ContentType, mimeType)) { > options.mode = FetchOptions::Mode::Cors; >+ options.httpHeadersToKeep.add(HTTPHeadersToKeepFromCleaning::ContentType); >+ } > } > } > >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 27e10d2638d00f5a6cf1cf79f28682f3ff10b6b8..8fabb29dfc06dbc7b7ef7bcfb68889385d39dfbb 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,15 @@ >+2022-02-24 Youenn Fablet <youenn@apple.com> >+ >+ Non-simple CORS preflight fails due to cache-control header >+ https://bugs.webkit.org/show_bug.cgi?id=236837 >+ <rdar://problem/89382796> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * http/wpt/service-workers/cache-control-request-expected.txt: >+ * http/wpt/service-workers/cache-control-request.html: >+ * http/wpt/service-workers/resources/cross-origin-allow-for-beacon.py: Added. >+ > 2022-02-24 Youenn Fablet <youenn@apple.com> > > webrtc/video-replace-muted-track.html is unnecessary long to run >diff --git a/LayoutTests/http/wpt/service-workers/cache-control-request-expected.txt b/LayoutTests/http/wpt/service-workers/cache-control-request-expected.txt >index 6fb80f773026ed46f48b235c64c65d351ef48f4a..e06c504bcfcb16791e931ea190c1154c4e3eeebb 100644 >--- a/LayoutTests/http/wpt/service-workers/cache-control-request-expected.txt >+++ b/LayoutTests/http/wpt/service-workers/cache-control-request-expected.txt >@@ -1,4 +1,5 @@ > > PASS Setup worker > PASS Ensure cache-control does not break service worker fetch handling >+PASS Ensure beacon headers are not broken by service worker fetch handling > >diff --git a/LayoutTests/http/wpt/service-workers/cache-control-request.html b/LayoutTests/http/wpt/service-workers/cache-control-request.html >index 73e4bfd1e9c33946cf63a7bdb89c73a5ae9b5869..a5ccafb8a6cde1c35e2f06dcc39864749dba4005 100644 >--- a/LayoutTests/http/wpt/service-workers/cache-control-request.html >+++ b/LayoutTests/http/wpt/service-workers/cache-control-request.html >@@ -5,6 +5,7 @@ > <script src="/resources/testharnessreport.js"></script> > <script src="/service-workers/service-worker/resources/test-helpers.sub.js"></script> > <script src="/common/get-host-info.sub.js"></script> >+<script src="/common/utils.js"></script> > </head> > <body> > <script> >@@ -33,6 +34,21 @@ promise_test(async (test) => { > assert_not_equals(await response.text(), "no cache-control header"); > iframe.remove(); > }, "Ensure cache-control does not break service worker fetch handling"); >+ >+promise_test(async (test) => { >+ const iframe = await with_iframe("resources/empty.html"); >+ >+ const id = token(); >+ const blob = new Blob(["test"], { type: "application/badabaoo" }); >+ >+ iframe.contentWindow.navigator.sendBeacon(get_host_info().HTTP_REMOTE_ORIGIN + "/WebKit/service-workers/resources/cross-origin-allow-for-beacon.py?token=" + id, blob); >+ await new Promise(resolve => setTimeout(resolve, 50)); >+ >+ const response = await fetch("/WebKit/service-workers/resources/cross-origin-allow-for-beacon.py?token=" + id); >+ assert_equals(await response.text(), "preflight ok"); >+ >+ iframe.remove(); >+}, "Ensure beacon headers are not broken by service worker fetch handling"); > </script> > </body> > </html> >diff --git a/LayoutTests/http/wpt/service-workers/resources/cross-origin-allow-for-beacon.py b/LayoutTests/http/wpt/service-workers/resources/cross-origin-allow-for-beacon.py >new file mode 100644 >index 0000000000000000000000000000000000000000..1d7fa10d36912afe44b93c21a29aa5a941df18ca >--- /dev/null >+++ b/LayoutTests/http/wpt/service-workers/resources/cross-origin-allow-for-beacon.py >@@ -0,0 +1,15 @@ >+def main(request, response): >+ token = request.GET.first(b"token", None) >+ if request.method == u'OPTIONS': >+ headers = request.headers.get("Access-Control-Request-Headers", "none") >+ if "cache-control" in str(headers): >+ request.server.stash.put(token, "preflight ko, got cache-control") >+ return 404, [(b"Cache-Control", b"no-store")], u"cache-control in preflight" >+ if "content-type" not in str(headers): >+ request.server.stash.put(token, "preflight ko got content-type") >+ return 404, [(b"Cache-Control", b"no-store")], u"content-type not in preflight" >+ request.server.stash.put(token, "preflight ok") >+ return 200, [(b"Cache-Control", b"no-store"), (b"Content-Type", b"text/ascii"), (b"Access-Control-Allow-Origin", b"http://localhost:8800"), (b"Access-Control-Allow-Credentials", b"true"), (b"Access-Control-Allow-Headers", b"content-type"), (b"Access-Control-Allow-Methods", b"*")], u"ok" >+ if request.method == u'GET': >+ return 200, [(b"Content-Type", b"text/ascii")], request.server.stash.take(token) >+ return 200, [(b"Content-Type", b"text/ascii"), (b"Access-Control-Allow-Origin", b"http://localhost:8800"), (b"Access-Control-Allow-Credentials", b"true")], u"post ok"
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 236837
:
453082
| 453096