WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Updating AtomicString
bug-154536-20160224205457.patch (text/plain), 81.46 KB, created by
youenn fablet
on 2016-02-24 11:55:16 PST
(
hide
)
Description:
Updating AtomicString
Filename:
MIME Type:
Creator:
youenn fablet
Created:
2016-02-24 11:55:16 PST
Size:
81.46 KB
patch
obsolete
>Subversion Revision: 197027 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 7bb39d0616834be4fcaad29f1bb26aec7d260f86..00a18d026dfb407a8a94aef920074ef7cf47cbe9 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,5 +1,63 @@ > 2016-02-24 Youenn Fablet <youenn.fablet@crf.canon.fr> > >+ [Fetch API] Implement Fetch API Response >+ https://bugs.webkit.org/show_bug.cgi?id=154536 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Tests: imported/w3c/web-platform-tests/fetch/api/response/response-clone.html >+ imported/w3c/web-platform-tests/fetch/api/response/response-consume.html >+ imported/w3c/web-platform-tests/fetch/api/response/response-error.html >+ imported/w3c/web-platform-tests/fetch/api/response/response-idl.html >+ imported/w3c/web-platform-tests/fetch/api/response/response-init-001.html >+ imported/w3c/web-platform-tests/fetch/api/response/response-init-002.html >+ imported/w3c/web-platform-tests/fetch/api/response/response-static-error.html >+ imported/w3c/web-platform-tests/fetch/api/response/response-static-redirect.html >+ >+ Adding Fetch Response as FetchResponse class. >+ Constructor uses a built-in to pre-process the parameters. >+ Support of body as ReadableStream is missing. >+ >+ * CMakeLists.txt: >+ * DerivedSources.make: >+ * Modules/fetch/FetchBody.h: >+ (WebCore::FetchBody::empty): >+ * Modules/fetch/FetchResponse.cpp: Added. >+ (WebCore::JSFetchResponse::body): >+ (WebCore::isRedirectStatus): >+ (WebCore::isNullBodyStatus): >+ (WebCore::FetchResponse::error): >+ (WebCore::FetchResponse::redirect): >+ (WebCore::FetchResponse::initializeWith): >+ (WebCore::FetchResponse::FetchResponse): >+ (WebCore::FetchResponse::clone): >+ (WebCore::FetchResponse::type): >+ * Modules/fetch/FetchResponse.h: Added. >+ (WebCore::FetchResponse::create): >+ (WebCore::FetchResponse::redirect): >+ (WebCore::FetchResponse::url): >+ (WebCore::FetchResponse::redirected): >+ (WebCore::FetchResponse::status): >+ (WebCore::FetchResponse::ok): >+ (WebCore::FetchResponse::statusText): >+ (WebCore::FetchResponse::headers): >+ (WebCore::FetchResponse::isDisturbed): >+ (WebCore::FetchResponse::arrayBuffer): >+ (WebCore::FetchResponse::formData): >+ (WebCore::FetchResponse::blob): >+ (WebCore::FetchResponse::json): >+ (WebCore::FetchResponse::text): >+ * Modules/fetch/FetchResponse.idl: Added. >+ * Modules/fetch/FetchResponse.js: Added. >+ (initializeFetchResponse): >+ * WebCore.xcodeproj/project.pbxproj: >+ * bindings/js/WebCoreJSBuiltins.cpp: >+ * bindings/js/WebCoreJSBuiltins.h: >+ (WebCore::JSBuiltinFunctions::JSBuiltinFunctions): >+ (WebCore::JSBuiltinFunctions::fetchResponseBuiltins): >+ >+2016-02-24 Youenn Fablet <youenn.fablet@crf.canon.fr> >+ > [Fetch API] Refactor FetchHeaders initialization with iterators > https://bugs.webkit.org/show_bug.cgi?id=154537 > >diff --git a/Source/WebCore/CMakeLists.txt b/Source/WebCore/CMakeLists.txt >index c6fdad47ade98b1d48df25949dc1e017f75ca0d3..74014d3dfa293c075db6b6f271f4b3ad8dabea8c 100644 >--- a/Source/WebCore/CMakeLists.txt >+++ b/Source/WebCore/CMakeLists.txt >@@ -166,6 +166,7 @@ set(WebCore_NON_SVG_IDL_FILES > Modules/fetch/FetchBody.idl > Modules/fetch/FetchHeaders.idl > Modules/fetch/FetchRequest.idl >+ Modules/fetch/FetchResponse.idl > > Modules/geolocation/Coordinates.idl > Modules/geolocation/Geolocation.idl >@@ -813,6 +814,7 @@ set(WebCore_SOURCES > Modules/fetch/FetchBody.cpp > Modules/fetch/FetchHeaders.cpp > Modules/fetch/FetchRequest.cpp >+ Modules/fetch/FetchResponse.cpp > > Modules/geolocation/Coordinates.cpp > Modules/geolocation/GeoNotifier.cpp >@@ -3665,6 +3667,7 @@ GENERATE_BINDINGS(WebCoreTestSupport_SOURCES > > set(WebCore_BUILTINS_SOURCES > ${WEBCORE_DIR}/Modules/fetch/FetchHeaders.js >+ ${WEBCORE_DIR}/Modules/fetch/FetchResponse.js > ${WEBCORE_DIR}/Modules/mediastream/MediaDevices.js > ${WEBCORE_DIR}/Modules/mediastream/NavigatorUserMedia.js > ${WEBCORE_DIR}/Modules/mediastream/RTCPeerConnection.js >diff --git a/Source/WebCore/DerivedSources.cpp b/Source/WebCore/DerivedSources.cpp >index 38078d8752fdc393aaffa9250728a24220c97b11..a4a48e20a991b8a3bbb64e2976810dd0247bb379 100644 >--- a/Source/WebCore/DerivedSources.cpp >+++ b/Source/WebCore/DerivedSources.cpp >@@ -156,6 +156,7 @@ > #include "JSFetchBody.cpp" > #include "JSFetchHeaders.cpp" > #include "JSFetchRequest.cpp" >+#include "JSFetchResponse.cpp" > #include "JSFile.cpp" > #include "JSFileError.cpp" > #include "JSFileException.cpp" >diff --git a/Source/WebCore/DerivedSources.make b/Source/WebCore/DerivedSources.make >index 46a19db3613a03bf5854f408d8f9cee534814f99..dc7c8d9f022dd543f713095085ea35dac1691b6f 100644 >--- a/Source/WebCore/DerivedSources.make >+++ b/Source/WebCore/DerivedSources.make >@@ -82,6 +82,7 @@ NON_SVG_BINDING_IDLS = \ > $(WebCore)/Modules/fetch/FetchBody.idl \ > $(WebCore)/Modules/fetch/FetchHeaders.idl \ > $(WebCore)/Modules/fetch/FetchRequest.idl \ >+ $(WebCore)/Modules/fetch/FetchResponse.idl \ > $(WebCore)/Modules/gamepad/Gamepad.idl \ > $(WebCore)/Modules/gamepad/GamepadButton.idl \ > $(WebCore)/Modules/gamepad/GamepadEvent.idl \ >@@ -1271,6 +1272,7 @@ WebReplayInputs.h : $(INPUT_GENERATOR_SPECIFICATIONS) $(INPUT_GENERATOR_SCRIPTS) > > WebCore_BUILTINS_SOURCES = \ > $(WebCore)/Modules/fetch/FetchHeaders.js \ >+ $(WebCore)/Modules/fetch/FetchResponse.js \ > $(WebCore)/Modules/mediastream/MediaDevices.js \ > $(WebCore)/Modules/mediastream/NavigatorUserMedia.js \ > $(WebCore)/Modules/mediastream/RTCPeerConnection.js \ >diff --git a/Source/WebCore/Modules/fetch/FetchBody.h b/Source/WebCore/Modules/fetch/FetchBody.h >index 43627a21280d977386a4f355f46b08556443c13d..49f10d5a7de57915ffb84e1c5a74c3d60a170134 100644 >--- a/Source/WebCore/Modules/fetch/FetchBody.h >+++ b/Source/WebCore/Modules/fetch/FetchBody.h >@@ -70,6 +70,7 @@ public: > > static FetchBody fromJSValue(JSC::ExecState&, JSC::JSValue); > static FetchBody fromRequestBody(FetchBody*); >+ static FetchBody empty() { return FetchBody(); } > > private: > template<typename T> bool processIfEmptyOrDisturbed(DOMPromise<T, ExceptionCode>&); >diff --git a/Source/WebCore/Modules/fetch/FetchResponse.cpp b/Source/WebCore/Modules/fetch/FetchResponse.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..9828b90f23ba51e1a968283ec04610c8574e6f59 >--- /dev/null >+++ b/Source/WebCore/Modules/fetch/FetchResponse.cpp >@@ -0,0 +1,166 @@ >+/* >+ * Copyright (C) 2016 Canon Inc. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted, provided that the following conditions >+ * are required to be met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * 3. Neither the name of Canon Inc. nor the names of >+ * its contributors may be used to endorse or promote products derived >+ * from this software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY CANON INC. AND ITS CONTRIBUTORS "AS IS" AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL CANON INC. AND ITS CONTRIBUTORS BE LIABLE FOR >+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL >+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR >+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER >+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, >+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "FetchResponse.h" >+ >+#if ENABLE(FETCH_API) >+ >+#include "Dictionary.h" >+#include "ExceptionCode.h" >+#include "JSFetchResponse.h" >+#include "ScriptExecutionContext.h" >+ >+namespace WebCore { >+ >+static inline bool isRedirectStatus(int status) >+{ >+ return status == 301 || status == 302 || status == 303 || status == 307 || status == 308; >+} >+ >+static inline bool isNullBodyStatus(int status) >+{ >+ return status == 101 || status == 204 || status == 205 || status == 304; >+} >+ >+Ref<FetchResponse> FetchResponse::error() >+{ >+ return adoptRef(*new FetchResponse(Type::Error, FetchBody::empty(), FetchHeaders::create(FetchHeaders::Guard::Immutable), ResourceResponse())); >+} >+ >+RefPtr<FetchResponse> FetchResponse::redirect(ScriptExecutionContext* context, const String& url, int status, ExceptionCode& ec) >+{ >+ // FIXME: Tighten the URL parsing algorithm according https://url.spec.whatwg.org/#concept-url-parser. >+ URL requestURL = context->completeURL(url); >+ if (!requestURL.isValid() || !requestURL.user().isEmpty() || !requestURL.pass().isEmpty()) { >+ ec = TypeError; >+ return nullptr; >+ } >+ if (!isRedirectStatus(status)) { >+ ec = TypeError; >+ return nullptr; >+ } >+ RefPtr<FetchResponse> redirectResponse = adoptRef(*new FetchResponse(Type::Default, FetchBody::empty(), FetchHeaders::create(FetchHeaders::Guard::Immutable), ResourceResponse())); >+ redirectResponse->m_response.setHTTPStatusCode(status); >+ redirectResponse->m_headers->fastSet(HTTPHeaderName::Location, requestURL.string()); >+ return redirectResponse; >+} >+ >+void FetchResponse::initializeWith(const Dictionary& init, ExceptionCode& ec) >+{ >+ int status; >+ if (!init.get("status", status)) { >+ ec = TypeError; >+ return; >+ } >+ if (status < 200 || status > 599) { >+ ec = RangeError; >+ return; >+ } >+ >+ // FIXME: Validate reason phrase (https://tools.ietf.org/html/rfc7230#section-3.1.2). >+ String statusText; >+ if (!init.get("statusText", statusText)) { >+ ec = TypeError; >+ return; >+ } >+ m_response.setHTTPStatusCode(status); >+ m_response.setHTTPStatusText(statusText); >+ >+ RefPtr<FetchHeaders> initialHeaders; >+ if (init.get("headers", initialHeaders)) >+ m_headers->fill(initialHeaders.get()); >+ >+ JSC::JSValue body; >+ if (init.get("body", body)) { >+ if (isNullBodyStatus(status)) { >+ ec = TypeError; >+ return; >+ } >+ m_body = FetchBody::fromJSValue(*init.execState(), body); >+ if (m_headers->fastGet(HTTPHeaderName::ContentType).isEmpty() && !m_body.mimeType().isEmpty()) >+ m_headers->fastSet(HTTPHeaderName::ContentType, m_body.mimeType()); >+ } >+} >+ >+FetchResponse::FetchResponse(Type type, FetchBody&& body, Ref<FetchHeaders>&& headers, ResourceResponse&& response) >+ : m_type(type) >+ , m_response(WTFMove(response)) >+ , m_body(WTFMove(body)) >+ , m_headers(WTFMove(headers)) >+{ >+} >+ >+RefPtr<FetchResponse> FetchResponse::clone(ExceptionCode& ec) >+{ >+ if (m_body.isDisturbed() || m_isLocked) { >+ ec = TypeError; >+ return nullptr; >+ } >+ RefPtr<FetchResponse> cloned = adoptRef(*new FetchResponse(m_type, FetchBody(m_body), FetchHeaders::create(headers()), ResourceResponse(m_response))); >+ cloned->m_isRedirected = m_isRedirected; >+ return cloned; >+} >+ >+const AtomicString& FetchResponse::type() const >+{ >+ static NeverDestroyed<AtomicString> basic("basic"); >+ static NeverDestroyed<AtomicString> cors("cors"); >+ static NeverDestroyed<AtomicString> defaults("default"); >+ static NeverDestroyed<AtomicString> closed("closed"); >+ static NeverDestroyed<AtomicString> error("error"); >+ static NeverDestroyed<AtomicString> opaque("opaque"); >+ static NeverDestroyed<AtomicString> opaqueredirect("opaqueredirect"); >+ >+ switch (m_type) { >+ case Type::Basic: >+ return basic; >+ case Type::Cors: >+ return cors; >+ case Type::Default: >+ return defaults; >+ case Type::Error: >+ return error; >+ case Type::Opaque: >+ return opaque; >+ case Type::OpaqueRedirect: >+ return opaqueredirect; >+ }; >+ ASSERT_NOT_REACHED(); >+ return basic; >+} >+ >+// FIXME: Implement this, as a custom or through binding generator. >+JSC::JSValue JSFetchResponse::body(JSC::ExecState&) const >+{ >+ return JSC::jsNull(); >+} >+ >+} // namespace WebCore >+ >+#endif // ENABLE(FETCH_API) >diff --git a/Source/WebCore/Modules/fetch/FetchResponse.h b/Source/WebCore/Modules/fetch/FetchResponse.h >new file mode 100644 >index 0000000000000000000000000000000000000000..604b251c694da7c14e2ff7ca0229d50614cbab6c >--- /dev/null >+++ b/Source/WebCore/Modules/fetch/FetchResponse.h >@@ -0,0 +1,93 @@ >+/* >+ * Copyright (C) 2016 Canon Inc. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted, provided that the following conditions >+ * are required to be met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * 3. Neither the name of Canon Inc. nor the names of >+ * its contributors may be used to endorse or promote products derived >+ * from this software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY CANON INC. AND ITS CONTRIBUTORS "AS IS" AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL CANON INC. AND ITS CONTRIBUTORS BE LIABLE FOR >+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL >+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR >+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER >+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, >+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#ifndef FetchResponse_h >+#define FetchResponse_h >+ >+#if ENABLE(FETCH_API) >+ >+#include "FetchBody.h" >+#include "FetchHeaders.h" >+#include "ResourceResponse.h" >+ >+namespace JSC { >+class ArrayBuffer; >+}; >+ >+namespace WebCore { >+ >+class Dictionary; >+ >+typedef int ExceptionCode; >+ >+class FetchResponse : public RefCounted<FetchResponse> { >+public: >+ static Ref<FetchResponse> create() { return adoptRef(*new FetchResponse(Type::Default, FetchBody::empty(), FetchHeaders::create(FetchHeaders::Guard::Response), ResourceResponse())); } >+ static Ref<FetchResponse> error(); >+ static RefPtr<FetchResponse> redirect(ScriptExecutionContext*, const String&, int, ExceptionCode&); >+ // FIXME: Binding generator should not require below method to handle optional status parameter. >+ static RefPtr<FetchResponse> redirect(ScriptExecutionContext* context, const String& url, ExceptionCode& ec) { return redirect(context, url, 302, ec); } >+ >+ void initializeWith(const Dictionary&, ExceptionCode&); >+ >+ const AtomicString& type() const; >+ const String& url() const { return m_response.url().string(); } >+ bool redirected() const { return m_isRedirected; } >+ int status() const { return m_response.httpStatusCode(); } >+ bool ok() const { return status() >= 200 && status() <= 299; } >+ const String& statusText() const { return m_response.httpStatusText(); } >+ >+ FetchHeaders& headers() { return m_headers; } >+ RefPtr<FetchResponse> clone(ExceptionCode&); >+ >+ // Body API >+ bool isDisturbed() const { return m_body.isDisturbed(); } >+ void arrayBuffer(FetchBody::ArrayBufferPromise&& promise) { m_body.arrayBuffer(WTFMove(promise)); } >+ void formData(FetchBody::FormDataPromise&& promise) { m_body.formData(WTFMove(promise)); } >+ void blob(FetchBody::BlobPromise&& promise) { m_body.blob(WTFMove(promise)); } >+ void json(JSC::ExecState& state, FetchBody::JSONPromise&& promise) { m_body.json(state, WTFMove(promise)); } >+ void text(FetchBody::TextPromise&& promise) { m_body.text(WTFMove(promise)); } >+ >+private: >+ enum class Type { Basic, Cors, Default, Error, Opaque, OpaqueRedirect }; >+ >+ FetchResponse(Type, FetchBody&&, Ref<FetchHeaders>&&, ResourceResponse&&); >+ >+ Type m_type; >+ ResourceResponse m_response; >+ FetchBody m_body; >+ Ref<FetchHeaders> m_headers; >+ bool m_isLocked = false; >+ bool m_isRedirected = false; >+}; >+ >+} // namespace WebCore >+ >+#endif // ENABLE(FETCH_API) >+ >+#endif // FetchResponse_h >diff --git a/Source/WebCore/Modules/fetch/FetchResponse.idl b/Source/WebCore/Modules/fetch/FetchResponse.idl >new file mode 100644 >index 0000000000000000000000000000000000000000..e70f4b91d05a5c83d2fd0fcc06d39048cec9706f >--- /dev/null >+++ b/Source/WebCore/Modules/fetch/FetchResponse.idl >@@ -0,0 +1,57 @@ >+/* >+ * Copyright (C) 2016 Canon Inc. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted, provided that the following conditions >+ * are required to be met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * 3. Neither the name of Canon Inc. nor the names of >+ * its contributors may be used to endorse or promote products derived >+ * from this software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY CANON INC. AND ITS CONTRIBUTORS "AS IS" AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL CANON INC. AND ITS CONTRIBUTORS BE LIABLE FOR >+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL >+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR >+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER >+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, >+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+enum ResponseType { "basic", "cors", "default", "error", "opaque", "opaqueredirect" }; >+ >+[ >+ Conditional=FETCH_API, >+ GlobalContext=DOMWindow&WorkerGlobalScope, >+ ImplementationLacksVTable, >+ InterfaceName=Response, >+ JSBuiltinConstructor >+] >+interface FetchResponse { >+ // FIXME: NewObject does not seem to be supported for static methods. >+ static FetchResponse error(); >+ [RaisesException, CallWith=ScriptExecutionContext] static FetchResponse redirect(DOMString url, optional unsigned short status = 302); >+ >+ readonly attribute ResponseType type; >+ >+ readonly attribute DOMString url; >+ readonly attribute boolean redirected; >+ readonly attribute unsigned short status; >+ readonly attribute boolean ok; >+ readonly attribute DOMString statusText; >+ // FIXME: Add support for SameObject keyword for headers >+ readonly attribute FetchHeaders headers; >+ [Custom, RaisesException] readonly attribute ReadableStream? body; >+ >+ [NewObject, RaisesException] FetchResponse clone(); >+ >+ [Private, RaisesException] void initializeWith(Dictionary parameters); >+}; >+FetchResponse implements FetchBody; >diff --git a/Source/WebCore/Modules/fetch/FetchResponse.js b/Source/WebCore/Modules/fetch/FetchResponse.js >new file mode 100644 >index 0000000000000000000000000000000000000000..f2b534e65304da3d57ab7d6d9385f51c12fc875e >--- /dev/null >+++ b/Source/WebCore/Modules/fetch/FetchResponse.js >@@ -0,0 +1,53 @@ >+/* >+ * Copyright (C) 2016 Canon Inc. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY CANON INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CANON INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+// @conditional=ENABLE(FETCH_API) >+ >+function initializeFetchResponse(body, init) >+{ >+ "use strict"; >+ >+ let parameters = { }; >+ if (init !== @undefined) { >+ if (!@isObject(init)) >+ throw new @TypeError("Response init must be an object"); >+ parameters.status = init.status; >+ parameters.statusText = init.statusText; >+ // FIXME: Shield this from user scripts. >+ if (init.headers) >+ parameters.headers = (this.headers.constructor === init.headers.constructor) ? init.headers : new this.headers.constructor(init.headers); >+ } >+ >+ if (parameters.status === @undefined) >+ parameters.status = 200; >+ if (parameters.statusText === @undefined) >+ parameters.statusText = "OK"; >+ >+ if (body !== @undefined && body !== null) >+ parameters.body = body; >+ >+ this.@initializeWith(parameters); >+ return this; >+} >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index 53eaa3451297c3b2adaf0888ef31c3300b2dbcf8..ae2b187191fbba2d062db67f2fdf99e3e91034f2 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -1497,6 +1497,7 @@ > 4127D5370F8AAB1D00E424F5 /* ScriptState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4127D5360F8AAB1D00E424F5 /* ScriptState.cpp */; }; > 4129DF851BB5B80700322A16 /* JSReadableStreamPrivateConstructors.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4129DF831BB5B7F700322A16 /* JSReadableStreamPrivateConstructors.cpp */; }; > 4129DF861BB5B80C00322A16 /* JSReadableStreamPrivateConstructors.h in Headers */ = {isa = PBXBuildFile; fileRef = 4129DF841BB5B7F700322A16 /* JSReadableStreamPrivateConstructors.h */; settings = {ATTRIBUTES = (Private, ); }; }; >+ 413015D91C7B571400091C6E /* FetchResponse.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 413015D51C7B570400091C6E /* FetchResponse.cpp */; }; > 4138D3351244054800323D33 /* EventContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 4138D3331244054800323D33 /* EventContext.h */; }; > 4138D3361244054800323D33 /* EventContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4138D3341244054800323D33 /* EventContext.cpp */; }; > 413C2C341BC29A8F0075204C /* JSDOMConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = 413C2C331BC29A7B0075204C /* JSDOMConstructor.h */; }; >@@ -2813,8 +2814,10 @@ > 7E474E1E12494DC900235364 /* SQLiteDatabaseTrackerClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E474E1B12494DC900235364 /* SQLiteDatabaseTrackerClient.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 7E474E1F12494DC900235364 /* SQLiteDatabaseTracker.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E474E1C12494DC900235364 /* SQLiteDatabaseTracker.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 7E474E2012494DC900235364 /* SQLiteDatabaseTracker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7E474E1D12494DC900235364 /* SQLiteDatabaseTracker.cpp */; }; >- 7E4C96DC1AD4483500365A50 /* JSFetchRequest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7E4C96D81AD4483500365A50 /* JSFetchRequest.cpp */; }; > 7E4C96DD1AD4483500365A50 /* JSFetchRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E4C96D91AD4483500365A50 /* JSFetchRequest.h */; }; >+ 7E4C96DC1AD4483500365A50 /* JSFetchRequest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7E4C96D81AD4483500365A50 /* JSFetchRequest.cpp */; }; >+ 8E4C96DD1AD4483500365A50 /* JSFetchResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 8E4C96D91AD4483500365A50 /* JSFetchResponse.h */; }; >+ 8E4C96DC1AD4483500365A50 /* JSFetchResponse.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8E4C96D81AD4483500365A50 /* JSFetchResponse.cpp */; }; > 7E4DE10D198B10B60051CB02 /* DiskCacheMonitorCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7E4DE10C198B10B60051CB02 /* DiskCacheMonitorCocoa.mm */; }; > 7E5D7A76161D3F8F00896C34 /* OESElementIndexUint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7E5D7A73161D3F8F00896C34 /* OESElementIndexUint.cpp */; }; > 7E5D7A77161D3F8F00896C34 /* OESElementIndexUint.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E5D7A74161D3F8F00896C34 /* OESElementIndexUint.h */; }; >@@ -8960,6 +8963,10 @@ > 4129DF821BB5B7A600322A16 /* ReadableStreamReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReadableStreamReader.h; sourceTree = "<group>"; }; > 4129DF831BB5B7F700322A16 /* JSReadableStreamPrivateConstructors.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSReadableStreamPrivateConstructors.cpp; sourceTree = "<group>"; }; > 4129DF841BB5B7F700322A16 /* JSReadableStreamPrivateConstructors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSReadableStreamPrivateConstructors.h; sourceTree = "<group>"; }; >+ 413015D51C7B570400091C6E /* FetchResponse.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FetchResponse.cpp; sourceTree = "<group>"; }; >+ 413015D61C7B570400091C6E /* FetchResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FetchResponse.h; sourceTree = "<group>"; }; >+ 413015D71C7B570400091C6E /* FetchResponse.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = FetchResponse.idl; sourceTree = "<group>"; }; >+ 413015D81C7B570400091C6E /* FetchResponse.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = FetchResponse.js; sourceTree = "<group>"; }; > 4138D3331244054800323D33 /* EventContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventContext.h; sourceTree = "<group>"; }; > 4138D3341244054800323D33 /* EventContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EventContext.cpp; sourceTree = "<group>"; }; > 413C2C331BC29A7B0075204C /* JSDOMConstructor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDOMConstructor.h; sourceTree = "<group>"; }; >@@ -10441,6 +10448,8 @@ > 7E474E1D12494DC900235364 /* SQLiteDatabaseTracker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SQLiteDatabaseTracker.cpp; sourceTree = "<group>"; }; > 7E4C96D81AD4483500365A50 /* JSFetchRequest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSFetchRequest.cpp; sourceTree = "<group>"; }; > 7E4C96D91AD4483500365A50 /* JSFetchRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSFetchRequest.h; sourceTree = "<group>"; }; >+ 8E4C96D81AD4483500365A50 /* JSFetchResponse.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSFetchResponse.cpp; sourceTree = "<group>"; }; >+ 8E4C96D91AD4483500365A50 /* JSFetchResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSFetchResponse.h; sourceTree = "<group>"; }; > 7E4DE10C198B10B60051CB02 /* DiskCacheMonitorCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DiskCacheMonitorCocoa.mm; sourceTree = "<group>"; }; > 7E5D7A73161D3F8F00896C34 /* OESElementIndexUint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OESElementIndexUint.cpp; sourceTree = "<group>"; }; > 7E5D7A74161D3F8F00896C34 /* OESElementIndexUint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OESElementIndexUint.h; sourceTree = "<group>"; }; >@@ -16753,6 +16762,10 @@ > 41F54F871C50C4F600338488 /* FetchRequest.cpp */, > 41F54F881C50C4F600338488 /* FetchRequest.h */, > 41F54F891C50C4F600338488 /* FetchRequest.idl */, >+ 413015D51C7B570400091C6E /* FetchResponse.cpp */, >+ 413015D61C7B570400091C6E /* FetchResponse.h */, >+ 413015D71C7B570400091C6E /* FetchResponse.idl */, >+ 413015D81C7B570400091C6E /* FetchResponse.js */, > ); > path = fetch; > sourceTree = "<group>"; >@@ -16766,6 +16779,8 @@ > 7E4C96D91AD4483500365A50 /* JSFetchRequest.h */, > 7D4C96D81AD4483500365A50 /* JSFetchHeaders.cpp */, > 7D4C96D91AD4483500365A50 /* JSFetchHeaders.h */, >+ 8E4C96D81AD4483500365A50 /* JSFetchResponse.cpp */, >+ 8E4C96D91AD4483500365A50 /* JSFetchResponse.h */, > ); > name = FetchAPI; > sourceTree = "<group>"; >@@ -26684,6 +26699,7 @@ > 65DF320209D1CC60000BE325 /* JSRange.h in Headers */, > 7F4C96DD1AD4483500365A50 /* JSFetchBody.h in Headers */, > 7E4C96DD1AD4483500365A50 /* JSFetchRequest.h in Headers */, >+ 8E4C96DD1AD4483500365A50 /* JSFetchResponse.h in Headers */, > 7D4C96DD1AD4483500365A50 /* JSFetchHeaders.h in Headers */, > 7C4C96DD1AD4483500365A50 /* JSReadableStream.h in Headers */, > 6C4C96DF1AD4483500365A50 /* JSReadableStreamController.h in Headers */, >@@ -30426,6 +30442,7 @@ > 7F4C96DC1AD4483500365A50 /* JSFetchBody.cpp in Sources */, > 7D4C96DC1AD4483500365A50 /* JSFetchHeaders.cpp in Sources */, > 7E4C96DC1AD4483500365A50 /* JSFetchRequest.cpp in Sources */, >+ 8E4C96DC1AD4483500365A50 /* JSFetchResponse.cpp in Sources */, > 7C4C96DC1AD4483500365A50 /* JSReadableStream.cpp in Sources */, > 6C4C96DE1AD4483500365A50 /* JSReadableStreamController.cpp in Sources */, > 4129DF851BB5B80700322A16 /* JSReadableStreamPrivateConstructors.cpp in Sources */, >@@ -30692,6 +30709,7 @@ > D3F3D3671A69B1A50059FC2B /* JSWebGLRenderingContextBase.cpp in Sources */, > D3F3D36B1A69B7C50059FC2B /* JSWebGLRenderingContextBaseCustom.cpp in Sources */, > 49EED14F1051971A00099FAB /* JSWebGLRenderingContextCustom.cpp in Sources */, >+ 413015D91C7B571400091C6E /* FetchResponse.cpp in Sources */, > 6F995A331A70833700A735F4 /* JSWebGLSampler.cpp in Sources */, > 49C7B9A21042D2D30009D447 /* JSWebGLShader.cpp in Sources */, > A07D3355152B630E001B6393 /* JSWebGLShaderPrecisionFormat.cpp in Sources */, >diff --git a/Source/WebCore/bindings/js/WebCoreJSBuiltins.cpp b/Source/WebCore/bindings/js/WebCoreJSBuiltins.cpp >index d10994281c944722cb538f3f625924ed1c9c8b3f..f71290362ab03fe035bbf9e9c8beb4f40218d8e2 100644 >--- a/Source/WebCore/bindings/js/WebCoreJSBuiltins.cpp >+++ b/Source/WebCore/bindings/js/WebCoreJSBuiltins.cpp >@@ -29,6 +29,7 @@ > #include "ByteLengthQueuingStrategyBuiltins.cpp" > #include "CountQueuingStrategyBuiltins.cpp" > #include "FetchHeadersBuiltins.cpp" >+#include "FetchResponseBuiltins.cpp" > #include "MediaDevicesBuiltins.cpp" > #include "NavigatorUserMediaBuiltins.cpp" > #include "RTCPeerConnectionBuiltins.cpp" >diff --git a/Source/WebCore/bindings/js/WebCoreJSBuiltins.h b/Source/WebCore/bindings/js/WebCoreJSBuiltins.h >index 95f6b972f275ec2176f200caeba2540cb5e0637c..f5f1a529eb08fd85191bef90ef8593a113beec3d 100644 >--- a/Source/WebCore/bindings/js/WebCoreJSBuiltins.h >+++ b/Source/WebCore/bindings/js/WebCoreJSBuiltins.h >@@ -30,6 +30,7 @@ > #include "ByteLengthQueuingStrategyBuiltins.h" > #include "CountQueuingStrategyBuiltins.h" > #include "FetchHeadersBuiltins.h" >+#include "FetchResponseBuiltins.h" > #include "MediaDevicesBuiltins.h" > #include "NavigatorUserMediaBuiltins.h" > #include "RTCPeerConnectionBuiltins.h" >@@ -51,6 +52,7 @@ public: > : vm(v) > #if ENABLE(FETCH_API) > , m_fetchHeadersBuiltins(&vm) >+ , m_fetchResponseBuiltins(&vm) > #endif > #if ENABLE(STREAMS_API) > , m_byteLengthQueuingStrategyBuiltins(&vm) >@@ -81,6 +83,7 @@ public: > } > #if ENABLE(FETCH_API) > FetchHeadersBuiltinsWrapper& fetchHeadersBuiltins() { return m_fetchHeadersBuiltins; } >+ FetchResponseBuiltinsWrapper& fetchResponseBuiltins() { return m_fetchResponseBuiltins; } > #endif > #if ENABLE(STREAMS_API) > ByteLengthQueuingStrategyBuiltinsWrapper& byteLengthQueuingStrategyBuiltins() { return m_byteLengthQueuingStrategyBuiltins; } >@@ -104,6 +107,7 @@ private: > JSC::VM& vm; > #if ENABLE(FETCH_API) > FetchHeadersBuiltinsWrapper m_fetchHeadersBuiltins; >+ FetchResponseBuiltinsWrapper m_fetchResponseBuiltins; > #endif > #if ENABLE(STREAMS_API) > ByteLengthQueuingStrategyBuiltinsWrapper m_byteLengthQueuingStrategyBuiltins; >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 2d8ebdf797dcaab81c97a40392a8a4d1655c186a..52dd66dc8028cc5a36583e97554134bb3049386e 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,22 @@ >+2016-02-24 Youenn Fablet <youenn.fablet@crf.canon.fr> >+ >+ [Fetch API] Implement Fetch API Response >+ https://bugs.webkit.org/show_bug.cgi?id=154536 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Adding Response as constructor in global and worker scopes. >+ >+ * js/dom/global-constructors-attributes-dedicated-worker-expected.txt: >+ * js/dom/global-constructors-attributes-expected.txt: >+ * platform/efl/js/dom/global-constructors-attributes-dedicated-worker-expected.txt: >+ * platform/efl/js/dom/global-constructors-attributes-expected.txt: >+ * platform/gtk/js/dom/global-constructors-attributes-expected.txt: >+ * platform/mac-mavericks/js/dom/global-constructors-attributes-expected.txt: >+ * platform/mac-yosemite/js/dom/global-constructors-attributes-expected.txt: >+ * platform/mac/js/dom/global-constructors-attributes-expected.txt: >+ * platform/win/js/dom/global-constructors-attributes-expected.txt: >+ > 2016-02-24 Carlos Garcia Campos <cgarcia@igalia.com> > > REGRESSION(r195949): [GTK] Test /webkit2/WebKitWebView/insert/link is failing since r195949 >diff --git a/LayoutTests/imported/w3c/ChangeLog b/LayoutTests/imported/w3c/ChangeLog >index edb99b116b67467141b6e147366ed1709e5c6124..93f9cb5c54cda25c26ebb834b5ace8226380f397 100644 >--- a/LayoutTests/imported/w3c/ChangeLog >+++ b/LayoutTests/imported/w3c/ChangeLog >@@ -1,5 +1,31 @@ > 2016-02-24 Youenn Fablet <youenn.fablet@crf.canon.fr> > >+ [Fetch API] Implement Fetch API Response >+ https://bugs.webkit.org/show_bug.cgi?id=154536 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ New tests covering fetch API. >+ >+ * web-platform-tests/fetch/api/response/response-clone-expected.txt: Added. >+ * web-platform-tests/fetch/api/response/response-clone.html: Added. >+ * web-platform-tests/fetch/api/response/response-consume-expected.txt: Added. >+ * web-platform-tests/fetch/api/response/response-consume.html: Added. >+ * web-platform-tests/fetch/api/response/response-error-expected.txt: Added. >+ * web-platform-tests/fetch/api/response/response-error.html: Added. >+ * web-platform-tests/fetch/api/response/response-idl-expected.txt: Added. >+ * web-platform-tests/fetch/api/response/response-idl.html: Added. >+ * web-platform-tests/fetch/api/response/response-init-001-expected.txt: Added. >+ * web-platform-tests/fetch/api/response/response-init-001.html: Added. >+ * web-platform-tests/fetch/api/response/response-init-002-expected.txt: Added. >+ * web-platform-tests/fetch/api/response/response-init-002.html: Added. >+ * web-platform-tests/fetch/api/response/response-static-error-expected.txt: Added. >+ * web-platform-tests/fetch/api/response/response-static-error.html: Added. >+ * web-platform-tests/fetch/api/response/response-static-redirect-expected.txt: Added. >+ * web-platform-tests/fetch/api/response/response-static-redirect.html: Added. >+ >+2016-02-24 Youenn Fablet <youenn.fablet@crf.canon.fr> >+ > W3C importer should generate all web-platform-tests submodules descriptions > https://bugs.webkit.org/show_bug.cgi?id=154587 > >diff --git a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-clone-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-clone-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..5fa8fa44d3f5a96d45b844e5737d2b2af64fc554 >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-clone-expected.txt >@@ -0,0 +1,7 @@ >+ >+PASS Check Response's clone with default values, without body >+PASS Check Response's clone has the expected attribute values >+FAIL Check orginal response's body after cloning null is not an object (evaluating 'response.body.getReader') >+FAIL Check cloned response's body null is not an object (evaluating 'clonedResponse.body.getReader') >+FAIL Cannot clone a disturbed response assert_true: response is disturbed expected true got false >+ >diff --git a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-clone.html b/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-clone.html >new file mode 100644 >index 0000000000000000000000000000000000000000..fd323e68b4e8975f0056d2ea3460b73a9d0e1b3b >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-clone.html >@@ -0,0 +1,66 @@ >+<!doctype html> >+<html> >+ <head> >+ <meta charset="utf-8"> >+ <title>Response clone</title> >+ <meta name="help" href="https://fetch.spec.whatwg.org/#response"> >+ <meta name="author" title="Canon Research France" href="https://www.crf.canon.fr"> >+ <script src="/resources/testharness.js"></script> >+ <script src="/resources/testharnessreport.js"></script> >+ </head> >+ <body> >+ <script src="../resources/utils.js"></script> >+ <script> >+ var defaultValues = { "type" : "default", >+ "url" : "", >+ "ok" : true, >+ "status" : 200, >+ "statusText" : "OK" >+ }; >+ >+ var response = new Response(); >+ var clonedResponse = response.clone(); >+ test(function() { >+ for (var attributeName in defaultValues) { >+ var expectedValue = defaultValues[attributeName]; >+ assert_equals(clonedResponse[attributeName], expectedValue, >+ "Expect default response." + attributeName + " is " + expectedValue); >+ } >+ }, "Check Response's clone with default values, without body"); >+ >+ var body = "This is response body"; >+ var headersInit = { "name" : "value" }; >+ var responseInit = { "status" : 200, >+ "statusText" : "GOOD", >+ "headers" : headersInit >+ }; >+ var response = new Response(body, responseInit); >+ var clonedResponse = response.clone(); >+ test(function() { >+ assert_equals(clonedResponse.status, responseInit["status"], >+ "Expect response.status is " + responseInit["status"]); >+ assert_equals(clonedResponse.statusText, responseInit["statusText"], >+ "Expect response.statusText is " + responseInit["statusText"]); >+ assert_equals(response.headers.get("name"), "value", >+ "Expect response.headers has name:value header"); >+ }, "Check Response's clone has the expected attribute values"); >+ >+ async_test(function(test) { >+ readTextStream(response.body.getReader(), test, body); >+ }, "Check orginal response's body after cloning"); >+ >+ async_test(function(test) { >+ readTextStream(clonedResponse.body.getReader(), test, body); >+ }, "Check cloned response's body"); >+ >+ promise_test(function(test) { >+ var disturbedResponse = new Response(); >+ return disturbedResponse.text().then(function() { >+ assert_true(disturbedResponse.bodyUsed, "response is disturbed"); >+ assert_throws(new TypeError() , function() { disturbedResponse.clone(); }, >+ "Expect TypeError exception"); >+ }); >+ }, "Cannot clone a disturbed response"); >+ </script> >+ </body> >+</html> >diff --git a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..66c8f8672b1096f6f64be2a149f16f8cba7ff8a9 >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-expected.txt >@@ -0,0 +1,7 @@ >+ >+PASS Consume response's body as text >+FAIL Consume response's body as blob promise_test: Unhandled rejection with value: undefined >+FAIL Consume response's body as arrayBuffer promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: TextDecoder" >+PASS Consume response's body as json >+FAIL Consume response's body as formData promise_test: Unhandled rejection with value: undefined >+ >diff --git a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume.html b/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume.html >new file mode 100644 >index 0000000000000000000000000000000000000000..1de032165eb88e42aaa9f08606f5aae13fd9734c >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume.html >@@ -0,0 +1,82 @@ >+<!doctype html> >+<html> >+ <head> >+ <meta charset="utf-8"> >+ <title>Response consume</title> >+ <meta name="help" href="https://fetch.spec.whatwg.org/#response"> >+ <meta name="help" href="https://fetch.spec.whatwg.org/#body-mixin"> >+ <meta name="author" title="Canon Research France" href="https://www.crf.canon.fr"> >+ <script src="/resources/testharness.js"></script> >+ <script src="/resources/testharnessreport.js"></script> >+ </head> >+ <body> >+ <script> >+ function checkBodyText(response, expectedBody) { >+ return response.text().then( function(bodyAsText) { >+ assert_equals(bodyAsText, expectedBody, "Retrieve and verify response's body"); >+ assert_true(response.bodyUsed === true, "body as text: bodyUsed turned true"); >+ }); >+ } >+ >+ function checkBodyBlob(response, expectedBody) { >+ return response.blob().then(function(bodyAsBlob) { >+ var promise = new Promise( function (resolve, reject) { >+ var reader = new FileReader(); >+ reader.onload = function(evt) { >+ resolve(reader.result) >+ }; >+ reader.onerror = function () { >+ reject("Blob's reader failed"); >+ }; >+ reader.readAsText(bodyAsBlob); >+ }); >+ return promise.then(function(body) { >+ assert_equals(body, expectedBody, "Retrieve and verify response's body"); >+ assert_true(response.bodyUsed === true, "body as blob: bodyUsed turned true"); >+ }); >+ }); >+ } >+ >+ function checkBodyArrayBuffer(response, expectedBody) { >+ return response.arrayBuffer().then( function(bodyAsArrayBuffer) { >+ var decoder = new TextDecoder("utf-8"); >+ var strBody = decoder.decode(bodyAsArrayBuffer); >+ assert_equals(strBody, expectedBody, "Retrieve and verify response's body"); >+ assert_true(response.bodyUsed === true, "body as arrayBuffer: bodyUsed turned true"); >+ }); >+ } >+ >+ function checkBodyJson(response, expectedBody) { >+ return response.json().then(function(bodyAsJson) { >+ var strBody = JSON.stringify(bodyAsJson) >+ assert_equals(strBody, expectedBody, "Retrieve and verify response's body"); >+ assert_true(response.bodyUsed === true, "body as json: bodyUsed turned true"); >+ }); >+ } >+ >+ function checkBodyFormData(response, expectedBody) { >+ return response.formData().then(function(bodyAsFormData) { >+ for (var name of expectedBody.keys()) >+ assert_equals(bodyAsFormData.get(name), expectedBody.get(name) , "Retrieve and verify response's body" ); >+ assert_true(response.bodyUsed === true, "body as formData: bodyUsed turned true"); >+ }); >+ } >+ >+ function checkResponseBody(body, bodyType, checkFunction) { >+ promise_test(function(test) { >+ var response = new Response(body); >+ assert_true(response.bodyUsed === false, "bodyUsed is false at init"); >+ return checkFunction(response, body); >+ }, "Consume response's body as " + bodyType); >+ } >+ >+ var formData = new FormData(); >+ formData.append("name", "value") >+ checkResponseBody("This is response's body", "text", checkBodyText); >+ checkResponseBody("This is response's body", "blob", checkBodyBlob); >+ checkResponseBody("This is response's body", "arrayBuffer", checkBodyArrayBuffer); >+ checkResponseBody(JSON.stringify("This is response's body"), "json", checkBodyJson); >+ checkResponseBody(formData, "formData", checkBodyFormData); >+ </script> >+ </body> >+</html> >\ No newline at end of file >diff --git a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-error-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-error-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..55c571022d786137496cec6a1788af93ddbeebc4 >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-error-expected.txt >@@ -0,0 +1,6 @@ >+ >+PASS Throws RangeError when responseInit's status is invalid >+FAIL Throws TypeError when responseInit's statusText is invalid assert_throws: Expect TypeError exception >+ function "function () { new Response("", { "statusText" : statusTex..." did not throw >+PASS Throws TypeError when building a response with body and a null body status >+ >diff --git a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-error.html b/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-error.html >new file mode 100644 >index 0000000000000000000000000000000000000000..13024528081dd054bc4001d0791307075a60031a >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-error.html >@@ -0,0 +1,39 @@ >+<!doctype html> >+<html> >+ <head> >+ <meta charset="utf-8"> >+ <title>Response error</title> >+ <meta name="help" href="https://fetch.spec.whatwg.org/#response"> >+ <meta name="author" title="Canon Research France" href="https://www.crf.canon.fr"> >+ <script src="/resources/testharness.js"></script> >+ <script src="/resources/testharnessreport.js"></script> >+ </head> >+ <body> >+ <script> >+ test(function() { >+ var invalidStatus = [0, 100, 199, 600, 1000]; >+ invalidStatus.forEach(function(status) { >+ assert_throws(new RangeError() , function() { new Response("", { "status" : status }); }, >+ "Expect RangeError exception when status is " + status); >+ }); >+ },"Throws RangeError when responseInit's status is invalid"); >+ >+ test(function() { >+ var invalidStatusText = ["\n", "Ä"]; >+ invalidStatusText.forEach(function(statusText) { >+ assert_throws(new TypeError() , function() { new Response("", { "statusText" : statusText }); }, >+ "Expect TypeError exception " + statusText); >+ }); >+ },"Throws TypeError when responseInit's statusText is invalid"); >+ >+ test(function() { >+ var nullBodyStatus = [204, 205, 304]; >+ nullBodyStatus.forEach(function(status) { >+ assert_throws(new TypeError() , >+ function() { new Response("body", { "status" : status }); }, >+ "Expect TypeError exception "); >+ }); >+ },"Throws TypeError when building a response with body and a null body status"); >+ </script> >+ </body> >+</html> >\ No newline at end of file >diff --git a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-idl-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-idl-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..43037a021e30d90949cb82e68ca83038dab65c24 >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-idl-expected.txt >@@ -0,0 +1,47 @@ >+ >+PASS Response interface: existence and properties of interface object >+PASS Response interface object length >+PASS Response interface object name >+PASS Response interface: existence and properties of interface prototype object >+PASS Response interface: existence and properties of interface prototype object's "constructor" property >+PASS Response interface: operation error() >+PASS Response interface: operation redirect(USVString,unsigned short) >+PASS Response interface: attribute type >+PASS Response interface: attribute url >+PASS Response interface: attribute status >+PASS Response interface: attribute ok >+PASS Response interface: attribute statusText >+PASS Response interface: attribute headers >+PASS Response interface: attribute body >+PASS Response interface: operation clone() >+PASS Response interface: attribute bodyUsed >+FAIL Response interface: operation arrayBuffer() assert_throws: calling operation with this = null didn't throw TypeError function "function () { >+ memberHolderObject[member.n..." did not throw >+FAIL Response interface: operation blob() assert_throws: calling operation with this = null didn't throw TypeError function "function () { >+ memberHolderObject[member.n..." did not throw >+FAIL Response interface: operation formData() assert_throws: calling operation with this = null didn't throw TypeError function "function () { >+ memberHolderObject[member.n..." did not throw >+FAIL Response interface: operation json() assert_throws: calling operation with this = null didn't throw TypeError function "function () { >+ memberHolderObject[member.n..." did not throw >+FAIL Response interface: operation text() assert_throws: calling operation with this = null didn't throw TypeError function "function () { >+ memberHolderObject[member.n..." did not throw >+PASS Response must be primary interface of new Response() >+PASS Stringification of new Response() >+PASS Response interface: new Response() must inherit property "error" with the proper type (0) >+PASS Response interface: new Response() must inherit property "redirect" with the proper type (1) >+PASS Response interface: calling redirect(USVString,unsigned short) on new Response() with too few arguments must throw TypeError >+PASS Response interface: new Response() must inherit property "type" with the proper type (2) >+PASS Response interface: new Response() must inherit property "url" with the proper type (3) >+PASS Response interface: new Response() must inherit property "status" with the proper type (4) >+PASS Response interface: new Response() must inherit property "ok" with the proper type (5) >+PASS Response interface: new Response() must inherit property "statusText" with the proper type (6) >+PASS Response interface: new Response() must inherit property "headers" with the proper type (7) >+PASS Response interface: new Response() must inherit property "body" with the proper type (8) >+PASS Response interface: new Response() must inherit property "clone" with the proper type (9) >+PASS Response interface: new Response() must inherit property "bodyUsed" with the proper type (10) >+PASS Response interface: new Response() must inherit property "arrayBuffer" with the proper type (11) >+PASS Response interface: new Response() must inherit property "blob" with the proper type (12) >+PASS Response interface: new Response() must inherit property "formData" with the proper type (13) >+PASS Response interface: new Response() must inherit property "json" with the proper type (14) >+PASS Response interface: new Response() must inherit property "text" with the proper type (15) >+ >diff --git a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-idl.html b/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-idl.html >new file mode 100644 >index 0000000000000000000000000000000000000000..79ddf75cb205521dd7fe12468cce17500893c1d1 >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-idl.html >@@ -0,0 +1,69 @@ >+<!doctype html> >+<html> >+ <head> >+ <meta charset="utf-8"> >+ <title>Response idl interface</title> >+ <meta name="help" href="https://fetch.spec.whatwg.org/#response"> >+ <meta name="author" title="Canon Research France" href="https://www.crf.canon.fr"> >+ <script src="/resources/testharness.js"></script> >+ <script src="/resources/testharnessreport.js"></script> >+ <script src="/resources/WebIDLParser.js"></script> >+ <script src="/resources/idlharness.js"></script> >+ </head> >+ <body> >+ <script id="body-idl" type="text/plain"> >+ typedef any JSON; >+ typedef (Blob or BufferSource or FormData or URLSearchParams or USVString) BodyInit; >+ >+ [NoInterfaceObject, >+ Exposed=(Window,Worker)] >+ interface Body { >+ readonly attribute boolean bodyUsed; >+ [NewObject] Promise<ArrayBuffer> arrayBuffer(); >+ [NewObject] Promise<Blob> blob(); >+ [NewObject] Promise<FormData> formData(); >+ [NewObject] Promise<JSON> json(); >+ [NewObject] Promise<USVString> text(); >+ }; >+ </script> >+ <script id="response-idl" type="text/plain"> >+ [Constructor(optional BodyInit body, optional ResponseInit init), >+ Exposed=(Window,Worker)] >+ interface Response { >+ [NewObject] static Response error(); >+ [NewObject] static Response redirect(USVString url, optional unsigned short status = 302); >+ >+ readonly attribute ResponseType type; >+ >+ readonly attribute USVString url; >+ readonly attribute unsigned short status; >+ readonly attribute boolean ok; >+ readonly attribute ByteString statusText; >+ [SameObject] readonly attribute Headers headers; >+ [SameObject] readonly attribute ReadableStream body; >+ >+ [NewObject] Response clone(); >+ }; >+ Response implements Body; >+ >+ dictionary ResponseInit { >+ unsigned short status = 200; >+ ByteString statusText = "OK"; >+ HeadersInit headers; >+ }; >+ >+ enum ResponseType { "basic", "cors", "default", "error", "opaque", "opaqueredirect" }; >+ </script> >+ <script> >+ var idlsArray = new IdlArray(); >+ var idl = document.getElementById("body-idl").innerHTML >+ idl += document.getElementById("response-idl").innerHTML >+ >+ idlsArray.add_idls(idl); >+ idlsArray.add_untested_idls("interface Headers {};"); >+ idlsArray.add_untested_idls("interface ReadableStream {};"); >+ idlsArray.add_objects({ Response: ['new Response()'] }); >+ idlsArray.test(); >+ </script> >+ </body> >+</html> >\ No newline at end of file >diff --git a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-init-001-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-init-001-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..97de405380fe9d8519db3efcb8019babe29469fc >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-init-001-expected.txt >@@ -0,0 +1,10 @@ >+ >+PASS Check default value for type attribute >+PASS Check default value for url attribute >+PASS Check default value for ok attribute >+PASS Check default value for status attribute >+PASS Check default value for statusText attribute >+PASS Check default value for body attribute >+PASS Check status init values and associated getter >+PASS Check statusText init values and associated getter >+ >diff --git a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-init-001.html b/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-init-001.html >new file mode 100644 >index 0000000000000000000000000000000000000000..e36f90e4c827981307e243446e2448d1bc3199e0 >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-init-001.html >@@ -0,0 +1,63 @@ >+<!doctype html> >+<html> >+ <head> >+ <meta charset="utf-8"> >+ <title>Response init: simple cases</title> >+ <meta name="help" href="https://fetch.spec.whatwg.org/#response"> >+ <meta name="help" href="https://fetch.spec.whatwg.org/#concept-response"> >+ <meta name="author" title="Canon Research France" href="https://www.crf.canon.fr"> >+ <script src="/resources/testharness.js"></script> >+ <script src="/resources/testharnessreport.js"></script> >+ </head> >+ <body> >+ <script> >+ var defaultValues = { "type" : "default", >+ "url" : "", >+ "ok" : true, >+ "status" : 200, >+ "statusText" : "OK", >+ "body" : null >+ }; >+ >+ var statusCodes = { "givenValues" : [200, 300, 400, 500, 599], >+ "expectedValues" : [200, 300, 400, 500, 599] >+ }; >+ var statusTexts = { "givenValues" : ["OK", "with space", String.fromCharCode(0x80)], >+ "expectedValues" : ["OK", "with space", String.fromCharCode(0x80)] >+ }; >+ var initValuesDict = { "status" : statusCodes, >+ "statusText" : statusTexts >+ }; >+ >+ function isOkStatus(status) { >+ return 200 <= status && 299 >= status; >+ } >+ >+ var response = new Response(); >+ for (var attributeName in defaultValues) { >+ test(function() { >+ var expectedValue = defaultValues[attributeName]; >+ assert_equals(response[attributeName], expectedValue, >+ "Expect default response." + attributeName + " is " + expectedValue); >+ }, "Check default value for " + attributeName + " attribute"); >+ } >+ >+ for (var attributeName in initValuesDict) >+ test(function() { >+ var valuesToTest = initValuesDict[attributeName]; >+ for (var valueIdx in valuesToTest["givenValues"]) { >+ var givenValue = valuesToTest["givenValues"][valueIdx]; >+ var expectedValue = valuesToTest["expectedValues"][valueIdx]; >+ var responseInit = {}; >+ responseInit[attributeName] = givenValue; >+ var response = new Response("", responseInit); >+ assert_equals(response[attributeName], expectedValue, >+ "Expect response." + attributeName + " is " + expectedValue + >+ " when initialized with " + givenValue); >+ assert_equals(response.ok, isOkStatus(response.status), >+ "Expect response.ok is " + isOkStatus(response.status)); >+ } >+ }, "Check " + attributeName + " init values and associated getter"); >+ </script> >+ </body> >+</html> >\ No newline at end of file >diff --git a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-init-002-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-init-002-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..ab60ee16ed073c5a22669ec60ca98130df960c86 >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-init-002-expected.txt >@@ -0,0 +1,8 @@ >+ >+PASS Initialize Response with headers values >+FAIL Initialize Response's body with application/octet-binary promise_test: Unhandled rejection with value: undefined >+FAIL Initialize Response's body with multipart/form-data promise_test: Unhandled rejection with value: undefined >+FAIL Initialize Response's body with application/x-www-form-urlencoded;charset=UTF-8 assert_true: Content-Type header should be "application/x-www-form-urlencoded;charset=UTF-8" expected true got false >+PASS Initialize Response's body with text/plain;charset=UTF-8 >+FAIL Read Response's body as readableStream null is not an object (evaluating 'response.body.getReader') >+ >diff --git a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-init-002.html b/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-init-002.html >new file mode 100644 >index 0000000000000000000000000000000000000000..1baf7fb355bb91212c346e018ae35f9e7ed8aad0 >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-init-002.html >@@ -0,0 +1,62 @@ >+<!doctype html> >+<html> >+ <head> >+ <meta charset="utf-8"> >+ <title>Response init: body and headers</title> >+ <meta name="help" href="https://fetch.spec.whatwg.org/#response"> >+ <meta name="help" href="https://fetch.spec.whatwg.org/#concept-response"> >+ <meta name="author" title="Canon Research France" href="https://www.crf.canon.fr"> >+ <script src="/resources/testharness.js"></script> >+ <script src="/resources/testharnessreport.js"></script> >+ </head> >+ <body> >+ <script src="../resources/utils.js"></script> >+ <script> >+ test(function() { >+ var headerDict = {"name1": "value1", >+ "name2": "value2", >+ "name3": "value3" >+ }; >+ var headers = new Headers(headerDict); >+ var response = new Response("", { "headers" : headers }) >+ for (var name in headerDict) { >+ assert_equals(response.headers.get(name), headerDict[name], >+ "response's headers has " + name + " : " + headerDict[name]); >+ } >+ }, "Initialize Response with headers values"); >+ >+ function checkResponseInit(body, bodyType, expectedTextBody) { >+ promise_test(function(test) { >+ var response = new Response(body); >+ var resHeaders = response.headers; >+ var mime = resHeaders.get("Content-Type"); >+ assert_true(mime && mime.search(bodyType) > -1, "Content-Type header should be \"" + bodyType + "\" "); >+ return response.text().then(function(bodyAsText) { >+ //not equals: cannot guess formData exact value >+ assert_true( bodyAsText.search(expectedTextBody) > -1, "Retrieve and verify response body"); >+ }); >+ }, "Initialize Response's body with " + bodyType); >+ } >+ >+ var blob = new Blob(["This is a blob"], {type: "application/octet-binary"}); >+ var formaData = new FormData(); >+ formaData.append("name", "value"); >+ var urlSearchParams = "URLSearchParams are not supported"; >+ //avoid test timeout if not implemented >+ if (window.URLSearchParams) >+ urlSearchParams = new URLSearchParams("name=value"); >+ var usvString = "This is a USVString" >+ >+ checkResponseInit(blob, "application/octet-binary", "This is a blob"); >+ checkResponseInit(formaData, "multipart/form-data", "name=\"name\"\r\n\r\nvalue"); >+ checkResponseInit(urlSearchParams, "application/x-www-form-urlencoded;charset=UTF-8", "name=value"); >+ checkResponseInit(usvString, "text/plain;charset=UTF-8", "This is a USVString"); >+ >+ async_test(function(test) { >+ var body = "This is response body"; >+ var response = new Response(body); >+ readTextStream(response.body.getReader(), test, body); >+ }, "Read Response's body as readableStream"); >+ </script> >+ </body> >+</html> >diff --git a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-static-error-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-static-error-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..0a5c85e8f19030034ea267f236ffd6eed05f20d0 >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-static-error-expected.txt >@@ -0,0 +1,3 @@ >+ >+PASS Check response returned by static method error() >+ >diff --git a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-static-error.html b/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-static-error.html >new file mode 100644 >index 0000000000000000000000000000000000000000..d63bd5e3e5ef2bb192dad146d4c4e195fd5908a3 >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-static-error.html >@@ -0,0 +1,23 @@ >+<!doctype html> >+<html> >+ <head> >+ <meta charset="utf-8"> >+ <title>Response: error static method</title> >+ <meta name="help" href="https://fetch.spec.whatwg.org/#response"> >+ <meta name="help" href="https://fetch.spec.whatwg.org/#concept-network-error"> >+ <meta name="author" title="Canon Research France" href="https://www.crf.canon.fr"> >+ <script src="/resources/testharness.js"></script> >+ <script src="/resources/testharnessreport.js"></script> >+ </head> >+ <body> >+ <script> >+ test(function() { >+ var responseError = Response.error(); >+ assert_equals(responseError.type, "error", "Network error response's type is error"); >+ assert_equals(responseError.status, 0, "Network error response's status is 0"); >+ assert_equals(responseError.statusText, "", "Network error response's statusText is empty"); >+ assert_equals(responseError.body, null, "Network error response's body is null"); >+ }, "Check response returned by static method error()"); >+ </script> >+ </body> >+</html> >\ No newline at end of file >diff --git a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-static-redirect-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-static-redirect-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..7fd27fdd47fdb85745114fae4f43f20c068002ba >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-static-redirect-expected.txt >@@ -0,0 +1,4 @@ >+ >+PASS Check response returned by static method redirect() >+FAIL Check error returned when giving invalid parameters to redirect() assert_throws: Expect RangeError exception function "function () { Response.redirect("", invalidStatus); }" threw object "TypeError: Type error" ("TypeError") expected object "RangeError" ("RangeError") >+ >diff --git a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-static-redirect.html b/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-static-redirect.html >new file mode 100644 >index 0000000000000000000000000000000000000000..1dc092f54a7243edd7c661bc33382a304c94056d >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-static-redirect.html >@@ -0,0 +1,41 @@ >+<!doctype html> >+<html> >+ <head> >+ <meta charset="utf-8"> >+ <title>Response: redirect static method</title> >+ <meta name="help" href="https://fetch.spec.whatwg.org/#response"> >+ <meta name="help" href="https://fetch.spec.whatwg.org/#redirect-status"> >+ <meta name="author" title="Canon Research France" href="https://www.crf.canon.fr"> >+ <script src="/resources/testharness.js"></script> >+ <script src="/resources/testharnessreport.js"></script> >+ </head> >+ <body> >+ <script> >+ test(function() { >+ var redirectStatus = [301, 302, 303, 307, 308]; >+ var url = "http://test.url:1234/"; >+ redirectResponse = Response.redirect(url); >+ assert_equals(redirectResponse.status, 302, "Default redictect status is 302"); >+ assert_equals(redirectResponse.headers.get("Location"), url, >+ "redirected response has Location header with the correct url"); >+ for (var i in redirectStatus) { >+ var status = redirectStatus[i]; >+ redirectResponse = Response.redirect(url, status); >+ assert_equals(redirectResponse.status, status, "Redictect status is " + status); >+ } >+ }, "Check response returned by static method redirect()"); >+ >+ test(function() { >+ var invalidRedirectStatus = [200, 309, 400, 500]; >+ var invalidUrl = "This is not an url"; >+ for (var i in invalidRedirectStatus) { >+ var invalidStatus = invalidRedirectStatus[i]; >+ assert_throws(new RangeError() , function() { Response.redirect("", invalidStatus); }, >+ "Expect RangeError exception"); >+ } >+ assert_throws(new TypeError(), function() { Response.redirect(invalidUrl); }, >+ "Expect TypeError exception"); >+ }, "Check error returned when giving invalid parameters to redirect()"); >+ </script> >+ </body> >+</html> >\ No newline at end of file >diff --git a/LayoutTests/js/dom/global-constructors-attributes-dedicated-worker-expected.txt b/LayoutTests/js/dom/global-constructors-attributes-dedicated-worker-expected.txt >index ffd95311dc5d0a75e0cd4e440784e1a4d64ef2c3..e058cff95bb22da5933137a9fcae96aa9b842a7a 100644 >--- a/LayoutTests/js/dom/global-constructors-attributes-dedicated-worker-expected.txt >+++ b/LayoutTests/js/dom/global-constructors-attributes-dedicated-worker-expected.txt >@@ -169,6 +169,11 @@ PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Request').hasOwnProperty( > PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Request').hasOwnProperty('set') is false > PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Request').enumerable is false > PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Request').configurable is true >+PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Response').value is Response >+PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Response').hasOwnProperty('get') is false >+PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Response').hasOwnProperty('set') is false >+PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Response').enumerable is false >+PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Response').configurable is true > PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Set').value is Set > PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Set').hasOwnProperty('get') is false > PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Set').hasOwnProperty('set') is false >diff --git a/LayoutTests/js/dom/global-constructors-attributes-expected.txt b/LayoutTests/js/dom/global-constructors-attributes-expected.txt >index 15a4aeaa900236d61d501b344b3a770d4ad9df31..b0078e330b2134fcb384e2279e9359dc2332bbaa 100644 >--- a/LayoutTests/js/dom/global-constructors-attributes-expected.txt >+++ b/LayoutTests/js/dom/global-constructors-attributes-expected.txt >@@ -993,6 +993,11 @@ PASS Object.getOwnPropertyDescriptor(global, 'Request').hasOwnProperty('get') is > PASS Object.getOwnPropertyDescriptor(global, 'Request').hasOwnProperty('set') is false > PASS Object.getOwnPropertyDescriptor(global, 'Request').enumerable is false > PASS Object.getOwnPropertyDescriptor(global, 'Request').configurable is true >+PASS Object.getOwnPropertyDescriptor(global, 'Response').value is Response >+PASS Object.getOwnPropertyDescriptor(global, 'Response').hasOwnProperty('get') is false >+PASS Object.getOwnPropertyDescriptor(global, 'Response').hasOwnProperty('set') is false >+PASS Object.getOwnPropertyDescriptor(global, 'Response').enumerable is false >+PASS Object.getOwnPropertyDescriptor(global, 'Response').configurable is true > PASS Object.getOwnPropertyDescriptor(global, 'SQLException').value is SQLException > PASS Object.getOwnPropertyDescriptor(global, 'SQLException').hasOwnProperty('get') is false > PASS Object.getOwnPropertyDescriptor(global, 'SQLException').hasOwnProperty('set') is false >diff --git a/LayoutTests/platform/efl/js/dom/global-constructors-attributes-dedicated-worker-expected.txt b/LayoutTests/platform/efl/js/dom/global-constructors-attributes-dedicated-worker-expected.txt >index fc7204ff2ebf90881380886bdca76cce3461119b..2cc9ac35ef4576cfad36d8692af3864be22f3068 100644 >--- a/LayoutTests/platform/efl/js/dom/global-constructors-attributes-dedicated-worker-expected.txt >+++ b/LayoutTests/platform/efl/js/dom/global-constructors-attributes-dedicated-worker-expected.txt >@@ -69,6 +69,11 @@ PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Request').hasOwnProperty( > PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Request').hasOwnProperty('set') is false > PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Request').enumerable is false > PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Request').configurable is true >+PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Response').value is Response >+PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Response').hasOwnProperty('get') is false >+PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Response').hasOwnProperty('set') is false >+PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Response').enumerable is false >+PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Response').configurable is true > PASS [Worker] Object.getOwnPropertyDescriptor(global, 'URL').value is URL > PASS [Worker] Object.getOwnPropertyDescriptor(global, 'URL').hasOwnProperty('get') is false > PASS [Worker] Object.getOwnPropertyDescriptor(global, 'URL').hasOwnProperty('set') is false >diff --git a/LayoutTests/platform/efl/js/dom/global-constructors-attributes-expected.txt b/LayoutTests/platform/efl/js/dom/global-constructors-attributes-expected.txt >index 012bf08cdc9c85faeb4c29eedc778210757eab77..08e4f5c995242d555f5a349c72ee28abf862bbf8 100644 >--- a/LayoutTests/platform/efl/js/dom/global-constructors-attributes-expected.txt >+++ b/LayoutTests/platform/efl/js/dom/global-constructors-attributes-expected.txt >@@ -1063,6 +1063,11 @@ PASS Object.getOwnPropertyDescriptor(global, 'Request').hasOwnProperty('get') is > PASS Object.getOwnPropertyDescriptor(global, 'Request').hasOwnProperty('set') is false > PASS Object.getOwnPropertyDescriptor(global, 'Request').enumerable is false > PASS Object.getOwnPropertyDescriptor(global, 'Request').configurable is true >+PASS Object.getOwnPropertyDescriptor(global, 'Response').value is Response >+PASS Object.getOwnPropertyDescriptor(global, 'Response').hasOwnProperty('get') is false >+PASS Object.getOwnPropertyDescriptor(global, 'Response').hasOwnProperty('set') is false >+PASS Object.getOwnPropertyDescriptor(global, 'Response').enumerable is false >+PASS Object.getOwnPropertyDescriptor(global, 'Response').configurable is true > PASS Object.getOwnPropertyDescriptor(global, 'SQLException').value is SQLException > PASS Object.getOwnPropertyDescriptor(global, 'SQLException').hasOwnProperty('get') is false > PASS Object.getOwnPropertyDescriptor(global, 'SQLException').hasOwnProperty('set') is false >diff --git a/LayoutTests/platform/gtk/js/dom/global-constructors-attributes-expected.txt b/LayoutTests/platform/gtk/js/dom/global-constructors-attributes-expected.txt >index c4e5c4cb50bfa4e99f048fbce8ec61d8abbe0bc6..5d88e5de9ebfe6ec4e84cbbdb134885dd51a5bcb 100644 >--- a/LayoutTests/platform/gtk/js/dom/global-constructors-attributes-expected.txt >+++ b/LayoutTests/platform/gtk/js/dom/global-constructors-attributes-expected.txt >@@ -1083,6 +1083,11 @@ PASS Object.getOwnPropertyDescriptor(global, 'Request').hasOwnProperty('get') is > PASS Object.getOwnPropertyDescriptor(global, 'Request').hasOwnProperty('set') is false > PASS Object.getOwnPropertyDescriptor(global, 'Request').enumerable is false > PASS Object.getOwnPropertyDescriptor(global, 'Request').configurable is true >+PASS Object.getOwnPropertyDescriptor(global, 'Response').value is Response >+PASS Object.getOwnPropertyDescriptor(global, 'Response').hasOwnProperty('get') is false >+PASS Object.getOwnPropertyDescriptor(global, 'Response').hasOwnProperty('set') is false >+PASS Object.getOwnPropertyDescriptor(global, 'Response').enumerable is false >+PASS Object.getOwnPropertyDescriptor(global, 'Response').configurable is true > PASS Object.getOwnPropertyDescriptor(global, 'SQLException').value is SQLException > PASS Object.getOwnPropertyDescriptor(global, 'SQLException').hasOwnProperty('get') is false > PASS Object.getOwnPropertyDescriptor(global, 'SQLException').hasOwnProperty('set') is false >diff --git a/LayoutTests/platform/mac-mavericks/js/dom/global-constructors-attributes-expected.txt b/LayoutTests/platform/mac-mavericks/js/dom/global-constructors-attributes-expected.txt >index e60e45512ea896619c7b21341c2c2ca82dcab8b0..25b73f7bba804209f5bcdf1e5b59f12c12c7650b 100644 >--- a/LayoutTests/platform/mac-mavericks/js/dom/global-constructors-attributes-expected.txt >+++ b/LayoutTests/platform/mac-mavericks/js/dom/global-constructors-attributes-expected.txt >@@ -1073,6 +1073,11 @@ PASS Object.getOwnPropertyDescriptor(global, 'Request').hasOwnProperty('get') is > PASS Object.getOwnPropertyDescriptor(global, 'Request').hasOwnProperty('set') is false > PASS Object.getOwnPropertyDescriptor(global, 'Request').enumerable is false > PASS Object.getOwnPropertyDescriptor(global, 'Request').configurable is true >+PASS Object.getOwnPropertyDescriptor(global, 'Response').value is Response >+PASS Object.getOwnPropertyDescriptor(global, 'Response').hasOwnProperty('get') is false >+PASS Object.getOwnPropertyDescriptor(global, 'Response').hasOwnProperty('set') is false >+PASS Object.getOwnPropertyDescriptor(global, 'Response').enumerable is false >+PASS Object.getOwnPropertyDescriptor(global, 'Response').configurable is true > PASS Object.getOwnPropertyDescriptor(global, 'SQLException').value is SQLException > PASS Object.getOwnPropertyDescriptor(global, 'SQLException').hasOwnProperty('get') is false > PASS Object.getOwnPropertyDescriptor(global, 'SQLException').hasOwnProperty('set') is false >diff --git a/LayoutTests/platform/mac-yosemite/js/dom/global-constructors-attributes-expected.txt b/LayoutTests/platform/mac-yosemite/js/dom/global-constructors-attributes-expected.txt >index 774478eede2ec89ba66cff9359d04bdd970a1843..03c2f8a3c843a01db492123c55a3edd610a0fc6c 100644 >--- a/LayoutTests/platform/mac-yosemite/js/dom/global-constructors-attributes-expected.txt >+++ b/LayoutTests/platform/mac-yosemite/js/dom/global-constructors-attributes-expected.txt >@@ -1198,6 +1198,11 @@ PASS Object.getOwnPropertyDescriptor(global, 'Request').hasOwnProperty('get') is > PASS Object.getOwnPropertyDescriptor(global, 'Request').hasOwnProperty('set') is false > PASS Object.getOwnPropertyDescriptor(global, 'Request').enumerable is false > PASS Object.getOwnPropertyDescriptor(global, 'Request').configurable is true >+PASS Object.getOwnPropertyDescriptor(global, 'Response').value is Response >+PASS Object.getOwnPropertyDescriptor(global, 'Response').hasOwnProperty('get') is false >+PASS Object.getOwnPropertyDescriptor(global, 'Response').hasOwnProperty('set') is false >+PASS Object.getOwnPropertyDescriptor(global, 'Response').enumerable is false >+PASS Object.getOwnPropertyDescriptor(global, 'Response').configurable is true > PASS Object.getOwnPropertyDescriptor(global, 'SQLException').value is SQLException > PASS Object.getOwnPropertyDescriptor(global, 'SQLException').hasOwnProperty('get') is false > PASS Object.getOwnPropertyDescriptor(global, 'SQLException').hasOwnProperty('set') is false >diff --git a/LayoutTests/platform/mac/js/dom/global-constructors-attributes-expected.txt b/LayoutTests/platform/mac/js/dom/global-constructors-attributes-expected.txt >index bda416596716ce8fe4fb5bcd1ca57e116b40e087..77d488bbdef4cd626b200fee67f0d6da2c0782db 100644 >--- a/LayoutTests/platform/mac/js/dom/global-constructors-attributes-expected.txt >+++ b/LayoutTests/platform/mac/js/dom/global-constructors-attributes-expected.txt >@@ -1198,6 +1198,11 @@ PASS Object.getOwnPropertyDescriptor(global, 'Request').hasOwnProperty('get') is > PASS Object.getOwnPropertyDescriptor(global, 'Request').hasOwnProperty('set') is false > PASS Object.getOwnPropertyDescriptor(global, 'Request').enumerable is false > PASS Object.getOwnPropertyDescriptor(global, 'Request').configurable is true >+PASS Object.getOwnPropertyDescriptor(global, 'Response').value is Response >+PASS Object.getOwnPropertyDescriptor(global, 'Response').hasOwnProperty('get') is false >+PASS Object.getOwnPropertyDescriptor(global, 'Response').hasOwnProperty('set') is false >+PASS Object.getOwnPropertyDescriptor(global, 'Response').enumerable is false >+PASS Object.getOwnPropertyDescriptor(global, 'Response').configurable is true > PASS Object.getOwnPropertyDescriptor(global, 'SQLException').value is SQLException > PASS Object.getOwnPropertyDescriptor(global, 'SQLException').hasOwnProperty('get') is false > PASS Object.getOwnPropertyDescriptor(global, 'SQLException').hasOwnProperty('set') is false >diff --git a/LayoutTests/platform/win/js/dom/global-constructors-attributes-expected.txt b/LayoutTests/platform/win/js/dom/global-constructors-attributes-expected.txt >index 540f9a58923cd5a09aff9f843fff1e3ac5eaf96f..c2a9551f17bdb3cc9345239022cf01d3d2127dfa 100644 >--- a/LayoutTests/platform/win/js/dom/global-constructors-attributes-expected.txt >+++ b/LayoutTests/platform/win/js/dom/global-constructors-attributes-expected.txt >@@ -913,6 +913,11 @@ PASS Object.getOwnPropertyDescriptor(global, 'Request').hasOwnProperty('get') is > PASS Object.getOwnPropertyDescriptor(global, 'Request').hasOwnProperty('set') is false > PASS Object.getOwnPropertyDescriptor(global, 'Request').enumerable is false > PASS Object.getOwnPropertyDescriptor(global, 'Request').configurable is true >+PASS Object.getOwnPropertyDescriptor(global, 'Response').value is Response >+PASS Object.getOwnPropertyDescriptor(global, 'Response').hasOwnProperty('get') is false >+PASS Object.getOwnPropertyDescriptor(global, 'Response').hasOwnProperty('set') is false >+PASS Object.getOwnPropertyDescriptor(global, 'Response').enumerable is false >+PASS Object.getOwnPropertyDescriptor(global, 'Response').configurable is true > PASS Object.getOwnPropertyDescriptor(global, 'SQLException').value is SQLException > PASS Object.getOwnPropertyDescriptor(global, 'SQLException').hasOwnProperty('get') is false > PASS Object.getOwnPropertyDescriptor(global, 'SQLException').hasOwnProperty('set') is false
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 154536
:
271924
|
272132