| Index: third_party/WebKit/Source/modules/serviceworkers/InstallEvent.cpp
|
| diff --git a/third_party/WebKit/Source/modules/serviceworkers/InstallEvent.cpp b/third_party/WebKit/Source/modules/serviceworkers/InstallEvent.cpp
|
| index 1cd134969c6b8998180c25147ea56a350991b341..0ad0cc29c13563036c4d2e229968c9c8c5aefbad 100644
|
| --- a/third_party/WebKit/Source/modules/serviceworkers/InstallEvent.cpp
|
| +++ b/third_party/WebKit/Source/modules/serviceworkers/InstallEvent.cpp
|
| @@ -4,6 +4,7 @@
|
|
|
| #include "modules/serviceworkers/InstallEvent.h"
|
|
|
| +#include "bindings/modules/v8/UnionTypesModules.h"
|
| #include "core/dom/ExceptionCode.h"
|
| #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h"
|
|
|
| @@ -28,13 +29,39 @@ InstallEvent::~InstallEvent()
|
| {
|
| }
|
|
|
| -void InstallEvent::registerForeignFetchScopes(ExecutionContext* executionContext, const Vector<String>& subScopes, ExceptionState& exceptionState)
|
| +void InstallEvent::registerForeignFetchScopes(ExecutionContext* executionContext, const Vector<String>& subScopes, const USVStringOrUSVStringSequence& origins, ExceptionState& exceptionState)
|
| {
|
| if (!isBeingDispatched()) {
|
| exceptionState.throwDOMException(InvalidStateError, "The event handler is already finished.");
|
| return;
|
| }
|
|
|
| + Vector<String> originList;
|
| + if (origins.isUSVString()) {
|
| + originList.append(origins.getAsUSVString());
|
| + } else if (origins.isUSVStringSequence()) {
|
| + originList = origins.getAsUSVStringSequence();
|
| + }
|
| + if (originList.isEmpty()) {
|
| + exceptionState.throwTypeError("At least one origin is required");
|
| + return;
|
| + }
|
| +
|
| + // The origins parameter is either just a "*" to indicate all origins, or an
|
| + // explicit list of origins as absolute URLs. Internally an empty list of
|
| + // origins is used to represent the "*" case though.
|
| + Vector<KURL> originURLs;
|
| + if (originList.size() != 1 || originList[0] != "*") {
|
| + originURLs.resize(originList.size());
|
| + for (size_t i = 0; i < originList.size(); ++i) {
|
| + originURLs[i] = KURL(KURL(), originList[i]);
|
| + if (!originURLs[i].isValid()) {
|
| + exceptionState.throwTypeError("Invalid origin URL: " + originList[i]);
|
| + return;
|
| + }
|
| + }
|
| + }
|
| +
|
| ServiceWorkerGlobalScopeClient* client = ServiceWorkerGlobalScopeClient::from(executionContext);
|
|
|
| String scopePath = static_cast<KURL>(client->scope()).path();
|
| @@ -44,21 +71,21 @@ void InstallEvent::registerForeignFetchScopes(ExecutionContext* executionContext
|
| for (size_t i = 0; i < subScopes.size(); ++i) {
|
| subScopeURLs[i] = executionContext->completeURL(subScopes[i]);
|
| if (!subScopeURLs[i].isValid()) {
|
| - exceptionState.throwTypeError("Invalid URL: " + subScopes[i]);
|
| + exceptionState.throwTypeError("Invalid subscope URL: " + subScopes[i]);
|
| return;
|
| }
|
| subScopeURLs[i].removeFragmentIdentifier();
|
| if (!origin->canRequest(subScopeURLs[i])) {
|
| - exceptionState.throwTypeError("URL is not within scope: " + subScopes[i]);
|
| + exceptionState.throwTypeError("Subscope URL is not within scope: " + subScopes[i]);
|
| return;
|
| }
|
| String subScopePath = subScopeURLs[i].path();
|
| if (!subScopePath.startsWith(scopePath)) {
|
| - exceptionState.throwTypeError("URL is not within scope: " + subScopes[i]);
|
| + exceptionState.throwTypeError("Subscope URL is not within scope: " + subScopes[i]);
|
| return;
|
| }
|
| }
|
| - client->registerForeignFetchScopes(subScopeURLs);
|
| + client->registerForeignFetchScopes(subScopeURLs, originURLs);
|
| }
|
|
|
| const AtomicString& InstallEvent::interfaceName() const
|
|
|