Commit b19e29b0 authored by Dominic Farolino's avatar Dominic Farolino Committed by Commit Bot

Use nullable interface for RequestInit AbortSignal

R=kinuko@chromium.org, peria@chromium.org, ricea@chromium.org, yhirano@chromium.org, yoav@yoav.ws

Bug: 855968
Change-Id: I96be3b769dd75300553f639ca5fa8158771bde2c
Reviewed-on: https://chromium-review.googlesource.com/1137930
Commit-Queue: Dominic Farolino <domfarolino@gmail.com>
Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
Reviewed-by: default avatarYoav Weiss <yoav@yoav.ws>
Reviewed-by: default avatarKouhei Ueno <kouhei@chromium.org>
Reviewed-by: default avatarAdam Rice <ricea@chromium.org>
Reviewed-by: default avatarYutaka Hirano <yhirano@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#576204}
parent 02b906a3
...@@ -746,17 +746,22 @@ test(() => { ...@@ -746,17 +746,22 @@ test(() => {
test(() => { test(() => {
// At the time of writing this test, an `any` type is used to represent // This is to test that a TypeError is thrown when RequestInit's signal
// RequestInit's signal member instead of AbortSignal due to a bug in the IDL // member does not implement the AbortSignal interface. We test this because
// compiler; see https://crbug.com/855968. This test ensures that that we // we used to use an `any` IDL type to represent RequestInit's signal member
// treat the `any` member exactly as an AbortSignal member would be treated. // instead of `AbortSignal` due to a bug in the IDL compiler, and performed
// conversions manually. This test ensures that conversion were carried out
// properly.
const e = TypeError(); const e = TypeError();
assert_throws(e, () => { assert_throws(e, () => {
new Request('/', {signal: {}})}, 'signal'); new Request('/', {signal: {}})},
'An empty object as RequestInit\'s signal member should fail type conversion');
assert_throws(e, () => { assert_throws(e, () => {
new Request('/', {signal: new Request('/')})}, 'signal'); new Request('/', {signal: new Request('/')})},
'A Request object as RequestInit\'s signal member should fail type conversion');
assert_throws(e, () => { assert_throws(e, () => {
new Request('/', {signal: new Response('/')})}, 'signal'); new Request('/', {signal: new Response('/')})},
'A Response object as RequestInit\'s signal member should fail type conversion');
}, 'TypeError should be thrown when RequestInit\'s signal member does not implement the AbortSignal interface'); }, 'TypeError should be thrown when RequestInit\'s signal member does not implement the AbortSignal interface');
promise_test(function() { promise_test(function() {
......
...@@ -450,20 +450,8 @@ Request* Request::CreateRequestWithRequestOrString( ...@@ -450,20 +450,8 @@ Request* Request::CreateRequestWithRequestOrString(
} }
// "If |init|'s signal member is present, then set |signal| to it." // "If |init|'s signal member is present, then set |signal| to it."
v8::Local<v8::Value> init_signal = if (init.hasSignal()) {
init.hasSignal() ? init.signal().V8Value() : v8::Local<v8::Value>(); signal = init.signal();
if (!init_signal.IsEmpty()) {
if (init_signal->IsNull()) {
// This allows a null AbortSignal to override |input_request|'s, which
// would otherwise be used.
signal = nullptr;
} else {
signal = NativeValueTraits<AbortSignal>::NativeValue(
script_state->GetIsolate(), init_signal, exception_state);
if (exception_state.HadException()) {
return nullptr;
}
}
} }
// "Let |r| be a new Request object associated with |request| and a new // "Let |r| be a new Request object associated with |request| and a new
......
...@@ -22,9 +22,7 @@ dictionary RequestInit { ...@@ -22,9 +22,7 @@ dictionary RequestInit {
DOMString integrity; DOMString integrity;
boolean keepalive; boolean keepalive;
[RuntimeEnabled=PriorityHints] RequestImportance importance; [RuntimeEnabled=PriorityHints] RequestImportance importance;
// TODO(domfarolino): use AbortSignal? type for signal member once AbortSignal? signal;
// http://crrev.com/c/1113176 is merged.
any signal;
// TODO(domfarolino): add support for RequestInit window member. // TODO(domfarolino): add support for RequestInit window member.
//any window; // can only be set to null //any window; // can only be set to null
}; };
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