Automatic update from web-platform-tests Introduces an AIClassifier to the Chrome browser. AIClassifier is a new feature that allows the browser to classify text. This new feature is exposed to Blink via a new Mojo interface. I2P: https://groups.google.com/a/chromium.org/g/blink-dev/c/5dQNl-gyjgU/m/6YBJJIiDAQAJ The change includes the following: Blink Mojom: New AIClassifier interface and associated data structures. Chrome Implementation: AIClassifier class in chrome/browser/ai that uses an OnDeviceSession to interact with the classification model. AIManager Integration: Added CanCreateClassifier and CreateClassifier methods to AIManager to allow Blink to request and create AIClassifier instances. Content Implementation: EchoAIClassifier for testing purposes. Metrics: Added kClassifier to the AISessionType enum. Renderer: Updated classifier.cc to call the new AIManager methods. Bug: 483707607 Change-Id: I04676439afb3feed54237a701365b332910a10f6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7688370 Reviewed-by: Nathan Memmott <memmott@chromium.org> Reviewed-by: Jingyun Liu <jingyun@google.com> Commit-Queue: Devin Cabillo <devincabillo@google.com> Cr-Commit-Position: refs/heads/main@{#1611826} -- wpt-commits: c8f85b5816fc1990da0b3051e58d90578220efa3 wpt-pr: 59058
57 lines
2.4 KiB
JavaScript
57 lines
2.4 KiB
JavaScript
// META: title=Classifier Classify
|
|
// META: script=/resources/testdriver.js
|
|
// META: script=../resources/util.js
|
|
// META: timeout=long
|
|
|
|
'use strict';
|
|
|
|
promise_test(async (t) => {
|
|
const availability = await Classifier.availability();
|
|
assert_implements_optional(availability !== 'unavailable', 'classifier is unavailable');
|
|
const classifier = await createClassifier();
|
|
let result = await classifier.classify('');
|
|
assert_equals(typeof result, 'string');
|
|
result = await classifier.classify(' ');
|
|
assert_equals(typeof result, 'string');
|
|
}, 'Classifier.classify() with an empty input returns a string');
|
|
|
|
promise_test(async (t) => {
|
|
const availability = await Classifier.availability();
|
|
assert_implements_optional(availability !== 'unavailable', 'classifier is unavailable');
|
|
const classifier = await createClassifier();
|
|
const result = await classifier.classify(kTestPrompt, {context: ' '});
|
|
assert_equals(typeof result, 'string');
|
|
}, 'Classifier.classify() with a whitespace context returns a string');
|
|
|
|
promise_test(async t => {
|
|
const availability = await Classifier.availability();
|
|
assert_implements_optional(availability !== 'unavailable', 'classifier is unavailable');
|
|
await testDestroy(t, createClassifier, {}, [
|
|
classifier => classifier.classify(kTestPrompt),
|
|
]);
|
|
}, 'Calling Classifier.destroy() aborts calls to classify.');
|
|
|
|
promise_test(async t => {
|
|
const availability = await Classifier.availability();
|
|
assert_implements_optional(availability !== 'unavailable', 'classifier is unavailable');
|
|
await testCreateAbort(t, createClassifier, {}, [
|
|
classifier => classifier.classify(kTestPrompt),
|
|
]);
|
|
}, 'Classifier.create()\'s abort signal destroys its Classifier after creation.');
|
|
|
|
promise_test(async () => {
|
|
const availability = await Classifier.availability();
|
|
assert_implements_optional(availability !== 'unavailable', 'classifier is unavailable');
|
|
const classifier = await createClassifier();
|
|
const result = await classifier.classify(kTestPrompt);
|
|
assert_equals(typeof result, 'string');
|
|
}, 'Simple Classifier.classify() call');
|
|
|
|
promise_test(async () => {
|
|
const availability = await Classifier.availability();
|
|
assert_implements_optional(availability !== 'unavailable', 'classifier is unavailable');
|
|
const classifier = await createClassifier();
|
|
await Promise.all(
|
|
[classifier.classify(kTestPrompt), classifier.classify(kTestPrompt)]);
|
|
}, 'Multiple Classifier.classify() calls are resolved successfully');
|