Skip to content

Commit

Permalink
Bug 1865927 [wpt PR 43295] - DOM: Introduce SubscribeOptions for Obse…
Browse files Browse the repository at this point in the history
…rvable API, a=testonly

Automatic update from web-platform-tests
DOM: Introduce SubscribeOptions for Observable API

This PR separates the AbortSignal from the callbacks passed into
`subscribe()` via the `Observer` dictionary, into its own dictionary,
where future options may live. This is a particularly useful ergonomic
change for chaining Observables together.

See WICG/observable#85 and
WICG/observable#71 for any relevant design
discussion.

R=masonfchromium.org

Bug: 1485981
Change-Id: I9b9f9cf26cb8b7a71d2aab7811ad681386cbfd5a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5046377
Commit-Queue: Dominic Farolino <domchromium.org>
Reviewed-by: Mason Freed <masonfchromium.org>
Cr-Commit-Position: refs/heads/main{#1227666}

--

wpt-commits: dbd13167a668830be3817fa612b2f00299d3cd76
wpt-pr: 43295

UltraBlame original commit: 2bc91571ae99012866b0f18f48e4df9a89dc75cf
  • Loading branch information
marco-c committed Nov 30, 2023
1 parent 3e247be commit 7b011fb
Showing 1 changed file with 9 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ test(t => {
initialSignalAborted = subscriber.signal.aborted;
});

source.subscribe({signal: AbortSignal.abort('Initially aborted')});
source.subscribe({}, {signal: AbortSignal.abort('Initially aborted')});
assert_false(initialActivity);
assert_true(initialSignalAborted);
assert_equals(innerSubscriber.signal.reason, 'Initially aborted');
Expand All @@ -198,7 +198,7 @@ test(() => {
const source = new Observable(subscriber => outerSubscriber = subscriber);

const controller = new AbortController();
source.subscribe({signal: controller.signal});
source.subscribe({}, {signal: controller.signal});

assert_not_equals(controller.signal, outerSubscriber.signal);
}, "Subscriber#signal is not the same AbortSignal as the one passed into `subscribe()`");
Expand Down Expand Up @@ -555,9 +555,8 @@ test(() => {
source.subscribe({

next: (x) => results.push(x),
complete: () => results.push('complete()'),
signal: ac.signal,
});
complete: () => results.push('complete()')
}, {signal: ac.signal});

ac.signal.addEventListener('abort', () => {
results.push('outer abort handler');
Expand Down Expand Up @@ -596,9 +595,8 @@ test(t => {
}
},
error: () => results.push('error'),
complete: () => results.push('complete'),
signal: ac.signal,
});
complete: () => results.push('complete')
}, {signal: ac.signal});

assert_array_equals(
results,
Expand Down Expand Up @@ -665,9 +663,7 @@ test(() => {
});

const ac = new AbortController();
source.subscribe({
signal: ac.signal,
});
source.subscribe({}, {signal: ac.signal});

assert_false(addTeardownCalled, "Teardown is not be called upon subscription");
ac.abort();
Expand Down Expand Up @@ -809,9 +805,8 @@ test(() => {
source.subscribe({
next: (x) => results.push(x),
error: (error) => results.push(error),
complete: () => results.push('complete'),
signal: ac.signal,
});
complete: () => results.push('complete')
}, {signal: ac.signal});

assert_array_equals(results, []);
assert_true(firstTeardownInvokedSynchronously, "First teardown callback is invoked during addTeardown()");
Expand Down

0 comments on commit 7b011fb

Please sign in to comment.