⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 286970 in webkit


Ignore:
Timestamp:
Dec 13, 2021, 12:28:00 PM (5 years ago)
Author:
youenn@apple.com
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.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r286966 r286970  
     12021-12-13  Youenn Fablet  <youenn@apple.com>
     2
     3        FetchResponse::clone should use the relevant realm for the cloned response
     4        https://bugs.webkit.org/show_bug.cgi?id=234238
     5
     6        Reviewed by Alexey Shvayka.
     7
     8        * http/wpt/fetch/clone-realm-expected.txt: Added.
     9        * http/wpt/fetch/clone-realm.html: Added.
     10
    1112021-12-13  Rob Buis  <rbuis@igalia.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r286968 r286970  
     12021-12-13  Youenn Fablet  <youenn@apple.com>
     2
     3        FetchResponse::clone should use the relevant realm for the cloned response
     4        https://bugs.webkit.org/show_bug.cgi?id=234238
     5
     6        Reviewed by Alexey Shvayka.
     7
     8        Reuse the relevant realm for cloning as per https://fetch.spec.whatwg.org/#dom-response-clone step 3.
     9        If context is stopped, throw an InvalidStateError exception, like done in Chrome.
     10
     11        Test: http/wpt/fetch/clone-realm.html
     12
     13        * Modules/fetch/FetchResponse.cpp:
     14        * Modules/fetch/FetchResponse.h:
     15        * Modules/fetch/FetchResponse.idl:
     16
    1172021-12-13  Alan Bujtas  <zalan@apple.com>
    218
  • trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp

    r286937 r286970  
    170170}
    171171
    172 ExceptionOr<Ref<FetchResponse>> FetchResponse::clone(ScriptExecutionContext& context)
    173 {
     172ExceptionOr<Ref<FetchResponse>> FetchResponse::clone()
     173{
     174    if (isContextStopped())
     175        return Exception { InvalidStateError, "Context is stopped"_s };
     176
    174177    if (isDisturbedOrLocked())
    175178        return Exception { TypeError, "Body is disturbed or locked"_s };
    176179
    177180    ASSERT(scriptExecutionContext());
     181    auto& context = *scriptExecutionContext();
    178182
    179183    // If loading, let's create a stream so that data is teed on both clones.
  • trunk/Source/WebCore/Modules/fetch/FetchResponse.h

    r286937 r286970  
    8080    const FetchHeaders& headers() const { return m_headers; }
    8181    FetchHeaders& headers() { return m_headers; }
    82     ExceptionOr<Ref<FetchResponse>> clone(ScriptExecutionContext&);
     82    ExceptionOr<Ref<FetchResponse>> clone();
    8383
    8484    void consumeBodyAsStream() final;
  • trunk/Source/WebCore/Modules/fetch/FetchResponse.idl

    r274832 r286970  
    5858    [SameObject] readonly attribute FetchHeaders headers;
    5959
    60     [CallWith=ScriptExecutionContext, NewObject] FetchResponse clone();
     60    [NewObject] FetchResponse clone();
    6161};
    6262
Note: See TracChangeset for help on using the changeset viewer.