Files
sousa-gecko/testing/web-platform/tests/ai/summarizer/summarizer-availability-available.tentative.https.window.js
T
Isaac Ahouma c3a5fa4609 Bug 2022740 [wpt PR 58436] - [Prompt API] Update AI creation and detection APIs to use NotSupportedError for unavailable status., a=testonly
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
2026-03-16 10:12:41 +00:00

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');