| Differences between
and this patch
- a/Source/WebCore/ChangeLog +14 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2022-02-24  Youenn Fablet  <youenn@apple.com>
2
3
        Non-simple CORS preflight fails due to cache-control header
4
        https://bugs.webkit.org/show_bug.cgi?id=236837
5
        <rdar://problem/89382796>
6
7
        Reviewed by NOBODY (OOPS!).
8
9
        We fixed cache-control in https://bugs.webkit.org/show_bug.cgi?id=233916.
10
        The fix to make the website work is to ensure that Content-Type is not cleared when going to service worker.
11
        Covered by updated tests.
12
13
        * Modules/beacon/NavigatorBeacon.cpp:
14
1
2022-02-24  Youenn Fablet  <youenn@apple.com>
15
2022-02-24  Youenn Fablet  <youenn@apple.com>
2
16
3
        Optimize black frame sending in MediaRecorderPrivate
17
        Optimize black frame sending in MediaRecorderPrivate
- a/Source/WebCore/Modules/beacon/NavigatorBeacon.cpp -1 / +3 lines
Lines 145-152 ExceptionOr<bool> NavigatorBeacon::sendBeacon(Document& document, const String& a/Source/WebCore/Modules/beacon/NavigatorBeacon.cpp_sec1
145
        request.setHTTPBody(fetchBody.bodyAsFormData());
145
        request.setHTTPBody(fetchBody.bodyAsFormData());
146
        if (!mimeType.isEmpty()) {
146
        if (!mimeType.isEmpty()) {
147
            request.setHTTPContentType(mimeType);
147
            request.setHTTPContentType(mimeType);
148
            if (!isCrossOriginSafeRequestHeader(HTTPHeaderName::ContentType, mimeType))
148
            if (!isCrossOriginSafeRequestHeader(HTTPHeaderName::ContentType, mimeType)) {
149
                options.mode = FetchOptions::Mode::Cors;
149
                options.mode = FetchOptions::Mode::Cors;
150
                options.httpHeadersToKeep.add(HTTPHeadersToKeepFromCleaning::ContentType);
151
            }
150
        }
152
        }
151
    }
153
    }
152
154
- a/LayoutTests/ChangeLog +12 lines
Lines 1-3 a/LayoutTests/ChangeLog_sec1
1
2022-02-24  Youenn Fablet  <youenn@apple.com>
2
3
        Non-simple CORS preflight fails due to cache-control header
4
        https://bugs.webkit.org/show_bug.cgi?id=236837
5
        <rdar://problem/89382796>
6
7
        Reviewed by NOBODY (OOPS!).
8
9
        * http/wpt/service-workers/cache-control-request-expected.txt:
10
        * http/wpt/service-workers/cache-control-request.html:
11
        * http/wpt/service-workers/resources/cross-origin-allow-for-beacon.py: Added.
12
1
2022-02-24  Youenn Fablet  <youenn@apple.com>
13
2022-02-24  Youenn Fablet  <youenn@apple.com>
2
14
3
        webrtc/video-replace-muted-track.html is unnecessary long to run
15
        webrtc/video-replace-muted-track.html is unnecessary long to run
- a/LayoutTests/http/wpt/service-workers/cache-control-request-expected.txt +1 lines
Lines 1-4 a/LayoutTests/http/wpt/service-workers/cache-control-request-expected.txt_sec1
1
1
2
PASS Setup worker
2
PASS Setup worker
3
PASS Ensure cache-control does not break service worker fetch handling
3
PASS Ensure cache-control does not break service worker fetch handling
4
PASS Ensure beacon headers are not broken by service worker fetch handling
4
5
- a/LayoutTests/http/wpt/service-workers/cache-control-request.html +16 lines
Lines 5-10 a/LayoutTests/http/wpt/service-workers/cache-control-request.html_sec1
5
<script src="/resources/testharnessreport.js"></script>
5
<script src="/resources/testharnessreport.js"></script>
6
<script src="/service-workers/service-worker/resources/test-helpers.sub.js"></script>
6
<script src="/service-workers/service-worker/resources/test-helpers.sub.js"></script>
7
<script src="/common/get-host-info.sub.js"></script>
7
<script src="/common/get-host-info.sub.js"></script>
8
<script src="/common/utils.js"></script>
8
</head>
9
</head>
9
<body>
10
<body>
10
<script>
11
<script>
Lines 33-38 promise_test(async (test) => { a/LayoutTests/http/wpt/service-workers/cache-control-request.html_sec2
33
    assert_not_equals(await response.text(), "no cache-control header");
34
    assert_not_equals(await response.text(), "no cache-control header");
34
    iframe.remove();
35
    iframe.remove();
35
}, "Ensure cache-control does not break service worker fetch handling");
36
}, "Ensure cache-control does not break service worker fetch handling");
37
38
promise_test(async (test) => {
39
    const iframe = await with_iframe("resources/empty.html");
40
41
    const id = token();
42
    const blob = new Blob(["test"], { type: "application/badabaoo" });
43
44
    iframe.contentWindow.navigator.sendBeacon(get_host_info().HTTP_REMOTE_ORIGIN +  "/WebKit/service-workers/resources/cross-origin-allow-for-beacon.py?token=" + id, blob);
45
    await new Promise(resolve => setTimeout(resolve, 50));
46
47
    const response = await fetch("/WebKit/service-workers/resources/cross-origin-allow-for-beacon.py?token=" + id);
48
    assert_equals(await response.text(), "preflight ok");
49
50
    iframe.remove();
51
}, "Ensure beacon headers are not broken by service worker fetch handling");
36
</script>
52
</script>
37
</body>
53
</body>
38
</html>
54
</html>
- a/LayoutTests/http/wpt/service-workers/resources/cross-origin-allow-for-beacon.py +15 lines
Line 0 a/LayoutTests/http/wpt/service-workers/resources/cross-origin-allow-for-beacon.py_sec1
1
def main(request, response):
2
    token = request.GET.first(b"token", None)
3
    if request.method == u'OPTIONS':
4
        headers = request.headers.get("Access-Control-Request-Headers", "none")
5
        if "cache-control" in str(headers):
6
            request.server.stash.put(token, "preflight ko, got cache-control")
7
            return 404, [(b"Cache-Control", b"no-store")], u"cache-control in preflight"
8
        if "content-type" not in str(headers):
9
            request.server.stash.put(token, "preflight ko got content-type")
10
            return 404, [(b"Cache-Control", b"no-store")], u"content-type not in preflight"
11
        request.server.stash.put(token, "preflight ok")
12
        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"
13
    if request.method == u'GET':
14
        return 200, [(b"Content-Type", b"text/ascii")], request.server.stash.take(token)
15
    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"

Return to Bug 236837