Automatic update from web-platform-tests Writing Assistance: Composite instance method abort signals with the create abort signal This composites Writing Assistance instance methods' abort signals with the abort signal used to create the Writing assistance instance. As part of this, the destroy signal is aligned with spec and rejects with AbortError instead of InvalidStateError. This change is based on crrev.com/c/6579550, with additional changes: - Pass abort reason to `RejectOnDestruction()` - Check abort signal before checking `AIMojoClient remote_` Fixed: 415114791 Change-Id: I0932d980a5d2d5b141e79a0e5beb916d2daea2df Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6653359 Commit-Queue: Daseul Lee <dslee@chromium.org> Reviewed-by: Mike Wasserman <msw@chromium.org> Cr-Commit-Position: refs/heads/main@{#1476574} -- wpt-commits: d6ef4cc5400f9bbebef84adee84cdbd6230ea5a9 wpt-pr: 53293
48 lines
1.7 KiB
JavaScript
48 lines
1.7 KiB
JavaScript
// META: title=Summarizer Summarize
|
|
// META: script=/resources/testdriver.js
|
|
// META: script=../resources/util.js
|
|
// META: timeout=long
|
|
|
|
'use strict';
|
|
|
|
promise_test(async (t) => {
|
|
const summarizer = await createSummarizer();
|
|
let result = await summarizer.summarize('');
|
|
assert_equals(result, '');
|
|
result = await summarizer.summarize(' ');
|
|
assert_equals(result, '');
|
|
}, 'Summarizer.summarize() with an empty input returns an empty text');
|
|
|
|
promise_test(async (t) => {
|
|
const summarizer = await createSummarizer();
|
|
const result = await summarizer.summarize(kTestPrompt, {context: ' '});
|
|
assert_not_equals(result, '');
|
|
}, 'Summarizer.summarize() with a whitespace context returns an empty result');
|
|
|
|
promise_test(async t => {
|
|
await testDestroy(t, createSummarizer, {}, [
|
|
summarizer => summarizer.summarize(kTestPrompt),
|
|
summarizer => summarizer.measureInputUsage(kTestPrompt),
|
|
]);
|
|
}, 'Calling Summarizer.destroy() aborts calls to summarize and measureInputUsage.');
|
|
|
|
promise_test(async t => {
|
|
await testCreateAbort(t, createSummarizer, {}, [
|
|
summarizer => summarizer.summarize(kTestPrompt),
|
|
summarizer => summarizer.measureInputUsage(kTestPrompt),
|
|
]);
|
|
}, 'Summarizer.create()\'s abort signal destroys its Summarizer after creation.');
|
|
|
|
promise_test(async () => {
|
|
const summarizer = await createSummarizer();
|
|
const result = await summarizer.summarize(kTestPrompt);
|
|
assert_equals(typeof result, 'string');
|
|
assert_greater_than(result.length, 0);
|
|
}, 'Simple Summarizer.summarize() call');
|
|
|
|
promise_test(async () => {
|
|
const summarizer = await createSummarizer();
|
|
await Promise.all(
|
|
[summarizer.summarize(kTestPrompt), summarizer.summarize(kTestPrompt)]);
|
|
}, 'Multiple Summarizer.summarize() calls are resolved successfully');
|