Automatic update from web-platform-tests [Prompt API] Update AI creation and detection APIs to use NotSupportedError for unavailable status. This CL ensures that AIWritingAssistanceCreateClient, LanguageModelCreateClient, and LanguageDetector consistently reject with kNotSupportedError (instead of kNotAllowedError or kUnknownError) when the requested feature, model, or language is unavailable. Permission and user activation checks correctly continue to use kNotAllowedError. A new WPT test case is added to verify that LanguageDetector.create() rejects with NotSupportedError for unsupported but syntactically valid language tags. Bug: 487291285 Change-Id: Ifc50597de4f07d9d9f85387d2189249360212383 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7654383 Reviewed-by: Reilly Grant <reillyg@chromium.org> Reviewed-by: Nathan Memmott <memmott@chromium.org> Commit-Queue: Isaac Ahouma <iahouma@google.com> Cr-Commit-Position: refs/heads/main@{#1597935} -- wpt-commits: 53b818a2cf0611ba70eb87afe994990b472b83b9 wpt-pr: 58436
38 lines
1.3 KiB
JavaScript
38 lines
1.3 KiB
JavaScript
// META: title=Summarizer Availability Available
|
|
// META: script=/resources/testdriver.js
|
|
// META: script=../resources/util.js
|
|
// META: timeout=long
|
|
|
|
'use strict';
|
|
|
|
promise_test(async () => {
|
|
const availability = await Summarizer.availability();
|
|
assert_in_array(availability, kAvailableAvailabilities);
|
|
}, 'Summarizer.availability() is available with no options');
|
|
|
|
promise_test(async () => {
|
|
const availability = await Summarizer.availability({
|
|
type: 'tldr',
|
|
format: 'plain-text',
|
|
length: 'medium',
|
|
expectedInputLanguages: ['en-GB'],
|
|
expectedContextLanguages: ['en'],
|
|
outputLanguage: 'en',
|
|
});
|
|
assert_in_array(availability, kAvailableAvailabilities);
|
|
}, 'Summarizer.availability() returns available with supported options');
|
|
|
|
promise_test(async t => {
|
|
const options = {
|
|
type: 'tldr',
|
|
format: 'plain-text',
|
|
length: 'medium',
|
|
expectedInputLanguages: ['zu'], // not supported
|
|
expectedContextLanguages: ['en'],
|
|
outputLanguage: 'zu', // not supported
|
|
};
|
|
const availability = await Summarizer.availability(options);
|
|
assert_equals(availability, 'unavailable');
|
|
await promise_rejects_dom(t, 'NotSupportedError', Summarizer.create(options));
|
|
}, 'Summarizer.availability() returns unavailable for unsupported languages and create() rejects');
|