Skip to content

Commit

Permalink
Translator: Update error handling
Browse files Browse the repository at this point in the history
Aligns error handling with other AI APIs.

Bug: 322229993
Change-Id: I72bf35b1f1c22ffbea8ae7651212a53729a24b52
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6191611
Reviewed-by: Ming-Ying Chung <[email protected]>
Commit-Queue: Nathan Memmott <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1410419}
  • Loading branch information
Nathan Memmott authored and chromium-wpt-export-bot committed Jan 23, 2025
1 parent 23980ec commit 6310ab7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ai/translator/ai_translator_translate.tentative.https.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,11 @@ promise_test(async t => {
assert_equals(translator.sourceLanguage, 'en');
assert_equals(translator.targetLanguage, 'ja');
}, 'AITranslator: sourceLanguage and targetLanguage are equal to their respective option passed in to AITranslatorFactory.create.')

promise_test(async (t) => {
const translator =
await ai.translator.create({sourceLanguage: 'en', targetLanguage: 'ja'});
translator.destroy();
await promise_rejects_dom(
t, 'InvalidStateError', translator.translate('hello'));
}, 'AITranslator.translate() fails after destroyed');

0 comments on commit 6310ab7

Please sign in to comment.