Changeset 195954 in webkit
- Timestamp:
- Feb 1, 2016 3:05:39 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 36 added
- 23 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r195953 r195954 1 2016-02-01 Youenn Fablet <youenn.fablet@crf.canon.fr> 2 3 [Fetch API] Implement Fetch API Request 4 https://bugs.webkit.org/show_bug.cgi?id=153437 5 6 Reviewed by Darin Adler. 7 8 * js/dom/global-constructors-attributes-dedicated-worker-expected.txt: 9 * js/dom/global-constructors-attributes-expected.txt: 10 * platform/efl/js/dom/global-constructors-attributes-dedicated-worker-expected.txt: 11 * platform/efl/js/dom/global-constructors-attributes-expected.txt: 12 * platform/gtk/js/dom/global-constructors-attributes-expected.txt: 13 * platform/mac-mavericks/js/dom/global-constructors-attributes-expected.txt: 14 * platform/mac-yosemite/js/dom/global-constructors-attributes-expected.txt: 15 * platform/mac/js/dom/global-constructors-attributes-expected.txt: 16 * platform/win/js/dom/global-constructors-attributes-expected.txt: 17 1 18 2016-01-31 Jeremy Jones <jeremyj@apple.com> 2 19 -
trunk/LayoutTests/imported/w3c/ChangeLog
r195953 r195954 1 2016-02-01 Youenn Fablet <youenn.fablet@crf.canon.fr> 2 3 [Fetch API] Implement Fetch API Request 4 https://bugs.webkit.org/show_bug.cgi?id=153437 5 6 Reviewed by Darin Adler. 7 8 * web-platform-tests/fetch/api/headers/headers-basic.html: 9 * web-platform-tests/fetch/api/request/request-clone.sub-expected.txt: Added. 10 * web-platform-tests/fetch/api/request/request-clone.sub.html: Added. 11 * web-platform-tests/fetch/api/request/request-consume-expected.txt: Added. 12 * web-platform-tests/fetch/api/request/request-consume.html: Added. 13 * web-platform-tests/fetch/api/request/request-disturbed-expected.txt: Added. 14 * web-platform-tests/fetch/api/request/request-disturbed.html: Added. 15 * web-platform-tests/fetch/api/request/request-error-expected.txt: Added. 16 * web-platform-tests/fetch/api/request/request-error.html: Added. 17 * web-platform-tests/fetch/api/request/request-headers-expected.txt: Added. 18 * web-platform-tests/fetch/api/request/request-headers.html: Added. 19 * web-platform-tests/fetch/api/request/request-idl-expected.txt: Added. 20 * web-platform-tests/fetch/api/request/request-idl.html: Added. 21 * web-platform-tests/fetch/api/request/request-init-001.sub-expected.txt: Added. 22 * web-platform-tests/fetch/api/request/request-init-001.sub.html: Added. 23 * web-platform-tests/fetch/api/request/request-init-002-expected.txt: Added. 24 * web-platform-tests/fetch/api/request/request-init-002.html: Added. 25 * web-platform-tests/fetch/api/request/request-init-003.sub-expected.txt: Added. 26 * web-platform-tests/fetch/api/request/request-init-003.sub.html: Added. 27 * web-platform-tests/fetch/api/request/request-structure-expected.txt: Added. 28 * web-platform-tests/fetch/api/request/request-structure.html: Added. 29 * web-platform-tests/fetch/api/resources/authentication.py: Added. 30 (main): 31 * web-platform-tests/fetch/api/resources/clean-stash.py: Added. 32 (main): 33 * web-platform-tests/fetch/api/resources/inspect-headers.py: Added. 34 (main): 35 * web-platform-tests/fetch/api/resources/method.py: Added. 36 (main): 37 * web-platform-tests/fetch/api/resources/preflight.py: Added. 38 (main): 39 * web-platform-tests/fetch/api/resources/redirect.py: Added. 40 (main): 41 * web-platform-tests/fetch/api/resources/top.txt: Added. 42 * web-platform-tests/fetch/api/resources/trickle.py: Added. 43 (main): 44 * web-platform-tests/fetch/api/resources/utils.js: Added. 45 (catch): 46 (dirname): 47 (checkRequest): 48 (readTextStream): 49 1 50 2016-01-31 Jeremy Jones <jeremyj@apple.com> 2 51 -
trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/headers/headers-basic.html
r195530 r195954 49 49 "name: " + name + " has value: " + headerDict[name]); 50 50 } 51 assert_equals(headers.get("length"), null, "init should be treated as a sequence, not as a dictionary"); 51 52 }, "Create headers with sequence"); 52 53 -
trunk/LayoutTests/js/dom/global-constructors-attributes-dedicated-worker-expected.txt
r195530 r195954 65 65 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'ReadableStream').enumerable is false 66 66 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'ReadableStream').configurable is true 67 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Request').value is Request 68 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Request').hasOwnProperty('get') is false 69 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Request').hasOwnProperty('set') is false 70 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Request').enumerable is false 71 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Request').configurable is true 67 72 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'URL').value is URL 68 73 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'URL').hasOwnProperty('get') is false -
trunk/LayoutTests/js/dom/global-constructors-attributes-expected.txt
r195731 r195954 939 939 PASS Object.getOwnPropertyDescriptor(global, 'ProgressEvent').enumerable is false 940 940 PASS Object.getOwnPropertyDescriptor(global, 'ProgressEvent').configurable is true 941 PASS Object.getOwnPropertyDescriptor(global, 'Request').value is Request 942 PASS Object.getOwnPropertyDescriptor(global, 'Request').hasOwnProperty('get') is false 943 PASS Object.getOwnPropertyDescriptor(global, 'Request').hasOwnProperty('set') is false 944 PASS Object.getOwnPropertyDescriptor(global, 'Request').enumerable is false 945 PASS Object.getOwnPropertyDescriptor(global, 'Request').configurable is true 941 946 PASS Object.getOwnPropertyDescriptor(global, 'RGBColor').value is RGBColor 942 947 PASS Object.getOwnPropertyDescriptor(global, 'RGBColor').hasOwnProperty('get') is false -
trunk/LayoutTests/platform/efl/js/dom/global-constructors-attributes-dedicated-worker-expected.txt
r195530 r195954 65 65 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'ReadableStream').enumerable is false 66 66 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'ReadableStream').configurable is true 67 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Request').value is Request 68 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Request').hasOwnProperty('get') is false 69 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Request').hasOwnProperty('set') is false 70 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Request').enumerable is false 71 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Request').configurable is true 67 72 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'URL').value is URL 68 73 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'URL').hasOwnProperty('get') is false -
trunk/LayoutTests/platform/efl/js/dom/global-constructors-attributes-expected.txt
r195731 r195954 999 999 PASS Object.getOwnPropertyDescriptor(global, 'ProgressEvent').enumerable is false 1000 1000 PASS Object.getOwnPropertyDescriptor(global, 'ProgressEvent').configurable is true 1001 PASS Object.getOwnPropertyDescriptor(global, 'Request').value is Request 1002 PASS Object.getOwnPropertyDescriptor(global, 'Request').hasOwnProperty('get') is false 1003 PASS Object.getOwnPropertyDescriptor(global, 'Request').hasOwnProperty('set') is false 1004 PASS Object.getOwnPropertyDescriptor(global, 'Request').enumerable is false 1005 PASS Object.getOwnPropertyDescriptor(global, 'Request').configurable is true 1001 1006 PASS Object.getOwnPropertyDescriptor(global, 'RGBColor').value is RGBColor 1002 1007 PASS Object.getOwnPropertyDescriptor(global, 'RGBColor').hasOwnProperty('get') is false -
trunk/LayoutTests/platform/gtk/js/dom/global-constructors-attributes-expected.txt
r195731 r195954 1019 1019 PASS Object.getOwnPropertyDescriptor(global, 'ProgressEvent').enumerable is false 1020 1020 PASS Object.getOwnPropertyDescriptor(global, 'ProgressEvent').configurable is true 1021 PASS Object.getOwnPropertyDescriptor(global, 'Request').value is Request 1022 PASS Object.getOwnPropertyDescriptor(global, 'Request').hasOwnProperty('get') is false 1023 PASS Object.getOwnPropertyDescriptor(global, 'Request').hasOwnProperty('set') is false 1024 PASS Object.getOwnPropertyDescriptor(global, 'Request').enumerable is false 1025 PASS Object.getOwnPropertyDescriptor(global, 'Request').configurable is true 1021 1026 PASS Object.getOwnPropertyDescriptor(global, 'RGBColor').value is RGBColor 1022 1027 PASS Object.getOwnPropertyDescriptor(global, 'RGBColor').hasOwnProperty('get') is false -
trunk/LayoutTests/platform/mac-mavericks/js/dom/global-constructors-attributes-expected.txt
r195731 r195954 999 999 PASS Object.getOwnPropertyDescriptor(global, 'ProgressEvent').enumerable is false 1000 1000 PASS Object.getOwnPropertyDescriptor(global, 'ProgressEvent').configurable is true 1001 PASS Object.getOwnPropertyDescriptor(global, 'Request').value is Request 1002 PASS Object.getOwnPropertyDescriptor(global, 'Request').hasOwnProperty('get') is false 1003 PASS Object.getOwnPropertyDescriptor(global, 'Request').hasOwnProperty('set') is false 1004 PASS Object.getOwnPropertyDescriptor(global, 'Request').enumerable is false 1005 PASS Object.getOwnPropertyDescriptor(global, 'Request').configurable is true 1001 1006 PASS Object.getOwnPropertyDescriptor(global, 'RGBColor').value is RGBColor 1002 1007 PASS Object.getOwnPropertyDescriptor(global, 'RGBColor').hasOwnProperty('get') is false -
trunk/LayoutTests/platform/mac-yosemite/js/dom/global-constructors-attributes-expected.txt
r195731 r195954 1074 1074 PASS Object.getOwnPropertyDescriptor(global, 'Rect').enumerable is false 1075 1075 PASS Object.getOwnPropertyDescriptor(global, 'Rect').configurable is true 1076 PASS Object.getOwnPropertyDescriptor(global, 'Request').value is Request 1077 PASS Object.getOwnPropertyDescriptor(global, 'Request').hasOwnProperty('get') is false 1078 PASS Object.getOwnPropertyDescriptor(global, 'Request').hasOwnProperty('set') is false 1079 PASS Object.getOwnPropertyDescriptor(global, 'Request').enumerable is false 1080 PASS Object.getOwnPropertyDescriptor(global, 'Request').configurable is true 1076 1081 PASS Object.getOwnPropertyDescriptor(global, 'SQLException').value is SQLException 1077 1082 PASS Object.getOwnPropertyDescriptor(global, 'SQLException').hasOwnProperty('get') is false -
trunk/LayoutTests/platform/mac/js/dom/global-constructors-attributes-expected.txt
r195731 r195954 1024 1024 PASS Object.getOwnPropertyDescriptor(global, 'ProgressEvent').enumerable is false 1025 1025 PASS Object.getOwnPropertyDescriptor(global, 'ProgressEvent').configurable is true 1026 PASS Object.getOwnPropertyDescriptor(global, 'Request').value is Request 1027 PASS Object.getOwnPropertyDescriptor(global, 'Request').hasOwnProperty('get') is false 1028 PASS Object.getOwnPropertyDescriptor(global, 'Request').hasOwnProperty('set') is false 1029 PASS Object.getOwnPropertyDescriptor(global, 'Request').enumerable is false 1030 PASS Object.getOwnPropertyDescriptor(global, 'Request').configurable is true 1026 1031 PASS Object.getOwnPropertyDescriptor(global, 'RGBColor').value is RGBColor 1027 1032 PASS Object.getOwnPropertyDescriptor(global, 'RGBColor').hasOwnProperty('get') is false -
trunk/LayoutTests/platform/win/js/dom/global-constructors-attributes-expected.txt
r195731 r195954 874 874 PASS Object.getOwnPropertyDescriptor(global, 'ProgressEvent').enumerable is false 875 875 PASS Object.getOwnPropertyDescriptor(global, 'ProgressEvent').configurable is true 876 PASS Object.getOwnPropertyDescriptor(global, 'Request').value is Request 877 PASS Object.getOwnPropertyDescriptor(global, 'Request').hasOwnProperty('get') is false 878 PASS Object.getOwnPropertyDescriptor(global, 'Request').hasOwnProperty('set') is false 879 PASS Object.getOwnPropertyDescriptor(global, 'Request').enumerable is false 880 PASS Object.getOwnPropertyDescriptor(global, 'Request').configurable is true 876 881 PASS Object.getOwnPropertyDescriptor(global, 'RGBColor').value is RGBColor 877 882 PASS Object.getOwnPropertyDescriptor(global, 'RGBColor').hasOwnProperty('get') is false -
trunk/Source/WebCore/CMakeLists.txt
r195948 r195954 173 173 Modules/battery/NavigatorBattery.idl 174 174 175 Modules/fetch/FetchBody.idl 175 176 Modules/fetch/FetchHeaders.idl 177 Modules/fetch/FetchRequest.idl 176 178 177 179 Modules/geolocation/Coordinates.idl … … 816 818 Modules/battery/NavigatorBattery.cpp 817 819 820 Modules/fetch/FetchBody.cpp 818 821 Modules/fetch/FetchHeaders.cpp 822 Modules/fetch/FetchRequest.cpp 819 823 820 824 Modules/geolocation/Coordinates.cpp -
trunk/Source/WebCore/ChangeLog
r195953 r195954 1 2016-02-01 Youenn Fablet <youenn.fablet@crf.canon.fr> 2 3 [Fetch API] Implement Fetch API Request 4 https://bugs.webkit.org/show_bug.cgi?id=153437 5 6 Added support for Fetch Request and Body. 7 Body is sharing functionality between Request and Response. 8 Conversion between various body types are not implemented yet. 9 10 Added a FetchOptions class. Options in this class are partially redundant with ResourceLoaderOptions. 11 12 Fixing bug in Headers constructor. 13 Making error reporting in case of modifying headers compliant with the spec. 14 15 Reviewed by Darin Adler. 16 17 Tests: imported/w3c/web-platform-tests/fetch/api/request/request-clone.sub.html 18 imported/w3c/web-platform-tests/fetch/api/request/request-consume.html 19 imported/w3c/web-platform-tests/fetch/api/request/request-disturbed.html 20 imported/w3c/web-platform-tests/fetch/api/request/request-error.html 21 imported/w3c/web-platform-tests/fetch/api/request/request-headers.html 22 imported/w3c/web-platform-tests/fetch/api/request/request-idl.html 23 imported/w3c/web-platform-tests/fetch/api/request/request-init-001.sub.html 24 imported/w3c/web-platform-tests/fetch/api/request/request-init-002.html 25 imported/w3c/web-platform-tests/fetch/api/request/request-init-003.sub.html 26 imported/w3c/web-platform-tests/fetch/api/request/request-structure.html 27 28 * CMakeLists.txt: 29 * DerivedSources.cpp: 30 * DerivedSources.make: 31 * Modules/fetch/FetchBody.cpp: Added. 32 (WebCore::FetchBody::initBody): 33 (WebCore::FetchBody::clear): 34 (WebCore::FetchBody::processIfEmptyOrDisturbed): 35 (WebCore::FetchBody::arrayBuffer): 36 (WebCore::FetchBody::formData): 37 (WebCore::FetchBody::blob): 38 (WebCore::FetchBody::text): 39 (WebCore::FetchBody::json): 40 * Modules/fetch/FetchBody.h: Added. 41 (WebCore::FetchBody::~FetchBody): 42 (WebCore::FetchBody::isEmpty): 43 (WebCore::FetchBody::isDisturbed): 44 (WebCore::FetchBody::setDisturbed): 45 (WebCore::FetchBody::setMimeType): 46 (WebCore::FetchBody::mimeType): 47 * Modules/fetch/FetchBody.idl: Added. 48 * Modules/fetch/FetchHeaders.cpp: 49 (WebCore::canWriteHeader): 50 (WebCore::FetchHeaders::append): 51 (WebCore::FetchHeaders::remove): 52 (WebCore::FetchHeaders::set): 53 (WebCore::FetchHeaders::fill): Helper routine implementing https://fetch.spec.whatwg.org/#concept-headers-fill 54 * Modules/fetch/FetchHeaders.h: Adding header getter/setter for FetchRequest. 55 (WebCore::FetchHeaders::fastGet): 56 (WebCore::FetchHeaders::fastSet): 57 * Modules/fetch/FetchHeaders.js: Fixing bug in constructor (covered by modified headers-basc.html test). 58 (initializeFetchHeaders): 59 * Modules/fetch/FetchOptions.h: Added. 60 (WebCore::FetchOptions::FetchOptions): 61 (WebCore::FetchOptions::type): 62 (WebCore::FetchOptions::destination): 63 (WebCore::FetchOptions::mode): 64 (WebCore::FetchOptions::credentials): 65 (WebCore::FetchOptions::cache): 66 (WebCore::FetchOptions::redirect): 67 (WebCore::FetchOptions::referrerPolicy): 68 (WebCore::FetchOptions::setType): 69 (WebCore::FetchOptions::setDestination): 70 (WebCore::FetchOptions::setMode): 71 (WebCore::FetchOptions::setCredentials): 72 (WebCore::FetchOptions::setCache): 73 (WebCore::FetchOptions::setRedirect): 74 (WebCore::FetchOptions::setReferrerPolicy): 75 * Modules/fetch/FetchRequest.cpp: Added. 76 (WebCore::FetchRequest::create): 77 (WebCore::FetchRequest::FetchRequest): 78 (WebCore::FetchRequest::init): 79 (WebCore::FetchRequest::setReferrer): 80 (WebCore::FetchRequest::setReferrerPolicy): 81 (WebCore::FetchRequest::setMode): 82 (WebCore::FetchRequest::setCredentials): 83 (WebCore::FetchRequest::setCache): 84 (WebCore::FetchRequest::setRedirect): 85 (WebCore::FetchRequest::type): 86 (WebCore::FetchRequest::destination): 87 (WebCore::FetchRequest::referrerPolicy): 88 (WebCore::FetchRequest::referrer): 89 (WebCore::FetchRequest::mode): 90 (WebCore::FetchRequest::credentials): 91 (WebCore::FetchRequest::cache): 92 (WebCore::FetchRequest::redirect): 93 (WebCore::FetchRequest::setMethod): 94 (WebCore::FetchRequest::clone): 95 * Modules/fetch/FetchRequest.h: Added. 96 (WebCore::FetchRequest::method): 97 (WebCore::FetchRequest::url): 98 (WebCore::FetchRequest::integrity): 99 (WebCore::FetchRequest::headers): 100 * Modules/fetch/FetchRequest.idl: Added. 101 * WebCore.xcodeproj/project.pbxproj: 102 * bindings/js/Dictionary.h: 103 (WebCore::Dictionary::execState): 104 * bindings/js/JSDictionary.cpp: 105 (WebCore::JSDictionary::convertValue): 106 * bindings/js/JSDictionary.h: 107 (WebCore::JSDictionary::get): 108 1 109 2016-01-31 Jeremy Jones <jeremyj@apple.com> 2 110 -
trunk/Source/WebCore/DerivedSources.cpp
r195627 r195954 155 155 #include "JSEventSource.cpp" 156 156 #include "JSEventTarget.cpp" 157 #include "JSFetchBody.cpp" 157 158 #include "JSFetchHeaders.cpp" 159 #include "JSFetchRequest.cpp" 158 160 #include "JSFile.cpp" 159 161 #include "JSFileError.cpp" -
trunk/Source/WebCore/DerivedSources.make
r195698 r195954 80 80 $(WebCore)/Modules/encryptedmedia/MediaKeySession.idl \ 81 81 $(WebCore)/Modules/encryptedmedia/MediaKeys.idl \ 82 $(WebCore)/Modules/fetch/FetchBody.idl \ 82 83 $(WebCore)/Modules/fetch/FetchHeaders.idl \ 84 $(WebCore)/Modules/fetch/FetchRequest.idl \ 83 85 $(WebCore)/Modules/gamepad/Gamepad.idl \ 84 86 $(WebCore)/Modules/gamepad/GamepadButton.idl \ -
trunk/Source/WebCore/Modules/fetch/FetchBody.h
r195953 r195954 27 27 */ 28 28 29 #ifndef Fetch Headers_h30 #define Fetch Headers_h29 #ifndef FetchBody_h 30 #define FetchBody_h 31 31 32 32 #if ENABLE(FETCH_API) 33 33 34 #include "HTTPHeaderMap.h" 34 #include "Blob.h" 35 #include "DOMFormData.h" 36 #include "JSDOMPromise.h" 37 38 namespace JSC { 39 class ExecState; 40 class JSValue; 41 }; 35 42 36 43 namespace WebCore { 37 44 45 class Dictionary; 38 46 typedef int ExceptionCode; 39 47 40 class Fetch Headers : public RefCounted<FetchHeaders>{48 class FetchBody { 41 49 public: 42 enum class Guard { 43 None, 44 Immutable, 45 Request, 46 RequestNoCors, 47 Response 48 }; 50 typedef DOMPromise<Vector<unsigned char>, ExceptionCode> ArrayBufferPromise; 51 void arrayBuffer(ArrayBufferPromise&&); 49 52 50 static Ref<FetchHeaders> create(Guard guard = Guard::None) { return adoptRef(*new FetchHeaders(guard)); } 53 typedef DOMPromise<RefPtr<DOMFormData>, ExceptionCode> FormDataPromise; 54 void formData(FormDataPromise&&); 51 55 52 void append(const String& name, const String& value, ExceptionCode&); 53 void remove(const String&, ExceptionCode&); 54 String get(const String&, ExceptionCode&) const; 55 bool has(const String&, ExceptionCode&) const; 56 void set(const String& name, const String& value, ExceptionCode&); 56 typedef DOMPromise<RefPtr<Blob>, ExceptionCode> BlobPromise; 57 void blob(BlobPromise&&); 57 58 58 void initializeWith(const FetchHeaders*, ExceptionCode&); 59 typedef DOMPromise<JSC::JSValue, ExceptionCode> JSONPromise; 60 void json(JSC::ExecState&, JSONPromise&&); 61 62 typedef DOMPromise<String, ExceptionCode> TextPromise; 63 void text(TextPromise&&); 64 65 bool isDisturbed() const { return m_isDisturbed; } 66 bool isEmpty() const { return m_type == Type::None; } 67 68 void setMimeType(const String& mimeType) { m_mimeType = mimeType; } 69 String mimeType() const { return m_mimeType; } 70 71 static FetchBody fromJSValue(JSC::ExecState&, JSC::JSValue); 72 static FetchBody fromRequestBody(FetchBody*); 59 73 60 74 private: 61 FetchHeaders(Guard guard) : m_guard(guard) { }75 template<typename T> bool processIfEmptyOrDisturbed(DOMPromise<T, ExceptionCode>&); 62 76 63 Guard m_guard; 64 HTTPHeaderMap m_headers; 77 enum class Type { None, Text, Blob, FormData }; 78 79 FetchBody(Ref<Blob>&&); 80 FetchBody(Ref<DOMFormData>&&); 81 FetchBody(String&&); 82 FetchBody() { } 83 84 Type m_type = Type::None; 85 String m_mimeType; 86 bool m_isDisturbed = false; 87 88 // FIXME: Add support for BufferSource and URLSearchParams. 89 RefPtr<Blob> m_blob; 90 RefPtr<DOMFormData> m_formData; 91 String m_text; 65 92 }; 66 93 … … 69 96 #endif // ENABLE(FETCH_API) 70 97 71 #endif // Fetch Headers_h98 #endif // FetchBody_h -
trunk/Source/WebCore/Modules/fetch/FetchBody.idl
r195953 r195954 27 27 */ 28 28 29 #ifndef FetchHeaders_h 30 #define FetchHeaders_h 31 32 #if ENABLE(FETCH_API) 33 34 #include "HTTPHeaderMap.h" 35 36 namespace WebCore { 37 38 typedef int ExceptionCode; 39 40 class FetchHeaders : public RefCounted<FetchHeaders> { 41 public: 42 enum class Guard { 43 None, 44 Immutable, 45 Request, 46 RequestNoCors, 47 Response 48 }; 49 50 static Ref<FetchHeaders> create(Guard guard = Guard::None) { return adoptRef(*new FetchHeaders(guard)); } 51 52 void append(const String& name, const String& value, ExceptionCode&); 53 void remove(const String&, ExceptionCode&); 54 String get(const String&, ExceptionCode&) const; 55 bool has(const String&, ExceptionCode&) const; 56 void set(const String& name, const String& value, ExceptionCode&); 57 58 void initializeWith(const FetchHeaders*, ExceptionCode&); 59 60 private: 61 FetchHeaders(Guard guard) : m_guard(guard) { } 62 63 Guard m_guard; 64 HTTPHeaderMap m_headers; 29 [ 30 Conditional=FETCH_API, 31 GlobalContext=DOMWindow&WorkerGlobalScope, 32 InterfaceName=Body, 33 NoInterfaceObject 34 ] 35 interface FetchBody { 36 [ImplementedAs=isDisturbed] readonly attribute boolean bodyUsed; 37 [NewObject] Promise arrayBuffer(); 38 [NewObject] Promise blob(); 39 [NewObject] Promise formData(); 40 [CallWith=ScriptState, NewObject] Promise json(); 41 [NewObject] Promise text(); 65 42 }; 66 67 } // namespace WebCore68 69 #endif // ENABLE(FETCH_API)70 71 #endif // FetchHeaders_h -
trunk/Source/WebCore/Modules/fetch/FetchHeaders.cpp
r195530 r195954 102 102 } 103 103 104 static bool canWriteHeader(const String& name, const String& value, FetchHeaders::Guard guard )104 static bool canWriteHeader(const String& name, const String& value, FetchHeaders::Guard guard, ExceptionCode& ec) 105 105 { 106 if (!isValidHTTPToken(name) || !isValidHTTPHeaderValue(value)) 106 if (!isValidHTTPToken(name) || !isValidHTTPHeaderValue(value)) { 107 ec = TypeError; 107 108 return false; 108 if (guard == FetchHeaders::Guard::Immutable) 109 } 110 if (guard == FetchHeaders::Guard::Immutable) { 111 ec = TypeError; 109 112 return false; 113 } 110 114 if (guard == FetchHeaders::Guard::Request && isForbiddenHeaderName(name)) 111 115 return false; … … 120 124 { 121 125 String normalizedValue = stripLeadingAndTrailingHTTPSpaces(value); 122 if (!canWriteHeader(name, normalizedValue, m_guard)) { 123 ec = TypeError; 126 if (!canWriteHeader(name, normalizedValue, m_guard, ec)) 124 127 return; 125 }126 128 m_headers.add(name, normalizedValue); 127 129 } … … 129 131 void FetchHeaders::remove(const String& name, ExceptionCode& ec) 130 132 { 131 if (!canWriteHeader(name, String(), m_guard)) { 132 ec = TypeError; 133 if (!canWriteHeader(name, String(), m_guard, ec)) 133 134 return; 134 }135 135 m_headers.remove(name); 136 136 } … … 157 157 { 158 158 String normalizedValue = stripLeadingAndTrailingHTTPSpaces(value); 159 if (!canWriteHeader(name, normalizedValue, m_guard)) { 160 ec = TypeError; 159 if (!canWriteHeader(name, normalizedValue, m_guard, ec)) 161 160 return; 161 m_headers.set(name, normalizedValue); 162 } 163 164 void FetchHeaders::fill(const FetchHeaders* headers) 165 { 166 if (!headers) 167 return; 168 169 ASSERT(m_guard != Guard::Immutable); 170 171 ExceptionCode ec; 172 for (auto& header : headers->m_headers) { 173 if (canWriteHeader(header.key, header.value, m_guard, ec)) { 174 if (header.keyAsHTTPHeaderName) 175 m_headers.add(header.keyAsHTTPHeaderName.value(), header.value); 176 else 177 m_headers.add(header.key, header.value); 178 } 162 179 } 163 m_headers.set(name, normalizedValue);164 180 } 165 181 -
trunk/Source/WebCore/Modules/fetch/FetchHeaders.h
r195530 r195954 49 49 50 50 static Ref<FetchHeaders> create(Guard guard = Guard::None) { return adoptRef(*new FetchHeaders(guard)); } 51 static Ref<FetchHeaders> create(const FetchHeaders& headers) { return adoptRef(*new FetchHeaders(headers.m_guard, headers.m_headers)); } 51 52 52 53 void append(const String& name, const String& value, ExceptionCode&); … … 57 58 58 59 void initializeWith(const FetchHeaders*, ExceptionCode&); 60 void fill(const FetchHeaders*); 61 62 String fastGet(HTTPHeaderName name) const { return m_headers.get(name); } 63 void fastSet(HTTPHeaderName name, const String& value) { m_headers.set(name, value); } 59 64 60 65 private: 61 66 FetchHeaders(Guard guard) : m_guard(guard) { } 67 FetchHeaders(Guard guard, const HTTPHeaderMap& headers) : m_guard(guard), m_headers(headers) { } 62 68 63 69 Guard m_guard; -
trunk/Source/WebCore/Modules/fetch/FetchHeaders.js
r195530 r195954 48 48 this.@appendFromJS(header[0], header[1]); 49 49 } 50 return this; 50 51 } 51 52 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r195948 r195954 1548 1548 41F1D21F0EF35C2A00DA8753 /* ScriptCachedFrameData.h in Headers */ = {isa = PBXBuildFile; fileRef = 41F1D21D0EF35C2A00DA8753 /* ScriptCachedFrameData.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1549 1549 41F1D2200EF35C2A00DA8753 /* ScriptCachedFrameData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41F1D21E0EF35C2A00DA8753 /* ScriptCachedFrameData.cpp */; }; 1550 41F54F8B1C50C50300338488 /* FetchBody.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41F54F7D1C50C4F600338488 /* FetchBody.cpp */; }; 1550 1551 41F54F8D1C50C50800338488 /* FetchHeaders.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41F54F821C50C4F600338488 /* FetchHeaders.cpp */; }; 1552 41F54F8E1C50C50C00338488 /* FetchRequest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41F54F871C50C4F600338488 /* FetchRequest.cpp */; }; 1551 1553 41F584C7104652CB009CAA64 /* JSMessagePortCustom.h in Headers */ = {isa = PBXBuildFile; fileRef = 41F584C6104652CB009CAA64 /* JSMessagePortCustom.h */; }; 1552 1554 41FA303E1316C29C00C0BFC5 /* RenderMediaControls.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41FA303C1316C29C00C0BFC5 /* RenderMediaControls.cpp */; }; … … 2794 2796 7E474E1F12494DC900235364 /* SQLiteDatabaseTracker.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E474E1C12494DC900235364 /* SQLiteDatabaseTracker.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2795 2797 7E474E2012494DC900235364 /* SQLiteDatabaseTracker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7E474E1D12494DC900235364 /* SQLiteDatabaseTracker.cpp */; }; 2798 7E4C96DC1AD4483500365A50 /* JSFetchRequest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7E4C96D81AD4483500365A50 /* JSFetchRequest.cpp */; }; 2799 7E4C96DD1AD4483500365A50 /* JSFetchRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E4C96D91AD4483500365A50 /* JSFetchRequest.h */; }; 2796 2800 7E4DE10D198B10B60051CB02 /* DiskCacheMonitorCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7E4DE10C198B10B60051CB02 /* DiskCacheMonitorCocoa.mm */; }; 2797 2801 7E5D7A76161D3F8F00896C34 /* OESElementIndexUint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7E5D7A73161D3F8F00896C34 /* OESElementIndexUint.cpp */; }; … … 2830 2834 7EE6847112D26E3800E79415 /* ResourceResponseCFNet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7EE6845E12D26E3800E79415 /* ResourceResponseCFNet.cpp */; }; 2831 2835 7EE6847512D26E7000E79415 /* ResourceLoaderCFNet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7EE6847412D26E7000E79415 /* ResourceLoaderCFNet.cpp */; }; 2836 7F4C96DC1AD4483500365A50 /* JSFetchBody.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7F4C96D81AD4483500365A50 /* JSFetchBody.cpp */; }; 2837 7F4C96DD1AD4483500365A50 /* JSFetchBody.h in Headers */ = {isa = PBXBuildFile; fileRef = 7F4C96D91AD4483500365A50 /* JSFetchBody.h */; }; 2832 2838 8102C5881325BB1100DDE67A /* StringCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8102C5871325BB1100DDE67A /* StringCallback.cpp */; }; 2833 2839 81AC5999131636E60009A7E0 /* DataTransferItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 81AC5997131636E60009A7E0 /* DataTransferItem.h */; }; … … 8960 8966 41F1D21D0EF35C2A00DA8753 /* ScriptCachedFrameData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptCachedFrameData.h; sourceTree = "<group>"; }; 8961 8967 41F1D21E0EF35C2A00DA8753 /* ScriptCachedFrameData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptCachedFrameData.cpp; sourceTree = "<group>"; }; 8968 41F54F7D1C50C4F600338488 /* FetchBody.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FetchBody.cpp; sourceTree = "<group>"; }; 8969 41F54F7E1C50C4F600338488 /* FetchBody.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FetchBody.h; sourceTree = "<group>"; }; 8970 41F54F7F1C50C4F600338488 /* FetchBody.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = FetchBody.idl; sourceTree = "<group>"; }; 8962 8971 41F54F821C50C4F600338488 /* FetchHeaders.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FetchHeaders.cpp; sourceTree = "<group>"; }; 8963 8972 41F54F831C50C4F600338488 /* FetchHeaders.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FetchHeaders.h; sourceTree = "<group>"; }; 8964 8973 41F54F841C50C4F600338488 /* FetchHeaders.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = FetchHeaders.idl; sourceTree = "<group>"; }; 8965 8974 41F54F851C50C4F600338488 /* FetchHeaders.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = FetchHeaders.js; sourceTree = "<group>"; }; 8975 41F54F861C50C4F600338488 /* FetchOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FetchOptions.h; sourceTree = "<group>"; }; 8976 41F54F871C50C4F600338488 /* FetchRequest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FetchRequest.cpp; sourceTree = "<group>"; }; 8977 41F54F881C50C4F600338488 /* FetchRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FetchRequest.h; sourceTree = "<group>"; }; 8978 41F54F891C50C4F600338488 /* FetchRequest.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = FetchRequest.idl; sourceTree = "<group>"; }; 8966 8979 41F584C6104652CB009CAA64 /* JSMessagePortCustom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMessagePortCustom.h; sourceTree = "<group>"; }; 8967 8980 41FA303C1316C29C00C0BFC5 /* RenderMediaControls.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderMediaControls.cpp; sourceTree = "<group>"; }; … … 10359 10372 7E474E1C12494DC900235364 /* SQLiteDatabaseTracker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SQLiteDatabaseTracker.h; sourceTree = "<group>"; }; 10360 10373 7E474E1D12494DC900235364 /* SQLiteDatabaseTracker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SQLiteDatabaseTracker.cpp; sourceTree = "<group>"; }; 10374 7E4C96D81AD4483500365A50 /* JSFetchRequest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSFetchRequest.cpp; sourceTree = "<group>"; }; 10375 7E4C96D91AD4483500365A50 /* JSFetchRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSFetchRequest.h; sourceTree = "<group>"; }; 10361 10376 7E4DE10C198B10B60051CB02 /* DiskCacheMonitorCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DiskCacheMonitorCocoa.mm; sourceTree = "<group>"; }; 10362 10377 7E5D7A73161D3F8F00896C34 /* OESElementIndexUint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OESElementIndexUint.cpp; sourceTree = "<group>"; }; … … 10397 10412 7EE6845E12D26E3800E79415 /* ResourceResponseCFNet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceResponseCFNet.cpp; sourceTree = "<group>"; }; 10398 10413 7EE6847412D26E7000E79415 /* ResourceLoaderCFNet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceLoaderCFNet.cpp; sourceTree = "<group>"; }; 10414 7F4C96D81AD4483500365A50 /* JSFetchBody.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSFetchBody.cpp; sourceTree = "<group>"; }; 10415 7F4C96D91AD4483500365A50 /* JSFetchBody.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSFetchBody.h; sourceTree = "<group>"; }; 10399 10416 8102C5871325BB1100DDE67A /* StringCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringCallback.cpp; sourceTree = "<group>"; }; 10400 10417 81AC5997131636E60009A7E0 /* DataTransferItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DataTransferItem.h; sourceTree = "<group>"; }; … … 16620 16637 isa = PBXGroup; 16621 16638 children = ( 16639 41F54F7D1C50C4F600338488 /* FetchBody.cpp */, 16640 41F54F7E1C50C4F600338488 /* FetchBody.h */, 16641 41F54F7F1C50C4F600338488 /* FetchBody.idl */, 16622 16642 41F54F821C50C4F600338488 /* FetchHeaders.cpp */, 16623 16643 41F54F831C50C4F600338488 /* FetchHeaders.h */, 16624 16644 41F54F841C50C4F600338488 /* FetchHeaders.idl */, 16625 16645 41F54F851C50C4F600338488 /* FetchHeaders.js */, 16646 41F54F861C50C4F600338488 /* FetchOptions.h */, 16647 41F54F871C50C4F600338488 /* FetchRequest.cpp */, 16648 41F54F881C50C4F600338488 /* FetchRequest.h */, 16649 41F54F891C50C4F600338488 /* FetchRequest.idl */, 16626 16650 ); 16627 16651 path = fetch; … … 16631 16655 isa = PBXGroup; 16632 16656 children = ( 16657 7F4C96D81AD4483500365A50 /* JSFetchBody.cpp */, 16658 7F4C96D91AD4483500365A50 /* JSFetchBody.h */, 16659 7E4C96D81AD4483500365A50 /* JSFetchRequest.cpp */, 16660 7E4C96D91AD4483500365A50 /* JSFetchRequest.h */, 16633 16661 7D4C96D81AD4483500365A50 /* JSFetchHeaders.cpp */, 16634 16662 7D4C96D91AD4483500365A50 /* JSFetchHeaders.h */, … … 26484 26512 B658FFA21522EF3A00DD5595 /* JSRadioNodeList.h in Headers */, 26485 26513 65DF320209D1CC60000BE325 /* JSRange.h in Headers */, 26514 7F4C96DD1AD4483500365A50 /* JSFetchBody.h in Headers */, 26515 7E4C96DD1AD4483500365A50 /* JSFetchRequest.h in Headers */, 26486 26516 7D4C96DD1AD4483500365A50 /* JSFetchHeaders.h in Headers */, 26487 26517 7C4C96DD1AD4483500365A50 /* JSReadableStream.h in Headers */, … … 29665 29695 516D7D711BB5F0BD00AF7C77 /* IDBConnectionToClient.cpp in Sources */, 29666 29696 5198F7C01BC4856700E2CC5F /* IDBConnectionToServer.cpp in Sources */, 29697 41F54F8B1C50C50300338488 /* FetchBody.cpp in Sources */, 29667 29698 5185FC7A1BB4C4E80012898F /* IDBCursor.cpp in Sources */, 29668 29699 51F41A691BA73B5B002E053B /* IDBCursorBackend.cpp in Sources */, … … 30074 30105 83E359A31BB1031D002CEB98 /* JSHTMLTimeElement.cpp in Sources */, 30075 30106 A80E7B130A19D606007FB8C5 /* JSHTMLTitleElement.cpp in Sources */, 30107 41F54F8E1C50C50C00338488 /* FetchRequest.cpp in Sources */, 30076 30108 070756D314239A4E00414161 /* JSHTMLTrackElement.cpp in Sources */, 30077 30109 1A85B2100A1B258700D8C87C /* JSHTMLUListElement.cpp in Sources */, … … 30196 30228 B658FFA11522EF3A00DD5595 /* JSRadioNodeList.cpp in Sources */, 30197 30229 65DF320109D1CC60000BE325 /* JSRange.cpp in Sources */, 30230 7F4C96DC1AD4483500365A50 /* JSFetchBody.cpp in Sources */, 30198 30231 7D4C96DC1AD4483500365A50 /* JSFetchHeaders.cpp in Sources */, 30232 7E4C96DC1AD4483500365A50 /* JSFetchRequest.cpp in Sources */, 30199 30233 7C4C96DC1AD4483500365A50 /* JSReadableStream.cpp in Sources */, 30200 30234 6C4C96DE1AD4483500365A50 /* JSReadableStreamController.cpp in Sources */, -
trunk/Source/WebCore/bindings/js/Dictionary.h
r195616 r195954 67 67 bool getWithUndefinedOrNullCheck(const char* propertyName, String& value) const; 68 68 69 JSC::ExecState* execState() const { return m_dictionary.execState(); } 70 69 71 private: 70 72 template <typename T> -
trunk/Source/WebCore/bindings/js/JSDictionary.cpp
r192464 r195954 48 48 #endif 49 49 50 #if ENABLE(FETCH_API) 51 #include "JSFetchHeaders.h" 52 #endif 53 50 54 #if ENABLE(MEDIA_STREAM) 51 55 #include "JSMediaStream.h" … … 228 232 #endif 229 233 234 #if ENABLE(FETCH_API) 235 void JSDictionary::convertValue(JSC::ExecState*, JSC::JSValue value, RefPtr<FetchHeaders>& result) 236 { 237 result = JSFetchHeaders::toWrapped(value); 238 } 239 #endif 240 230 241 #if ENABLE(MEDIA_STREAM) 231 242 void JSDictionary::convertValue(JSC::ExecState*, JSC::JSValue value, RefPtr<MediaStream>& result) -
trunk/Source/WebCore/bindings/js/JSDictionary.h
r192464 r195954 48 48 class EventTarget; 49 49 class Gamepad; 50 class FetchHeaders; 50 51 class MediaKeyError; 51 52 class MediaStream; … … 127 128 static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<MediaKeyError>& result); 128 129 #endif 130 #if ENABLE(FETCH_API) 131 static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<FetchHeaders>& result); 132 #endif 129 133 #if ENABLE(MEDIA_STREAM) 130 134 static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<MediaStream>& result); … … 162 166 { 163 167 return tryGetPropertyAndResult(propertyName, &finalResult, IdentitySetter<Result>::identitySetter) == PropertyFound; 168 } 169 170 template <> 171 inline bool JSDictionary::get(const char* propertyName, JSC::JSValue& finalResult) const 172 { 173 return tryGetProperty(propertyName, finalResult) == PropertyFound; 164 174 } 165 175
Note: See TracChangeset
for help on using the changeset viewer.