Title: [286970] trunk
- Revision
- 286970
- Author
- you...@apple.com
- Date
- 2021-12-13 12:28:00 -0800 (Mon, 13 Dec 2021)
Log Message
FetchResponse::clone should use the relevant realm for the cloned response
https://bugs.webkit.org/show_bug.cgi?id=234238
Reviewed by Alexey Shvayka.
Source/WebCore:
Reuse the relevant realm for cloning as per https://fetch.spec.whatwg.org/#dom-response-clone step 3.
If context is stopped, throw an InvalidStateError exception, like done in Chrome.
Test: http/wpt/fetch/clone-realm.html
* Modules/fetch/FetchResponse.cpp:
* Modules/fetch/FetchResponse.h:
* Modules/fetch/FetchResponse.idl:
LayoutTests:
* http/wpt/fetch/clone-realm-expected.txt: Added.
* http/wpt/fetch/clone-realm.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (286969 => 286970)
--- trunk/LayoutTests/ChangeLog 2021-12-13 20:25:56 UTC (rev 286969)
+++ trunk/LayoutTests/ChangeLog 2021-12-13 20:28:00 UTC (rev 286970)
@@ -1,3 +1,13 @@
+2021-12-13 Youenn Fablet <you...@apple.com>
+
+ FetchResponse::clone should use the relevant realm for the cloned response
+ https://bugs.webkit.org/show_bug.cgi?id=234238
+
+ Reviewed by Alexey Shvayka.
+
+ * http/wpt/fetch/clone-realm-expected.txt: Added.
+ * http/wpt/fetch/clone-realm.html: Added.
+
2021-12-13 Rob Buis <rb...@igalia.com>
[ macOS and iOS ] editing/deleting/forward-delete-crash.html is timing out
Added: trunk/LayoutTests/http/wpt/fetch/clone-realm-expected.txt (0 => 286970)
--- trunk/LayoutTests/http/wpt/fetch/clone-realm-expected.txt (rev 0)
+++ trunk/LayoutTests/http/wpt/fetch/clone-realm-expected.txt 2021-12-13 20:28:00 UTC (rev 286970)
@@ -0,0 +1,3 @@
+
+PASS Cloning a response fails when its frame is detached
+
Added: trunk/LayoutTests/http/wpt/fetch/clone-realm.html (0 => 286970)
--- trunk/LayoutTests/http/wpt/fetch/clone-realm.html (rev 0)
+++ trunk/LayoutTests/http/wpt/fetch/clone-realm.html 2021-12-13 20:28:00 UTC (rev 286970)
@@ -0,0 +1,32 @@
+<!doctype html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <script src=""
+ <script src=""
+ </head>
+ <body>
+<script>
+function with_iframe(url) {
+ return new Promise(function(resolve) {
+ var frame = document.createElement('iframe');
+ frame.src = ""
+ frame._onload_ = function() { resolve(frame); };
+ document.body.appendChild(frame);
+ });
+}
+promise_test(async (t) => {
+ const frame = await with_iframe('/');
+ const response = await frame.contentWindow.fetch('/');
+ await response.clone().text();
+ frame.remove();
+ try {
+ response.clone();
+ assert_not_reached();
+ } catch (e) {
+ assert_equals(e.name, 'InvalidStateError');
+ }
+}, "Cloning a response fails when its frame is detached");
+</script>
+ </body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (286969 => 286970)
--- trunk/Source/WebCore/ChangeLog 2021-12-13 20:25:56 UTC (rev 286969)
+++ trunk/Source/WebCore/ChangeLog 2021-12-13 20:28:00 UTC (rev 286970)
@@ -1,3 +1,19 @@
+2021-12-13 Youenn Fablet <you...@apple.com>
+
+ FetchResponse::clone should use the relevant realm for the cloned response
+ https://bugs.webkit.org/show_bug.cgi?id=234238
+
+ Reviewed by Alexey Shvayka.
+
+ Reuse the relevant realm for cloning as per https://fetch.spec.whatwg.org/#dom-response-clone step 3.
+ If context is stopped, throw an InvalidStateError exception, like done in Chrome.
+
+ Test: http/wpt/fetch/clone-realm.html
+
+ * Modules/fetch/FetchResponse.cpp:
+ * Modules/fetch/FetchResponse.h:
+ * Modules/fetch/FetchResponse.idl:
+
2021-12-13 Alan Bujtas <za...@apple.com>
[LFC][IFC] Simple RTL content does not need visual reordering
Modified: trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp (286969 => 286970)
--- trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp 2021-12-13 20:25:56 UTC (rev 286969)
+++ trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp 2021-12-13 20:28:00 UTC (rev 286970)
@@ -169,12 +169,16 @@
{
}
-ExceptionOr<Ref<FetchResponse>> FetchResponse::clone(ScriptExecutionContext& context)
+ExceptionOr<Ref<FetchResponse>> FetchResponse::clone()
{
+ if (isContextStopped())
+ return Exception { InvalidStateError, "Context is stopped"_s };
+
if (isDisturbedOrLocked())
return Exception { TypeError, "Body is disturbed or locked"_s };
ASSERT(scriptExecutionContext());
+ auto& context = *scriptExecutionContext();
// If loading, let's create a stream so that data is teed on both clones.
if (isLoading() && !m_readableStreamSource) {
Modified: trunk/Source/WebCore/Modules/fetch/FetchResponse.h (286969 => 286970)
--- trunk/Source/WebCore/Modules/fetch/FetchResponse.h 2021-12-13 20:25:56 UTC (rev 286969)
+++ trunk/Source/WebCore/Modules/fetch/FetchResponse.h 2021-12-13 20:28:00 UTC (rev 286970)
@@ -79,7 +79,7 @@
const FetchHeaders& headers() const { return m_headers; }
FetchHeaders& headers() { return m_headers; }
- ExceptionOr<Ref<FetchResponse>> clone(ScriptExecutionContext&);
+ ExceptionOr<Ref<FetchResponse>> clone();
void consumeBodyAsStream() final;
void feedStream() final;
Modified: trunk/Source/WebCore/Modules/fetch/FetchResponse.idl (286969 => 286970)
--- trunk/Source/WebCore/Modules/fetch/FetchResponse.idl 2021-12-13 20:25:56 UTC (rev 286969)
+++ trunk/Source/WebCore/Modules/fetch/FetchResponse.idl 2021-12-13 20:28:00 UTC (rev 286970)
@@ -57,7 +57,7 @@
readonly attribute ByteString statusText;
[SameObject] readonly attribute FetchHeaders headers;
- [CallWith=ScriptExecutionContext, NewObject] FetchResponse clone();
+ [NewObject] FetchResponse clone();
};
FetchResponse includes FetchBody;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes