Changeset 203641 in webkit
- Timestamp:
- Jul 23, 2016 1:55:38 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 1 deleted
- 27 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/imported/w3c/ChangeLog
r203638 r203641 1 2016-07-23 Youenn Fablet <youenn@apple.com> 2 3 [Fetch API] Request should be created with any HeadersInit data 4 https://bugs.webkit.org/show_bug.cgi?id=159672 5 6 Reviewed by Sam Weinig. 7 8 * imported/w3c/web-platform-tests/fetch/api/credentials/authentication-basic-expected.txt: Test was previously 9 failing due to lack of support for HeadersInit data in Request constructor. 10 * platform/mac-wk1/imported/w3c/web-platform-tests/fetch/api/credentials/authentication-basic-expected.txt: Removed. 11 * web-platform-tests/fetch/api/request/request-headers-expected.txt: 12 * web-platform-tests/fetch/api/request/request-headers.html: Adding new test. 13 1 14 2016-07-23 Youenn Fablet <youenn@apple.com> 2 15 -
trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/credentials/authentication-basic-expected.txt
r200195 r203641 1 localhost:8800 - didReceiveAuthenticationChallenge - Simulating cancelled authentication sheet2 localhost:8800 - didReceiveAuthenticationChallenge - Simulating cancelled authentication sheet3 localhost:8800 - didReceiveAuthenticationChallenge - Simulating cancelled authentication sheet4 1 5 FAIL User-added Authorization header with include mode assert_equals: HTTP status is 200 expected 200 but got 401 6 FAIL User-added Authorization header with same-origin mode assert_equals: HTTP status is 200 expected 200 but got 401 7 FAIL User-added Authorization header with omit mode assert_equals: HTTP status is 200 expected 200 but got 401 2 PASS User-added Authorization header with include mode 3 PASS User-added Authorization header with same-origin mode 4 PASS User-added Authorization header with omit mode 8 5 -
trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-headers-expected.txt
r195954 r203641 54 54 PASS Request should get its content-type from the body if none is provided 55 55 PASS Request should get its content-type from init headers if one is provided 56 PASS Testing request header creations with various objects 56 57 -
trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-headers.html
r195954 r203641 146 146 }, "Request should get its content-type from init headers if one is provided"); 147 147 148 test(function() { 149 var array = [["hello", "worldAHH"]]; 150 var object = {"hello": 'worldOOH'}; 151 var headers = new Headers(array); 152 153 assert_equals(headers.get("hello"), "worldAHH"); 154 155 var request1 = new Request("", {"headers": headers}); 156 var request2 = new Request("", {"headers": array}); 157 var request3 = new Request("", {"headers": object}); 158 159 assert_equals(request1.headers.get("hello"), "worldAHH"); 160 assert_equals(request2.headers.get("hello"), "worldAHH"); 161 assert_equals(request3.headers.get("hello"), "worldOOH"); 162 }, "Testing request header creations with various objects"); 163 148 164 </script> 149 165 </body> -
trunk/Source/JavaScriptCore/ChangeLog
r203621 r203641 1 2016-07-23 Youenn Fablet <youenn@apple.com> 2 3 [Fetch API] Request should be created with any HeadersInit data 4 https://bugs.webkit.org/show_bug.cgi?id=159672 5 6 Reviewed by Sam Weinig. 7 8 * Scripts/builtins/builtins_generator.py: 9 (WK_lcfirst): Synchronized with CodeGenerator.pm version. 10 1 11 2016-07-21 Filip Pizlo <fpizlo@apple.com> 2 12 -
trunk/Source/JavaScriptCore/Scripts/builtins/builtins_generator.py
r202975 r203641 39 39 def WK_lcfirst(str): 40 40 str = str[:1].lower() + str[1:] 41 str = str.replace(' hTML', 'html')41 str = str.replace('dOM', 'dom') 42 42 str = str.replace('uRL', 'url') 43 43 str = str.replace('jS', 'js') -
trunk/Source/WebCore/CMakeLists.txt
r203632 r203641 3711 3711 3712 3712 set(WebCore_BUILTINS_SOURCES 3713 ${WEBCORE_DIR}/Modules/fetch/DOMWindowFetch.js 3713 3714 ${WEBCORE_DIR}/Modules/fetch/FetchHeaders.js 3714 3715 ${WEBCORE_DIR}/Modules/fetch/FetchInternals.js 3716 ${WEBCORE_DIR}/Modules/fetch/FetchRequest.js 3715 3717 ${WEBCORE_DIR}/Modules/fetch/FetchResponse.js 3718 ${WEBCORE_DIR}/Modules/fetch/WorkerGlobalScopeFetch.js 3716 3719 ${WEBCORE_DIR}/Modules/mediastream/MediaDevices.js 3717 3720 ${WEBCORE_DIR}/Modules/mediastream/NavigatorUserMedia.js -
trunk/Source/WebCore/ChangeLog
r203640 r203641 1 2016-07-23 Youenn Fablet <youenn@apple.com> 2 3 [Fetch API] Request should be created with any HeadersInit data 4 https://bugs.webkit.org/show_bug.cgi?id=159672 5 6 Reviewed by Sam Weinig. 7 8 Made Request use JSBuiltinConstructor. 9 This allows initializing newly created Request with a JS built-in function, initializeFetchRequest. 10 initializeFetchRequest can call @fillFetchHeaders internal built-in to handle any HeadersInit data. 11 Future effort should be made to migrate more initialization code in initializeFetchRequest. 12 13 Made window and worker fetch function as a JS built-in. 14 This becomes more handy as these new functions can construct the Request object. 15 They can then call a single private function that takes a Request object as input. 16 Updated DOMWindowFetch and WorkerGlobalScopeFetch code accordingly. 17 18 To enable this, the binding generator is updated to support runtime-enabled JS built-in functions and 19 private functions atttached to global objects. 20 21 Covered by existing and modified tests. 22 Binding generator test covered by updated binding tests. 23 24 * CMakeLists.txt: Adding DOMWindowFetch.js, FetchRequest.js and WorkerGlobalScopeFetch.js built-in files. 25 * DerivedSources.make: Ditto. 26 * Modules/fetch/DOMWindowFetch.cpp: Removed overloaded fetch and updated according new signature. 27 (WebCore::DOMWindowFetch::fetch): 28 * Modules/fetch/DOMWindowFetch.h: Ditto. 29 * Modules/fetch/DOMWindowFetch.idl: Making fetch a JS built-in and adding a @fetchRequest private function. 30 * Modules/fetch/DOMWindowFetch.js: Added. 31 (fetch): 32 * Modules/fetch/FetchHeaders.h: 33 (WebCore::FetchHeaders::setGuard): Used by FetchRequest when initializing headers. 34 * Modules/fetch/FetchRequest.cpp: 35 (WebCore::buildHeaders): Removed as implemented in JS. 36 (WebCore::FetchRequest::initializeOptions): Added to handle most of the dictionary initialization. 37 (WebCore::FetchRequest::initializeWith): Method called from built-in constructor function. 38 (WebCore::FetchRequest::setBody): Corresponding to @setBody private method. 39 (WebCore::buildBody): Deleted. 40 * Modules/fetch/FetchRequest.h: 41 * Modules/fetch/FetchRequest.idl: 42 * Modules/fetch/FetchRequest.js: Added. 43 (initializeFetchRequest): Implements fetch Request(input, init) constructor. 44 * Modules/fetch/FetchResponse.cpp: 45 (WebCore::FetchResponse::fetch): Removed the construction of FetchRequest in fetch method since it is done by JS built-in code. 46 * Modules/fetch/FetchResponse.h: 47 * Modules/fetch/WorkerGlobalScopeFetch.cpp: Removed overloaded fetch and updated according new signature. 48 (WebCore::WorkerGlobalScopeFetch::fetch): 49 * Modules/fetch/WorkerGlobalScopeFetch.h: Ditto. 50 * Modules/fetch/WorkerGlobalScopeFetch.idl: Making fetch a JS built-in and adding a @fetchRequest private function. 51 * Modules/fetch/WorkerGlobalScopeFetch.js: Added. 52 (fetch): 53 * bindings/js/WebCoreBuiltinNames.h: Adding fetchRequest, setBody and Request private identifiers. 54 * bindings/scripts/CodeGenerator.pm: 55 (WK_lcfirst): Replacing dOM by dom. 56 * bindings/scripts/CodeGeneratorJS.pm: 57 (GenerateImplementation): Adding support for runtime-enabled built-in methods and private methods. 58 * bindings/scripts/test/JS/JSTestGlobalObject.cpp: 59 (WebCore::JSTestGlobalObject::finishCreation): 60 (WebCore::jsTestGlobalObjectInstanceFunctionTestPrivateFunction): 61 * bindings/scripts/test/ObjC/DOMTestGlobalObject.mm: 62 (-[DOMTestGlobalObject testJSBuiltinFunction]): 63 * bindings/scripts/test/TestGlobalObject.idl: Adding tests for runtime-enabled global built-in methods and private methods. 64 1 65 2016-07-23 Frederic Wang <fwang@igalia.com> 2 66 -
trunk/Source/WebCore/DerivedSources.make
r203554 r203641 1284 1284 1285 1285 WebCore_BUILTINS_SOURCES = \ 1286 ${WebCore}/Modules/fetch/DOMWindowFetch.js \ 1286 1287 $(WebCore)/Modules/fetch/FetchHeaders.js \ 1287 1288 $(WebCore)/Modules/fetch/FetchInternals.js \ 1289 $(WebCore)/Modules/fetch/FetchRequest.js \ 1288 1290 $(WebCore)/Modules/fetch/FetchResponse.js \ 1291 ${WebCore}/Modules/fetch/WorkerGlobalScopeFetch.js \ 1289 1292 $(WebCore)/Modules/mediastream/MediaDevices.js \ 1290 1293 $(WebCore)/Modules/mediastream/NavigatorUserMedia.js \ -
trunk/Source/WebCore/Modules/fetch/DOMWindowFetch.cpp
r198891 r203641 38 38 namespace WebCore { 39 39 40 void DOMWindowFetch::fetch(DOMWindow& window, FetchRequest& input, const Dictionary& dictionary, DeferredWrapper&& promise)40 void DOMWindowFetch::fetch(DOMWindow& window, FetchRequest& request, DeferredWrapper&& promise) 41 41 { 42 42 if (!window.scriptExecutionContext()) 43 43 return; 44 FetchResponse::fetch(*window.scriptExecutionContext(), input, dictionary, WTFMove(promise)); 45 } 46 47 void DOMWindowFetch::fetch(DOMWindow& window, const String& url, const Dictionary& dictionary, DeferredWrapper&& promise) 48 { 49 if (!window.scriptExecutionContext()) 50 return; 51 FetchResponse::fetch(*window.scriptExecutionContext(), url, dictionary, WTFMove(promise)); 44 FetchResponse::fetch(*window.scriptExecutionContext(), request, WTFMove(promise)); 52 45 } 53 46 -
trunk/Source/WebCore/Modules/fetch/DOMWindowFetch.h
r198833 r203641 26 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 #ifndef DOMWindowFetch_h 29 # define DOMWindowFetch_h28 29 #pragma once 30 30 31 31 #if ENABLE(FETCH_API) … … 42 42 class DOMWindowFetch { 43 43 public: 44 static void fetch(DOMWindow&, FetchRequest&, const Dictionary&, DeferredWrapper&&); 45 static void fetch(DOMWindow&, const String&, const Dictionary&, DeferredWrapper&&); 44 static void fetch(DOMWindow&, FetchRequest&, DeferredWrapper&&); 46 45 }; 47 46 … … 49 48 50 49 #endif // ENABLE(FETCH_API) 51 52 #endif // DOMWindowFetch_h -
trunk/Source/WebCore/Modules/fetch/DOMWindowFetch.idl
r199081 r203641 31 31 EnabledAtRuntime=FetchAPI, 32 32 ] partial interface DOMWindow { 33 Promise fetch(FetchRequest input, optional Dictionary init); 34 Promise fetch(DOMString input, optional Dictionary init); 33 [JSBuiltin] Promise fetch(any input, optional Dictionary init); 34 35 [PrivateIdentifier, ImplementedAs=fetch] Promise fetchRequest(FetchRequest request); 35 36 }; -
trunk/Source/WebCore/Modules/fetch/DOMWindowFetch.js
r203640 r203641 1 1 /* 2 * Copyright (C) 2016 Apple Inc. All rights reserved.2 * Copyright (C) 2016 Apple Inc. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 // This interface is recognized as a global object by the bindings generator. 27 interface TestGlobalObject { 28 attribute DOMString regularAttribute; 29 [PrivateIdentifier, PublicIdentifier] attribute DOMString publicAndPrivateAttribute; 30 [Conditional=TEST_FEATURE, PrivateIdentifier, PublicIdentifier] attribute DOMString publicAndPrivateConditionalAttribute; 31 [Conditional=TEST_FEATURE, EnabledAtRuntime=TestFeature] attribute DOMString enabledAtRuntimeAttribute; 32 void regularOperation(DOMString testParam); 33 [Conditional=TEST_FEATURE, EnabledAtRuntime=TestFeature] void enabledAtRuntimeOperation(DOMString testParam); 34 [Conditional=TEST_FEATURE, EnabledAtRuntime=TestFeature] void enabledAtRuntimeOperation(long testParam); 35 }; 26 // @conditional=ENABLE(FETCH_API) 27 28 function fetch(input, init) 29 { 30 "use strict"; 31 32 try { 33 return @fetchRequest(new @Request(input, init)); 34 } catch(e) { 35 return @Promise.@reject(e); 36 } 37 } -
trunk/Source/WebCore/Modules/fetch/FetchHeaders.h
r200546 r203641 27 27 */ 28 28 29 #ifndef FetchHeaders_h 30 #define FetchHeaders_h 29 #pragma once 31 30 32 31 #if ENABLE(FETCH_API) … … 80 79 const HTTPHeaderMap& internalHeaders() const { return m_headers; } 81 80 81 void setGuard(Guard); 82 82 83 private: 83 84 FetchHeaders(Guard guard) : m_guard(guard) { } … … 88 89 }; 89 90 91 inline void FetchHeaders::setGuard(Guard guard) 92 { 93 ASSERT(!m_headers.size()); 94 m_guard = guard; 95 } 96 90 97 } // namespace WebCore 91 98 92 99 #endif // ENABLE(FETCH_API) 93 94 #endif // FetchHeaders_h -
trunk/Source/WebCore/Modules/fetch/FetchRequest.cpp
r203221 r203641 194 194 } 195 195 196 static RefPtr<FetchHeaders> buildHeaders(const Dictionary& init, const FetchRequest::InternalRequest& request, const FetchHeaders* inputHeaders = nullptr)197 {198 FetchHeaders::Guard guard = FetchHeaders::Guard::Request;199 if (request.options.mode == FetchOptions::Mode::NoCors) {200 const String& method = request.request.httpMethod();201 if (method != "GET" && method != "POST" && method != "HEAD")202 return nullptr;203 if (!request.integrity.isEmpty())204 return nullptr;205 guard = FetchHeaders::Guard::RequestNoCors;206 }207 208 RefPtr<FetchHeaders> initialHeaders;209 RefPtr<FetchHeaders> headers = FetchHeaders::create(guard);210 headers->fill(init.get("headers", initialHeaders) ? initialHeaders.get() : inputHeaders);211 212 return headers;213 }214 215 static FetchBody buildBody(const Dictionary& init, FetchHeaders& headers, FetchBody* inputBody = nullptr)216 {217 JSC::JSValue value;218 bool hasInitBody = init.get("body", value);219 FetchBody body = hasInitBody ? FetchBody::extract(*init.execState(), value) : FetchBody::extractFromBody(inputBody);220 221 String type = headers.fastGet(HTTPHeaderName::ContentType);222 if (hasInitBody && type.isEmpty() && !body.mimeType().isEmpty()) {223 type = body.mimeType();224 headers.fastSet(HTTPHeaderName::ContentType, type);225 }226 body.setMimeType(type);227 return body;228 }229 230 196 static bool validateBodyAndMethod(const FetchBody& body, const FetchRequest::InternalRequest& internalRequest) 231 197 { … … 235 201 } 236 202 237 RefPtr<FetchRequest> FetchRequest::create(ScriptExecutionContext& context, const String& url, const Dictionary& init, ExceptionCode& ec) 238 { 203 void FetchRequest::initializeOptions(const Dictionary& init, ExceptionCode& ec) 204 { 205 ASSERT(scriptExecutionContext()); 206 if (!buildOptions(m_internalRequest, *scriptExecutionContext(), init)) { 207 ec = TypeError; 208 return; 209 } 210 211 if (m_internalRequest.options.mode == FetchOptions::Mode::NoCors) { 212 const String& method = m_internalRequest.request.httpMethod(); 213 if (method != "GET" && method != "POST" && method != "HEAD") { 214 ec = TypeError; 215 return; 216 } 217 if (!m_internalRequest.integrity.isEmpty()) { 218 ec = TypeError; 219 return; 220 } 221 m_headers->setGuard(FetchHeaders::Guard::RequestNoCors); 222 } 223 } 224 225 FetchHeaders* FetchRequest::initializeWith(const String& url, const Dictionary& init, ExceptionCode& ec) 226 { 227 ASSERT(scriptExecutionContext()); 239 228 // FIXME: Tighten the URL parsing algorithm according https://url.spec.whatwg.org/#concept-url-parser. 240 URL requestURL = context.completeURL(url);229 URL requestURL = scriptExecutionContext()->completeURL(url); 241 230 if (!requestURL.isValid() || !requestURL.user().isEmpty() || !requestURL.pass().isEmpty()) { 242 231 ec = TypeError; … … 244 233 } 245 234 246 FetchRequest::InternalRequest internalRequest; 247 internalRequest.options.mode = Mode::Cors; 248 internalRequest.options.credentials = Credentials::Omit; 249 internalRequest.referrer = ASCIILiteral("client"); 250 internalRequest.request.setURL(requestURL); 251 252 if (!buildOptions(internalRequest, context, init)) { 235 m_internalRequest.options.mode = Mode::Cors; 236 m_internalRequest.options.credentials = Credentials::Omit; 237 m_internalRequest.referrer = ASCIILiteral("client"); 238 m_internalRequest.request.setURL(requestURL); 239 240 initializeOptions(init, ec); 241 return m_headers.ptr(); 242 } 243 244 FetchHeaders* FetchRequest::initializeWith(FetchRequest& input, const Dictionary& init, ExceptionCode& ec) 245 { 246 if (input.isDisturbed()) { 253 247 ec = TypeError; 254 248 return nullptr; 255 249 } 256 250 257 RefPtr<FetchHeaders> headers = buildHeaders(init, internalRequest); 258 if (!headers) { 259 ec = TypeError; 260 return nullptr; 261 } 262 263 FetchBody body = buildBody(init, *headers); 264 if (!validateBodyAndMethod(body, internalRequest)) { 265 ec = TypeError; 266 return nullptr; 267 } 268 269 return adoptRef(*new FetchRequest(context, WTFMove(body), headers.releaseNonNull(), WTFMove(internalRequest))); 270 } 271 272 RefPtr<FetchRequest> FetchRequest::create(ScriptExecutionContext& context, FetchRequest& input, const Dictionary& init, ExceptionCode& ec) 273 { 274 if (input.isDisturbed()) { 275 ec = TypeError; 276 return nullptr; 277 } 278 279 FetchRequest::InternalRequest internalRequest(input.m_internalRequest); 280 281 if (!buildOptions(internalRequest, context, init)) { 282 ec = TypeError; 283 return nullptr; 284 } 285 286 RefPtr<FetchHeaders> headers = buildHeaders(init, internalRequest, input.m_headers.ptr()); 287 if (!headers) { 288 ec = TypeError; 289 return nullptr; 290 } 291 292 FetchBody body = buildBody(init, *headers, &input.m_body); 293 if (!validateBodyAndMethod(body, internalRequest)) { 294 ec = TypeError; 295 return nullptr; 296 } 297 298 if (!input.m_body.isEmpty()) 299 input.setDisturbed(); 300 301 return adoptRef(*new FetchRequest(context, WTFMove(body), headers.releaseNonNull(), WTFMove(internalRequest))); 251 m_internalRequest = input.m_internalRequest; 252 253 initializeOptions(init, ec); 254 return m_headers.ptr(); 255 } 256 257 void FetchRequest::setBody(JSC::ExecState& execState, JSC::JSValue body, FetchRequest* request, ExceptionCode& ec) 258 { 259 if (!body.isNull()) 260 m_body = FetchBody::extract(execState, body); 261 else if (request && !request->m_body.isEmpty()) { 262 m_body = FetchBody::extractFromBody(&request->m_body); 263 request->setDisturbed(); 264 } 265 266 String type = m_headers->fastGet(HTTPHeaderName::ContentType); 267 if (!body.isUndefined() && type.isEmpty() && !m_body.mimeType().isEmpty()) { 268 type = m_body.mimeType(); 269 m_headers->fastSet(HTTPHeaderName::ContentType, type); 270 } 271 m_body.setMimeType(type); 272 if (!validateBodyAndMethod(m_body, m_internalRequest)) 273 ec = TypeError; 302 274 } 303 275 -
trunk/Source/WebCore/Modules/fetch/FetchRequest.h
r203221 r203641 46 46 class FetchRequest final : public FetchBodyOwner { 47 47 public: 48 static RefPtr<FetchRequest> create(ScriptExecutionContext&, FetchRequest&, const Dictionary&, ExceptionCode&); 49 static RefPtr<FetchRequest> create(ScriptExecutionContext&, const String&, const Dictionary&, ExceptionCode&); 48 static Ref<FetchRequest> create(ScriptExecutionContext& context) { return adoptRef(*new FetchRequest(context, { }, FetchHeaders::create(FetchHeaders::Guard::Request), { })); } 49 50 FetchHeaders* initializeWith(FetchRequest&, const Dictionary&, ExceptionCode&); 51 FetchHeaders* initializeWith(const String&, const Dictionary&, ExceptionCode&); 52 void setBody(JSC::ExecState&, JSC::JSValue, FetchRequest*, ExceptionCode&); 50 53 51 54 const String& method() const { return m_internalRequest.request.httpMethod(); } … … 92 95 private: 93 96 FetchRequest(ScriptExecutionContext&, FetchBody&&, Ref<FetchHeaders>&&, InternalRequest&&); 97 98 void initializeOptions(const Dictionary&, ExceptionCode&); 94 99 95 100 // ActiveDOMObject API. -
trunk/Source/WebCore/Modules/fetch/FetchRequest.idl
r202323 r203641 38 38 ActiveDOMObject, 39 39 Conditional=FETCH_API, 40 Constructor(any input, optional Dictionary init), 40 41 EnabledAtRuntime=FetchAPI, 41 ConstructorCallWith=ScriptExecutionContext,42 ConstructorRaisesException,43 Constructor(FetchRequest input, optional Dictionary init),44 Constructor(DOMString input, optional Dictionary init),45 42 Exposed=(Window,Worker), 46 InterfaceName=Request 43 InterfaceName=Request, 44 JSBuiltinConstructor, 45 PrivateIdentifier, 46 PublicIdentifier, 47 47 ] 48 48 interface FetchRequest { … … 62 62 63 63 [NewObject, CallWith=ScriptExecutionContext, RaisesException] FetchRequest clone(); 64 65 [PrivateIdentifier, RaisesException] FetchHeaders initializeWith(FetchRequest input, Dictionary init); 66 [PrivateIdentifier, RaisesException] FetchHeaders initializeWith(DOMString input, Dictionary init); 67 [PrivateIdentifier, RaisesException, CallWith=ScriptState] void setBody(any body, FetchRequest? request); 64 68 }; 65 69 FetchRequest implements FetchBody; -
trunk/Source/WebCore/Modules/fetch/FetchRequest.js
r203640 r203641 1 1 /* 2 * Copyright (C) 2016 Apple Inc. All rights reserved.2 * Copyright (C) 2016 Apple Inc. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 // This interface is recognized as a global object by the bindings generator. 27 interface TestGlobalObject { 28 attribute DOMString regularAttribute; 29 [PrivateIdentifier, PublicIdentifier] attribute DOMString publicAndPrivateAttribute; 30 [Conditional=TEST_FEATURE, PrivateIdentifier, PublicIdentifier] attribute DOMString publicAndPrivateConditionalAttribute; 31 [Conditional=TEST_FEATURE, EnabledAtRuntime=TestFeature] attribute DOMString enabledAtRuntimeAttribute; 32 void regularOperation(DOMString testParam); 33 [Conditional=TEST_FEATURE, EnabledAtRuntime=TestFeature] void enabledAtRuntimeOperation(DOMString testParam); 34 [Conditional=TEST_FEATURE, EnabledAtRuntime=TestFeature] void enabledAtRuntimeOperation(long testParam); 35 }; 26 // @conditional=ENABLE(FETCH_API) 27 28 function initializeFetchRequest(input, init) 29 { 30 "use strict"; 31 32 if (init === @undefined) 33 init = { }; 34 else if (!@isObject(init)) 35 throw new @TypeError("Request init must be an object"); 36 37 let headers = this.@initializeWith(input, init); 38 @assert(headers instanceof @Headers); 39 40 let inputIsRequest = input instanceof @Request; 41 if ("headers" in init) 42 @fillFetchHeaders(headers, init.headers) 43 else if (inputIsRequest) 44 @fillFetchHeaders(headers, input.headers) 45 46 let hasInitBody = init.body !== @undefined && init.body !== null; 47 this.@setBody(hasInitBody ? init.body : null, inputIsRequest ? input : null); 48 49 return this; 50 } -
trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp
r203637 r203641 103 103 } 104 104 105 void FetchResponse:: startFetching(ScriptExecutionContext& context, constFetchRequest& request, FetchPromise&& promise)105 void FetchResponse::fetch(ScriptExecutionContext& context, FetchRequest& request, FetchPromise&& promise) 106 106 { 107 107 auto response = adoptRef(*new FetchResponse(context, FetchBody::loadingBody(), FetchHeaders::create(FetchHeaders::Guard::Immutable), { })); … … 115 115 } 116 116 117 void FetchResponse::fetch(ScriptExecutionContext& context, FetchRequest& input, const Dictionary& dictionary, FetchPromise&& promise)118 {119 ExceptionCode ec = 0;120 RefPtr<FetchRequest> fetchRequest = FetchRequest::create(context, input, dictionary, ec);121 if (ec) {122 promise.reject(ec);123 return;124 }125 ASSERT(fetchRequest);126 startFetching(context, *fetchRequest, WTFMove(promise));127 }128 129 117 const String& FetchResponse::url() const 130 118 { … … 132 120 m_responseURL = m_response.url().serialize(true); 133 121 return m_responseURL; 134 }135 136 void FetchResponse::fetch(ScriptExecutionContext& context, const String& url, const Dictionary& dictionary, FetchPromise&& promise)137 {138 ExceptionCode ec = 0;139 RefPtr<FetchRequest> fetchRequest = FetchRequest::create(context, url, dictionary, ec);140 if (ec) {141 promise.reject(ec);142 return;143 }144 ASSERT(fetchRequest);145 startFetching(context, *fetchRequest, WTFMove(promise));146 122 } 147 123 -
trunk/Source/WebCore/Modules/fetch/FetchResponse.h
r203445 r203641 58 58 59 59 using FetchPromise = DOMPromise<FetchResponse>; 60 static void fetch(ScriptExecutionContext&, FetchRequest&, const Dictionary&, FetchPromise&&); 61 static void fetch(ScriptExecutionContext&, const String&, const Dictionary&, FetchPromise&&); 62 60 static void fetch(ScriptExecutionContext&, FetchRequest&, FetchPromise&&); 63 61 64 62 void setStatus(int, const String&, ExceptionCode&); -
trunk/Source/WebCore/Modules/fetch/WorkerGlobalScopeFetch.cpp
r198891 r203641 37 37 namespace WebCore { 38 38 39 void WorkerGlobalScopeFetch::fetch(WorkerGlobalScope& scope, FetchRequest& input, const Dictionary& dictionary, DeferredWrapper&& promise)39 void WorkerGlobalScopeFetch::fetch(WorkerGlobalScope& scope, FetchRequest& request, DeferredWrapper&& promise) 40 40 { 41 41 if (!scope.scriptExecutionContext()) 42 42 return; 43 FetchResponse::fetch(*scope.scriptExecutionContext(), input, dictionary, WTFMove(promise)); 44 } 45 46 void WorkerGlobalScopeFetch::fetch(WorkerGlobalScope& scope, const String& url, const Dictionary& dictionary, DeferredWrapper&& promise) 47 { 48 if (!scope.scriptExecutionContext()) 49 return; 50 FetchResponse::fetch(*scope.scriptExecutionContext(), url, dictionary, WTFMove(promise)); 43 FetchResponse::fetch(*scope.scriptExecutionContext(), request, WTFMove(promise)); 51 44 } 52 45 -
trunk/Source/WebCore/Modules/fetch/WorkerGlobalScopeFetch.h
r198891 r203641 26 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 #ifndef WorkerGlobalScopeFetch_h 29 # define WorkerGlobalScopeFetch_h28 29 #pragma once 30 30 31 31 #if ENABLE(FETCH_API) … … 38 38 class WorkerGlobalScope; 39 39 class DeferredWrapper; 40 class Dictionary;41 40 class FetchRequest; 42 41 43 42 class WorkerGlobalScopeFetch { 44 43 public: 45 static void fetch(WorkerGlobalScope&, FetchRequest&, const Dictionary&, DeferredWrapper&&); 46 static void fetch(WorkerGlobalScope&, const String&, const Dictionary&, DeferredWrapper&&); 44 static void fetch(WorkerGlobalScope&, FetchRequest&, DeferredWrapper&&); 47 45 }; 48 46 … … 50 48 51 49 #endif // ENABLE(FETCH_API) 52 53 #endif // WorkerGlobalScopeFetch_h -
trunk/Source/WebCore/Modules/fetch/WorkerGlobalScopeFetch.idl
r199081 r203641 31 31 EnabledAtRuntime=FetchAPI, 32 32 ] partial interface WorkerGlobalScope { 33 Promise fetch(DOMString input, optional Dictionary init); 34 Promise fetch(FetchRequest input, optional Dictionary init); 33 [JSBuiltin] Promise fetch(any input, optional Dictionary init); 34 35 [PrivateIdentifier, ImplementedAs=fetch] Promise fetchRequest(FetchRequest request); 35 36 }; -
trunk/Source/WebCore/Modules/fetch/WorkerGlobalScopeFetch.js
r203640 r203641 1 1 /* 2 * Copyright (C) 2016 Apple Inc. All rights reserved.2 * Copyright (C) 2016 Apple Inc. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 // This interface is recognized as a global object by the bindings generator. 27 interface TestGlobalObject { 28 attribute DOMString regularAttribute; 29 [PrivateIdentifier, PublicIdentifier] attribute DOMString publicAndPrivateAttribute; 30 [Conditional=TEST_FEATURE, PrivateIdentifier, PublicIdentifier] attribute DOMString publicAndPrivateConditionalAttribute; 31 [Conditional=TEST_FEATURE, EnabledAtRuntime=TestFeature] attribute DOMString enabledAtRuntimeAttribute; 32 void regularOperation(DOMString testParam); 33 [Conditional=TEST_FEATURE, EnabledAtRuntime=TestFeature] void enabledAtRuntimeOperation(DOMString testParam); 34 [Conditional=TEST_FEATURE, EnabledAtRuntime=TestFeature] void enabledAtRuntimeOperation(long testParam); 35 }; 26 // @conditional=ENABLE(FETCH_API) 27 28 function fetch(input, init) 29 { 30 "use strict"; 31 32 try { 33 return @fetchRequest(new @Request(input, init)); 34 } catch(e) { 35 return @Promise.@reject(e); 36 } 37 } -
trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h
r203632 r203641 42 42 macro(createReadableStreamSource) \ 43 43 macro(disturbed) \ 44 macro(fetchRequest) \ 44 45 macro(fillFromJS) \ 45 46 macro(firstReadCallback) \ … … 69 70 macro(retrieveResponse) \ 70 71 macro(response) \ 72 macro(setBody) \ 71 73 macro(setStatus) \ 72 74 macro(state) \ … … 90 92 macro(ReadableStreamReader) \ 91 93 macro(ReadableStreamController) \ 94 macro(Request) \ 92 95 macro(Response) \ 93 96 macro(RTCIceCandidate) \ -
trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm
r203337 r203641 560 560 my ($object, $param) = @_; 561 561 my $ret = lcfirst($param); 562 $ret =~ s/dOM/dom/ if $ret =~ /^dOM/; 562 563 $ret =~ s/hTML/html/ if $ret =~ /^hTML/; 563 564 $ret =~ s/uRL/url/ if $ret =~ /^uRL/; -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r203463 r203641 2420 2420 my $jsAttributes = ComputeFunctionSpecial($interface, $function); 2421 2421 push(@implContent, " if (${enable_function}())\n"); 2422 push(@implContent, " putDirectNativeFunction(vm, this, vm.propertyNames->$functionName, $functionLength, $implementationFunction, NoIntrinsic, attributesForStructure($jsAttributes));\n"); 2422 2423 my $propertyName = "vm.propertyNames->$functionName"; 2424 if ($function->signature->extendedAttributes->{"PrivateIdentifier"}) { 2425 $propertyName = "static_cast<JSVMClientData*>(vm.clientData)->builtinNames()." . $functionName . "PrivateName()"; 2426 } 2427 if (IsJSBuiltin($interface, $function)) { 2428 push(@implContent, " putDirectBuiltinFunction(vm, this, $propertyName, $implementationFunction(vm), attributesForStructure($jsAttributes));\n"); 2429 } else { 2430 push(@implContent, " putDirectNativeFunction(vm, this, $propertyName, $functionLength, $implementationFunction, NoIntrinsic, attributesForStructure($jsAttributes));\n"); 2431 } 2423 2432 push(@implContent, "#endif\n") if $conditionalString; 2424 2433 } 2425 2434 push(@implContent, "}\n\n"); 2426 2435 } 2427 2436 2428 2437 unless (ShouldUseGlobalObjectPrototype($interface)) { 2429 2438 push(@implContent, "JSObject* ${className}::createPrototype(VM& vm, JSGlobalObject* globalObject)\n"); -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestGlobalObject.cpp
r202551 r203641 34 34 #include <wtf/GetPtr.h> 35 35 36 #if ENABLE(TEST_FEATURE) 37 #include "TestGlobalObjectBuiltins.h" 38 #endif 39 36 40 using namespace JSC; 37 41 … … 43 47 #if ENABLE(TEST_FEATURE) 44 48 JSC::EncodedJSValue JSC_HOST_CALL jsTestGlobalObjectInstanceFunctionEnabledAtRuntimeOperation(JSC::ExecState*); 49 #endif 50 #if ENABLE(TEST_FEATURE) 51 JSC::EncodedJSValue JSC_HOST_CALL jsTestGlobalObjectInstanceFunctionTestPrivateFunction(JSC::ExecState*); 45 52 #endif 46 53 … … 154 161 if (RuntimeEnabledFeatures::sharedFeatures().testFeatureEnabled()) 155 162 putDirectNativeFunction(vm, this, vm.propertyNames->enabledAtRuntimeOperation, 1, jsTestGlobalObjectInstanceFunctionEnabledAtRuntimeOperation, NoIntrinsic, attributesForStructure(JSC::Function)); 163 #endif 164 #if ENABLE(TEST_FEATURE) 165 if (RuntimeEnabledFeatures::sharedFeatures().testFeatureEnabled()) 166 putDirectNativeFunction(vm, this, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().testPrivateFunctionPrivateName(), 0, jsTestGlobalObjectInstanceFunctionTestPrivateFunction, NoIntrinsic, attributesForStructure(JSC::Function)); 167 #endif 168 #if ENABLE(TEST_FEATURE) 169 if (RuntimeEnabledFeatures::sharedFeatures().testFeatureEnabled()) 170 putDirectBuiltinFunction(vm, this, vm.propertyNames->testJSBuiltinFunction, testGlobalObjectTestJSBuiltinFunctionCodeGenerator(vm), attributesForStructure(JSC::Builtin)); 156 171 #endif 157 172 } … … 398 413 return throwVMTypeError(state); 399 414 } 415 416 #if ENABLE(TEST_FEATURE) 417 EncodedJSValue JSC_HOST_CALL jsTestGlobalObjectInstanceFunctionTestPrivateFunction(ExecState* state) 418 { 419 JSValue thisValue = state->thisValue(); 420 auto castedThis = jsDynamicCast<JSTestGlobalObject*>(thisValue); 421 if (UNLIKELY(!castedThis)) 422 return throwThisTypeError(*state, "TestGlobalObject", "testPrivateFunction"); 423 ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestGlobalObject::info()); 424 auto& impl = castedThis->wrapped(); 425 impl.testPrivateFunction(); 426 return JSValue::encode(jsUndefined()); 427 } 428 429 #endif 400 430 401 431 bool JSTestGlobalObjectOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor) -
trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestGlobalObject.mm
r202551 r203641 133 133 #endif 134 134 135 136 #if ENABLE(TEST_FEATURE) 137 - (void)testJSBuiltinFunction 138 { 139 WebCore::JSMainThreadNullState state; 140 IMPL->testJSBuiltinFunction(); 141 } 142 143 #endif 144 135 145 @end 136 146 -
trunk/Source/WebCore/bindings/scripts/test/TestGlobalObject.idl
r202551 r203641 33 33 [Conditional=TEST_FEATURE, EnabledAtRuntime=TestFeature] void enabledAtRuntimeOperation(DOMString testParam); 34 34 [Conditional=TEST_FEATURE, EnabledAtRuntime=TestFeature] void enabledAtRuntimeOperation(long testParam); 35 36 [PrivateIdentifier, Conditional=TEST_FEATURE, EnabledAtRuntime=TestFeature] void testPrivateFunction(); 37 [JSBuiltin, Conditional=TEST_FEATURE, EnabledAtRuntime=TestFeature] void testJSBuiltinFunction(); 35 38 };
Note: See TracChangeset
for help on using the changeset viewer.