Title: [281158] trunk
- Revision
- 281158
- Author
- [email protected]
- Date
- 2021-08-17 12:57:50 -0700 (Tue, 17 Aug 2021)
Log Message
[curl] Kept alive NetworkResourceLoaders should be cancelled by NetworkLoad::didCompleteWithError on PolicyAction::Ignore of didReceiveResponse
https://bugs.webkit.org/show_bug.cgi?id=228095
<rdar://problem/81393898>
Reviewed by Don Olmstead.
Source/WebKit:
If a page dispatches a keepalive fetch and the page is navigated
away, the alive NetworkResourceLoader is transferred to the
NetworkSession by NetworkConnectionToWebProcess::transferKeptAliveLoad.
After the NetworkResourceLoader receives a response, it is canceled
by PolicyAction::Ignore.
However, NetworkDataTaskCurl didn't properly cancel the kept alive
NetworkResourceLoader. They remained in m_keptAliveLoads of
NetworkSession even after the requests were canceled.
Test: http/tests/fetch/keepalive-fetch-2.html
* NetworkProcess/curl/NetworkDataTaskCurl.cpp:
(WebKit::NetworkDataTaskCurl::invokeDidReceiveResponse): Call didCompleteWithError on PolicyAction::Ignore.
LayoutTests:
* http/tests/fetch/keepalive-fetch-2-expected.txt: Added.
* http/tests/fetch/keepalive-fetch-2.html: Added.
* http/tests/fetch/resources/get-set-temp-file.py: Added.
* http/tests/fetch/resources/keepalive-fetch-2-window.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (281157 => 281158)
--- trunk/LayoutTests/ChangeLog 2021-08-17 19:34:28 UTC (rev 281157)
+++ trunk/LayoutTests/ChangeLog 2021-08-17 19:57:50 UTC (rev 281158)
@@ -1,3 +1,16 @@
+2021-08-17 Fujii Hironori <[email protected]>
+
+ [curl] Kept alive NetworkResourceLoaders should be cancelled by NetworkLoad::didCompleteWithError on PolicyAction::Ignore of didReceiveResponse
+ https://bugs.webkit.org/show_bug.cgi?id=228095
+ <rdar://problem/81393898>
+
+ Reviewed by Don Olmstead.
+
+ * http/tests/fetch/keepalive-fetch-2-expected.txt: Added.
+ * http/tests/fetch/keepalive-fetch-2.html: Added.
+ * http/tests/fetch/resources/get-set-temp-file.py: Added.
+ * http/tests/fetch/resources/keepalive-fetch-2-window.html: Added.
+
2021-08-17 Mikhail R. Gadelha <[email protected]>
Unreviewed. Skip failing MIPS tests
Added: trunk/LayoutTests/http/tests/fetch/keepalive-fetch-2-expected.txt (0 => 281158)
--- trunk/LayoutTests/http/tests/fetch/keepalive-fetch-2-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/fetch/keepalive-fetch-2-expected.txt 2021-08-17 19:57:50 UTC (rev 281158)
@@ -0,0 +1,3 @@
+
+PASS keepalive fetches for delayed resources
+
Added: trunk/LayoutTests/http/tests/fetch/keepalive-fetch-2.html (0 => 281158)
--- trunk/LayoutTests/http/tests/fetch/keepalive-fetch-2.html (rev 0)
+++ trunk/LayoutTests/http/tests/fetch/keepalive-fetch-2.html 2021-08-17 19:57:50 UTC (rev 281158)
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<title>keepalive fetches</title>
+<script src=""
+<script src=""
+<script>
+ promise_test(async () => {
+ // Clear
+ let id = Math.random().toString();
+ let suffixes = Array.from(Array(5).keys());
+ await Promise.all(suffixes.map((i) => {
+ let filename = `keepalive-fetch-2.${id}.${i}.txt`;
+ return fetch('resources/get-set-temp-file.py?cmd=clear&filename=' + filename);
+ }));
+ // Set
+ let w1 = open('resources/keepalive-fetch-2-window.html#' + id);
+ await new Promise(resolve => w1._onload_ = resolve);
+ w1.location = '/';
+ await new Promise(resolve => setTimeout(resolve, 3000));
+ // Get
+ let texts = await Promise.all(suffixes.map(async (i) => {
+ let filename = `keepalive-fetch-2.${id}.${i}.txt`;
+ let response = await fetch('resources/get-set-temp-file.py?cmd=get&filename=' + filename);
+ return await response.text();
+ }));
+ // Clear
+ await Promise.all(suffixes.map((i) => {
+ let filename = `keepalive-fetch-2.${id}.${i}.txt`;
+ return fetch('resources/get-set-temp-file.py?cmd=clear&filename=' + filename);
+ }));
+ // Test
+ texts.map((text) => assert_equals(text, id));
+ }, "keepalive fetches for delayed resources");
+</script>
Added: trunk/LayoutTests/http/tests/fetch/resources/get-set-temp-file.py (0 => 281158)
--- trunk/LayoutTests/http/tests/fetch/resources/get-set-temp-file.py (rev 0)
+++ trunk/LayoutTests/http/tests/fetch/resources/get-set-temp-file.py 2021-08-17 19:57:50 UTC (rev 281158)
@@ -0,0 +1,35 @@
+#!/usr/bin/env python3
+
+import os
+import sys
+import tempfile
+import time
+from urllib.parse import parse_qs
+
+query = parse_qs(os.environ.get('QUERY_STRING', ''), keep_blank_values=True)
+cmd = query.get('cmd', [None])[0]
+filename = query.get('filename', [None])[0]
+data = "" [''])[0]
+delay = int(query.get('delay', ['0'])[0])
+
+time.sleep(delay / 1000.0)
+
+tmp_file = os.path.join(tempfile.gettempdir(), os.path.basename(filename))
+
+sys.stdout.write('Content-Type: text/plain\r\n\r\n')
+
+if cmd == 'get':
+ with open(tmp_file, 'r') as open_file:
+ sys.stdout.write(open_file.read())
+elif cmd == 'set':
+ with open(tmp_file, 'w') as open_file:
+ open_file.write(data)
+ sys.stdout.write('Set {}\r\n'.format(tmp_file))
+elif cmd == 'clear':
+ if os.path.exists(tmp_file):
+ os.remove(tmp_file)
+ sys.stdout.write('Deleted {}\r\n'.format(tmp_file))
+ else:
+ sys.stdout.write('No such file: {}\r\n'.format(tmp_file))
+else:
+ sys.stdout.write('Unknown command\r\n')
Added: trunk/LayoutTests/http/tests/fetch/resources/keepalive-fetch-2-window.html (0 => 281158)
--- trunk/LayoutTests/http/tests/fetch/resources/keepalive-fetch-2-window.html (rev 0)
+++ trunk/LayoutTests/http/tests/fetch/resources/keepalive-fetch-2-window.html 2021-08-17 19:57:50 UTC (rev 281158)
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<script>
+ var id = location.hash.substring(1);
+ let suffixes = Array.from(Array(5).keys());
+ suffixes.map((i) => {
+ let filename = `keepalive-fetch-2.${id}.${i}.txt`;
+ fetch(`get-set-temp-file.py?cmd=set&delay=1000&filename=${filename}&data="" { keepalive: true });
+ });
+</script>
Modified: trunk/Source/WebKit/ChangeLog (281157 => 281158)
--- trunk/Source/WebKit/ChangeLog 2021-08-17 19:34:28 UTC (rev 281157)
+++ trunk/Source/WebKit/ChangeLog 2021-08-17 19:57:50 UTC (rev 281158)
@@ -1,3 +1,26 @@
+2021-08-17 Fujii Hironori <[email protected]>
+
+ [curl] Kept alive NetworkResourceLoaders should be cancelled by NetworkLoad::didCompleteWithError on PolicyAction::Ignore of didReceiveResponse
+ https://bugs.webkit.org/show_bug.cgi?id=228095
+ <rdar://problem/81393898>
+
+ Reviewed by Don Olmstead.
+
+ If a page dispatches a keepalive fetch and the page is navigated
+ away, the alive NetworkResourceLoader is transferred to the
+ NetworkSession by NetworkConnectionToWebProcess::transferKeptAliveLoad.
+ After the NetworkResourceLoader receives a response, it is canceled
+ by PolicyAction::Ignore.
+
+ However, NetworkDataTaskCurl didn't properly cancel the kept alive
+ NetworkResourceLoader. They remained in m_keptAliveLoads of
+ NetworkSession even after the requests were canceled.
+
+ Test: http/tests/fetch/keepalive-fetch-2.html
+
+ * NetworkProcess/curl/NetworkDataTaskCurl.cpp:
+ (WebKit::NetworkDataTaskCurl::invokeDidReceiveResponse): Call didCompleteWithError on PolicyAction::Ignore.
+
2021-08-17 Jer Noble <[email protected]>
De-duplicate the Cocoa-specific MediaPlayerPrivateRemote constructor
Modified: trunk/Source/WebKit/NetworkProcess/curl/NetworkDataTaskCurl.cpp (281157 => 281158)
--- trunk/Source/WebKit/NetworkProcess/curl/NetworkDataTaskCurl.cpp 2021-08-17 19:34:28 UTC (rev 281157)
+++ trunk/Source/WebKit/NetworkProcess/curl/NetworkDataTaskCurl.cpp 2021-08-17 19:57:50 UTC (rev 281158)
@@ -234,6 +234,8 @@
m_curlRequest->completeDidReceiveResponse();
break;
case PolicyAction::Ignore:
+ if (m_client)
+ m_client->didCompleteWithError(ResourceErrorBase::Type::Cancellation);
invalidateAndCancel();
break;
default:
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes