Automatic update from web-platform-tests Add Spanish and Japanese support; Add canonicalization & validation. 1. Enables Spanish and Japanese as a supported language in the browser process for Prompt and Summarizer APIs. 2. Adds Feature Params for kAISummarizationAPI and kAIPromptAPI to control enabled languages. 2. Adds validation and canonicalization of language tags for expectedInputs and expectedOutputs in LanguageModel availability() and create(). Adds web platform tests to test the behavior. Bug: 422210273, 422211699 Change-Id: I35d152e05119382ce156c715c72d297de59c210d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6628446 Reviewed-by: Mike Wasserman <msw@chromium.org> Commit-Queue: Brad Triebwasser <btriebw@chromium.org> Cr-Commit-Position: refs/heads/main@{#1485302} -- wpt-commits: 833f4bddb3373f9bc236ed7f3637b91a30933eae wpt-pr: 53706
39 lines
1.5 KiB
JavaScript
39 lines
1.5 KiB
JavaScript
// META: title=Summarizer Availability
|
|
// META: script=/resources/testdriver.js
|
|
// META: script=../resources/util.js
|
|
// META: timeout=long
|
|
|
|
'use strict';
|
|
|
|
promise_test(async () => {
|
|
assert_true(!!Summarizer);
|
|
assert_equals(typeof Summarizer.availability, 'function');
|
|
}, 'Summarizer.availability() is defined');
|
|
|
|
promise_test(async () => {
|
|
const availability = await Summarizer.availability();
|
|
assert_in_array(availability, kValidAvailabilities);
|
|
}, 'Summarizer.availability() returns a valid value with no options');
|
|
|
|
promise_test(async () => {
|
|
// An array of plausible test option values.
|
|
const kCreateOptionsSpec = [
|
|
{type: [undefined, 'tldr', 'teaser', 'key-points', 'headline']},
|
|
{format: [undefined, 'plain-text', 'markdown']},
|
|
{length: [undefined, 'short', 'medium', 'long']},
|
|
{expectedInputLanguages: [[], ['en'], ['es'], ['jp', 'fr']]},
|
|
{expectedContextLanguages: [[], ['en'], ['es'], ['jp', 'fr']]},
|
|
{outputLanguage: [undefined, 'en', 'es', 'jp', 'fr']}
|
|
];
|
|
for (const options of generateOptionCombinations(kCreateOptionsSpec)) {
|
|
const availability = await Summarizer.availability(options);
|
|
assert_in_array(availability, kValidAvailabilities, options);
|
|
}
|
|
}, 'Summarizer.availability() returns a valid value with plausible options');
|
|
|
|
promise_test(async (t) => {
|
|
return promise_rejects_js(t, RangeError, Summarizer.availability({
|
|
expectedInputLanguages: ['en-abc-invalid'], // not supported
|
|
}));
|
|
}, 'Summarizer.availability() rejects when given invalid language tags');
|