Commit d11bec83 authored by Miyoung Shin's avatar Miyoung Shin Committed by Commit Bot

Use [RaisesException] for immediate promise rejections in cache_storage

This is a part of effort for using [RaisesException] when
synchronously rejecting a promise.

It uses [RaisesException] for
//third_party/blink/renderer/modules/cache_storage.

Bug: 1001114
Change-Id: I78e3b02518e5c04725f50abb9e6ca54b191f3bc9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1985833Reviewed-by: default avatarJeremy Roman <jbroman@chromium.org>
Commit-Queue: Miyoung Shin <myid.shin@igalia.com>
Cr-Commit-Position: refs/heads/master@{#728435}
parent b59b8402
......@@ -860,18 +860,15 @@ ScriptPromise Cache::AddAllImpl(ScriptState* script_state,
promises.resize(requests.size());
for (wtf_size_t i = 0; i < requests.size(); ++i) {
if (!requests[i]->url().ProtocolIsInHTTPFamily()) {
return ScriptPromise::Reject(script_state,
V8ThrowException::CreateTypeError(
script_state->GetIsolate(),
"Add/AddAll does not support schemes "
"other than \"http\" or \"https\""));
exception_state.ThrowTypeError(
"Add/AddAll does not support schemes "
"other than \"http\" or \"https\"");
return ScriptPromise();
}
if (requests[i]->method() != http_names::kGET) {
return ScriptPromise::Reject(
script_state,
V8ThrowException::CreateTypeError(
script_state->GetIsolate(),
"Add/AddAll only supports the GET request method."));
exception_state.ThrowTypeError(
"Add/AddAll only supports the GET request method.");
return ScriptPromise();
}
request_infos[i].SetRequest(requests[i]);
......
......@@ -62,7 +62,7 @@ class ScopedFetcherForTests final
ScriptPromise Fetch(ScriptState* script_state,
const RequestInfo& request_info,
const RequestInit*,
ExceptionState&) override {
ExceptionState& exception_state) override {
++fetch_count_;
if (expected_url_) {
String fetched_url;
......@@ -80,10 +80,9 @@ class ScopedFetcherForTests final
response_ = nullptr;
return promise;
}
return ScriptPromise::Reject(
script_state, V8ThrowException::CreateTypeError(
script_state->GetIsolate(),
"Unexpected call to fetch, no response available."));
exception_state.ThrowTypeError(
"Unexpected call to fetch, no response available.");
return ScriptPromise();
}
// This does not take ownership of its parameter. The provided sample object
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment