service worker: When claiming, don't assume document_url is valid
Many provider hosts have an empty document_url, for example those
that haven't yet been loaded or those created for special URLs like
chrome-search://. So that claim can use IsContextSecureForServiceWorker,
return false when the URL is invalid instead of doing a
DCHECK that it's valid.
BUG=621762,607543
Review-Url: https://codereview.chromium.org/2085923002
Cr-Commit-Position: refs/heads/master@{#401216}
diff --git a/content/browser/service_worker/service_worker_provider_host.cc b/content/browser/service_worker/service_worker_provider_host.cc
index d823e2c..0208e54 100644
--- a/content/browser/service_worker/service_worker_provider_host.cc
+++ b/content/browser/service_worker/service_worker_provider_host.cc
@@ -119,7 +119,12 @@
}
bool ServiceWorkerProviderHost::IsContextSecureForServiceWorker() const {
- DCHECK(document_url_.is_valid());
+ // |document_url_| may be empty if loading has not begun, or
+ // ServiceWorkerRequestHandler didn't handle the load (because e.g. another
+ // handler did first, or the initial request URL was such that
+ // OriginCanAccessServiceWorkers returned false).
+ if (!document_url_.is_valid())
+ return false;
if (!OriginCanAccessServiceWorkers(document_url_))
return false;