tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 5aa26229078832788c56b5e8648274d1a33db1db
parent 021a53dfb4ebe5e3a209abf5b8373dfd9d86ff5e
Author: Mike Wasserman <msw@chromium.org>
Date:   Wed, 15 Oct 2025 08:24:20 +0000

Bug 1993643 [wpt PR 55342] - Built-In AI APIs: Fix Translator and Language Detector tests, a=testonly

Automatic update from web-platform-tests
Built-In AI APIs: Fix Translator and Language Detector tests

These tests presume API availability is initially 'downloadable'.
Formalize that expectation with assert_implements_optional.
Align test structure with Summarizer, etc.

Fixed: 443908031, 443911549
Test: Chromium CI still WAI, wpt.live now surfaces failing precondition when used with a user-data-dir that previously downloaded API models and configs, yielding a different initial availability.
Change-Id: I5884f02a8613df6fa20f091354cadfdceac6a7c6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7024029
Commit-Queue: Mike Wasserman <msw@chromium.org>
Reviewed-by: Nathan Memmott <memmott@chromium.org>
Auto-Submit: Mike Wasserman <msw@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1527826}

--

wpt-commits: 3017421811a4fd4bb668ec25891647ec0e0f0ef0
wpt-pr: 55342

Diffstat:
Mtesting/web-platform/tests/ai/language_detection/detector.https.window.js | 25+++++++++++--------------
Mtesting/web-platform/tests/ai/translator/translator.optional.https.window.js | 26+++++++++++---------------
2 files changed, 22 insertions(+), 29 deletions(-)

diff --git a/testing/web-platform/tests/ai/language_detection/detector.https.window.js b/testing/web-platform/tests/ai/language_detection/detector.https.window.js @@ -8,22 +8,19 @@ 'use strict'; +// TODO(crbug.com/390246212): Support model state controls for WPTs. promise_test(async t => { - // Creating the language detector without user activation rejects with - // NotAllowedError. - const createPromise = LanguageDetector.create(); - await promise_rejects_dom(t, 'NotAllowedError', createPromise); - - // Creating the translator with user activation succeeds. - await createLanguageDetector(); - - // Creating it should have switched it to available. - const availability = await LanguageDetector.availability(); - assert_equals(availability, 'available'); - - // Now that it is available, we should no longer need user activation. + // Create requires user activation when availability is 'downloadable'. + assert_implements_optional(await LanguageDetector.availability() == 'downloadable'); + assert_false(navigator.userActivation.isActive); + await promise_rejects_dom(t, 'NotAllowedError', LanguageDetector.create()); + await test_driver.bless('LanguageDetector.create', LanguageDetector.create); + + // Create does not require user activation when availability is 'available'. + assert_equals(await LanguageDetector.availability(), 'available'); + assert_false(navigator.userActivation.isActive); await LanguageDetector.create(); -}, 'LanguageDetector.create() requires user activation when availability is "downloadable.'); +}, 'Create requires user activation when availability is "downloadable"'); promise_test(async t => { const detector = await createLanguageDetector(); diff --git a/testing/web-platform/tests/ai/translator/translator.optional.https.window.js b/testing/web-platform/tests/ai/translator/translator.optional.https.window.js @@ -10,24 +10,20 @@ 'use strict'; +// TODO(crbug.com/390246212): Support model state controls for WPTs. promise_test(async t => { + // Create requires user activation when availability is 'downloadable'. const languagePair = {sourceLanguage: 'en', targetLanguage: 'ja'}; - - // Creating the translator without user activation rejects with - // NotAllowedError. - const createPromise = Translator.create(languagePair); - await promise_rejects_dom(t, 'NotAllowedError', createPromise); - - // Creating the translator with user activation succeeds. - await createTranslator(languagePair); - - // Creating it should have switched it to available. - const availability = await Translator.availability(languagePair); - assert_equals(availability, 'available'); - - // Now that it is available, we should no longer need user activation. + assert_implements_optional(await Translator.availability(languagePair) == 'downloadable'); + assert_false(navigator.userActivation.isActive); + await promise_rejects_dom(t, 'NotAllowedError', Translator.create(languagePair)); + await test_driver.bless('Translator.create', async () => { await Translator.create(languagePair); }); + + // Create does not require user activation when availability is 'available'. + assert_equals(await Translator.availability(languagePair), 'available'); + assert_false(navigator.userActivation.isActive); await Translator.create(languagePair); -}, 'Translator.create() requires user activation when availability is "downloadable.'); +}, 'Create requires user activation when availability is "downloadable"'); promise_test(async t => { const translator =