fix: reject with error when url not loaded (#16571)
* fix: reject with error when url not loaded * improve descriptive spec naming
This commit is contained in:
parent
138ba53511
commit
a25f82c91f
2 changed files with 15 additions and 5 deletions
|
@ -1444,12 +1444,17 @@ v8::Local<v8::Promise> WebContents::HasServiceWorker() {
|
|||
auto* context = GetServiceWorkerContext(web_contents());
|
||||
if (!context) {
|
||||
promise->RejectWithErrorMessage("Unable to get ServiceWorker context.");
|
||||
return promise->GetHandle();
|
||||
}
|
||||
|
||||
GURL url = web_contents()->GetLastCommittedURL();
|
||||
if (!url.is_valid()) {
|
||||
promise->RejectWithErrorMessage("URL invalid or not yet loaded.");
|
||||
return promise->GetHandle();
|
||||
}
|
||||
|
||||
context->CheckHasServiceWorker(
|
||||
web_contents()->GetLastCommittedURL(),
|
||||
web_contents()->GetLastCommittedURL(),
|
||||
base::BindOnce(&OnServiceWorkerCheckDone, promise));
|
||||
url, url, base::BindOnce(&OnServiceWorkerCheckDone, promise));
|
||||
|
||||
return promise->GetHandle();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue