| Index: Source/modules/serviceworkers/ServiceWorkerGlobalScope.cpp
|
| diff --git a/Source/modules/serviceworkers/ServiceWorkerGlobalScope.cpp b/Source/modules/serviceworkers/ServiceWorkerGlobalScope.cpp
|
| index 9551b55a49d8117937d37bb59e7ebb39969954df..6e2878a19f8818b205861ba3366e38073dd9b905 100644
|
| --- a/Source/modules/serviceworkers/ServiceWorkerGlobalScope.cpp
|
| +++ b/Source/modules/serviceworkers/ServiceWorkerGlobalScope.cpp
|
| @@ -33,7 +33,9 @@
|
| #include "bindings/core/v8/ScriptPromise.h"
|
| #include "bindings/core/v8/ScriptState.h"
|
| #include "bindings/core/v8/V8ThrowException.h"
|
| +#include "core/fetch/ResourceLoaderOptions.h"
|
| #include "core/inspector/ScriptCallStack.h"
|
| +#include "core/loader/ThreadableLoader.h"
|
| #include "core/workers/WorkerClients.h"
|
| #include "core/workers/WorkerThreadStartupData.h"
|
| #include "modules/CachePolyfill.h"
|
| @@ -88,18 +90,50 @@ String ServiceWorkerGlobalScope::scope(ExecutionContext* context)
|
|
|
| ScriptPromise ServiceWorkerGlobalScope::fetch(ScriptState* scriptState, Request* request)
|
| {
|
| - OwnPtr<ResourceRequest> resourceRequest(request->createResourceRequest());
|
| - return m_fetchManager->fetch(scriptState, resourceRequest.release());
|
| + TrackExceptionState exceptionState;
|
| + // Let r be the associated request of the result of invoking the initial
|
| + // value of Request as constructor with input and init as arguments. If this
|
| + // throws an exception, reject p with it.
|
| + RefPtr<Request> r = Request::create(this, request, exceptionState);
|
| + if (exceptionState.hadException())
|
| + return ScriptPromise::reject(scriptState, V8ThrowException::createTypeError(exceptionState.message(), scriptState->isolate()));
|
| + return m_fetchManager->fetch(scriptState, r->request());
|
| +}
|
| +
|
| +ScriptPromise ServiceWorkerGlobalScope::fetch(ScriptState* scriptState, Request* request, const Dictionary& requestInit)
|
| +{
|
| + TrackExceptionState exceptionState;
|
| + // Let r be the associated request of the result of invoking the initial
|
| + // value of Request as constructor with input and init as arguments. If this
|
| + // throws an exception, reject p with it.
|
| + RefPtr<Request> r = Request::create(this, request, requestInit, exceptionState);
|
| + if (exceptionState.hadException())
|
| + return ScriptPromise::reject(scriptState, V8ThrowException::createTypeError(exceptionState.message(), scriptState->isolate()));
|
| + return m_fetchManager->fetch(scriptState, r->request());
|
| }
|
|
|
| ScriptPromise ServiceWorkerGlobalScope::fetch(ScriptState* scriptState, const String& urlstring)
|
| {
|
| - KURL url = completeURL(urlstring);
|
| - if (!url.isValid())
|
| - return ScriptPromise::reject(scriptState, V8ThrowException::createTypeError("Invalid URL", scriptState->isolate()));
|
| - OwnPtr<ResourceRequest> resourceRequest = adoptPtr(new ResourceRequest(url));
|
| - resourceRequest->setHTTPMethod("GET");
|
| - return m_fetchManager->fetch(scriptState, resourceRequest.release());
|
| + TrackExceptionState exceptionState;
|
| + // Let r be the associated request of the result of invoking the initial
|
| + // value of Request as constructor with input and init as arguments. If this
|
| + // throws an exception, reject p with it.
|
| + RefPtr<Request> r = Request::create(this, urlstring, exceptionState);
|
| + if (exceptionState.hadException())
|
| + return ScriptPromise::reject(scriptState, V8ThrowException::createTypeError(exceptionState.message(), scriptState->isolate()));
|
| + return m_fetchManager->fetch(scriptState, r->request());
|
| +}
|
| +
|
| +ScriptPromise ServiceWorkerGlobalScope::fetch(ScriptState* scriptState, const String& urlstring, const Dictionary& requestInit)
|
| +{
|
| + TrackExceptionState exceptionState;
|
| + // Let r be the associated request of the result of invoking the initial
|
| + // value of Request as constructor with input and init as arguments. If this
|
| + // throws an exception, reject p with it.
|
| + RefPtr<Request> r = Request::create(this, urlstring, requestInit, exceptionState);
|
| + if (exceptionState.hadException())
|
| + return ScriptPromise::reject(scriptState, V8ThrowException::createTypeError(exceptionState.message(), scriptState->isolate()));
|
| + return m_fetchManager->fetch(scriptState, r->request());
|
| }
|
|
|
| PassRefPtr<ServiceWorkerClients> ServiceWorkerGlobalScope::clients()
|
|
|