Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Side by Side Diff: third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerWindowClient.cpp

Issue 1505023004: ServiceWorker: Early reject error if url is something wrong. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "modules/serviceworkers/ServiceWorkerWindowClient.h" 6 #include "modules/serviceworkers/ServiceWorkerWindowClient.h"
7 7
8 #include "bindings/core/v8/CallbackPromiseAdapter.h" 8 #include "bindings/core/v8/CallbackPromiseAdapter.h"
9 #include "bindings/core/v8/ScriptPromiseResolver.h" 9 #include "bindings/core/v8/ScriptPromiseResolver.h"
10 #include "core/dom/DOMException.h" 10 #include "core/dom/DOMException.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 return promise; 61 return promise;
62 } 62 }
63 63
64 ScriptPromise ServiceWorkerWindowClient::navigate(ScriptState* scriptState, cons t String& url) 64 ScriptPromise ServiceWorkerWindowClient::navigate(ScriptState* scriptState, cons t String& url)
65 { 65 {
66 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; 66 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
67 ScriptPromise promise = resolver->promise(); 67 ScriptPromise promise = resolver->promise();
68 ExecutionContext* context = scriptState->executionContext(); 68 ExecutionContext* context = scriptState->executionContext();
69 69
70 KURL parsedUrl = KURL(toWorkerGlobalScope(context)->location()->url(), url); 70 KURL parsedUrl = KURL(toWorkerGlobalScope(context)->location()->url(), url);
71 if (!parsedUrl.isValid() || parsedUrl.protocolIsAbout()) { 71 if (!parsedUrl.isValid() || !parsedUrl.protocolIsInHTTPFamily()) {
72 resolver->reject(V8ThrowException::createTypeError(scriptState->isolate( ), "'" + url + "' is not a valid URL.")); 72 resolver->reject(V8ThrowException::createTypeError(scriptState->isolate( ), "'" + url + "' is not a valid URL."));
73 return promise; 73 return promise;
74 } 74 }
75 if (!context->securityOrigin()->canDisplay(parsedUrl)) { 75 if (!context->securityOrigin()->canDisplay(parsedUrl)) {
76 resolver->reject(V8ThrowException::createTypeError(scriptState->isolate( ), "'" + parsedUrl.elidedString() + "' cannot navigate.")); 76 resolver->reject(V8ThrowException::createTypeError(scriptState->isolate( ), "'" + parsedUrl.elidedString() + "' cannot navigate."));
77 return promise; 77 return promise;
78 } 78 }
79 79
80 ServiceWorkerGlobalScopeClient::from(context)->navigate(uuid(), parsedUrl, n ew NavigateClientCallback(resolver)); 80 ServiceWorkerGlobalScopeClient::from(context)->navigate(uuid(), parsedUrl, n ew NavigateClientCallback(resolver));
81 return promise; 81 return promise;
82 } 82 }
83 83
84 DEFINE_TRACE(ServiceWorkerWindowClient) 84 DEFINE_TRACE(ServiceWorkerWindowClient)
85 { 85 {
86 ServiceWorkerClient::trace(visitor); 86 ServiceWorkerClient::trace(visitor);
87 } 87 }
88 88
89 } // namespace blink 89 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698