commit 73496b2bb5ef26b158575cf3743f3573e1d0d015
parent 46bd54732b5e349f0dc7fe84d3b4d2d84cad98db
Author: Isaac Ahouma <iahouma@google.com>
Date: Fri, 7 Nov 2025 09:02:15 +0000
Bug 1998590 [wpt PR 55893] - [Built-In AI] Add WPTs for LanguageModel user activation, a=testonly
Automatic update from web-platform-tests
[Built-In AI] Add WPTs for LanguageModel user activation
Adds web platform tests for LanguageModel.create() to cover various user
activation scenarios:
- No user activation.
- Immediate transient activation.
- Sticky activation after transient expiry.
We add two separate virtual test suites one for sticky activation and
one for transient activation.
Bug: 454435239
Test: Ran the added tests to verify they work as expected.
Change-Id: I1a81db9f00fcc8cfe5818e21a0fdc5c8b152fea4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7102682
Reviewed-by: Mike Wasserman <msw@chromium.org>
Reviewed-by: Kent Tamura <tkent@chromium.org>
Commit-Queue: Isaac Ahouma <iahouma@google.com>
Cr-Commit-Position: refs/heads/main@{#1540933}
--
wpt-commits: ce0009794061fc69b4e8127abb9f4f6c21cf10b0
wpt-pr: 55893
Diffstat:
2 files changed, 62 insertions(+), 0 deletions(-)
diff --git a/testing/web-platform/tests/ai/language-model/language-model-create-sticky-user-activation.tentative.https.window.js b/testing/web-platform/tests/ai/language-model/language-model-create-sticky-user-activation.tentative.https.window.js
@@ -0,0 +1,31 @@
+// META: title=LanguageModel.create() User Activation Tests
+// META: script=/resources/testdriver.js
+// META: script=/resources/testdriver-vendor.js
+// META: script=../resources/util.js
+// META: timeout=long
+
+'use strict';
+
+promise_test(async t => {
+ assert_implements_optional(
+ await LanguageModel.availability() == 'downloadable');
+ assert_false(navigator.userActivation.isActive);
+ return promise_rejects_dom(t, 'NotAllowedError', LanguageModel.create());
+}, 'Create fails without user activation when availability is "downloadable"');
+
+promise_test(async t => {
+ assert_implements_optional(
+ await LanguageModel.availability() == 'downloadable',
+ 'This test only runs if model is downloadable');
+
+ await test_driver.bless('Enable LanguageModel create()');
+
+ // Consume transient activation.
+ const win = window.open('about:blank', '_blank');
+ if (win)
+ win.close();
+ assert_true(navigator.userActivation.hasBeenActive);
+ assert_false(navigator.userActivation.isActive);
+
+ return LanguageModel.create();
+}, 'Create succeeds with sticky activation when availability is "downloadable"');
diff --git a/testing/web-platform/tests/ai/language-model/language-model-create-transient-user-activation.tentative.https.window.js b/testing/web-platform/tests/ai/language-model/language-model-create-transient-user-activation.tentative.https.window.js
@@ -0,0 +1,31 @@
+// META: title=LanguageModel.create() User Activation Tests
+// META: script=/resources/testdriver.js
+// META: script=/resources/testdriver-vendor.js
+// META: script=../resources/util.js
+// META: timeout=long
+
+'use strict';
+
+promise_test(async t => {
+ assert_implements_optional(
+ await LanguageModel.availability() == 'downloadable');
+ assert_false(navigator.userActivation.isActive);
+ return promise_rejects_dom(
+ t, 'NotAllowedError', LanguageModel.create(),
+ 'LanguageModel.create() should fail without any user activation.');
+}, 'Create fails without user activation');
+
+promise_test(async t => {
+ assert_implements_optional(
+ await LanguageModel.availability() == 'downloadable');
+
+ await test_driver.bless('Enable LanguageModel create()');
+
+ // Consume transient activation.
+ const win = window.open('about:blank', '_blank');
+ win.close();
+ assert_true(navigator.userActivation.hasBeenActive);
+ assert_false(navigator.userActivation.isActive);
+
+ return promise_rejects_dom(t, 'NotAllowedError', LanguageModel.create());
+}, 'Create fails with sticky activation when availability is "downloadable"');