Files
sousa-gecko/testing/web-platform/tests/ai/semantic_embedder/semantic-embedder-create-user-activation.tentative.https.window.js
T
Ian Zhao 67c7ceccd0 Bug 2044886 [wpt PR 60247] - Implement Blink logic for AISemanticEmbedder, a=testonly
Automatic update from web-platform-tests
Implement Blink logic for AISemanticEmbedder

Fills in the WebIDL implementation logic and adds WPTs, but keeps the Browser process integration stubbed.

Bug: 428233906
Change-Id: Iec6c026c19c575db61fac2afc01bb2252161bb90
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7870476
Reviewed-by: Nathan Memmott <memmott@chromium.org>
Commit-Queue: Ian Zhao <yinguang@google.com>
Reviewed-by: Mike Wasserman <msw@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1647191}

--

wpt-commits: a5c79f370f4fdcee52a08cc4af166dfbbb10357d
wpt-pr: 60247
2026-06-18 14:40:08 +00:00

35 lines
1.4 KiB
JavaScript

// META: title=Embedder Create Requires User Activation
// META: script=/resources/testdriver.js
// META: script=/resources/testdriver-vendor.js
'use strict';
promise_test(async t => {
// 1. Ensure the browser is currently reporting 'downloadable'
const availability = await SemanticEmbedder.availability();
assert_implements_optional(availability === 'downloadable', 'Model should be downloadable');
// 2. Try to create the embedder WITHOUT a user gesture (clicking the page).
// This should be rejected by the browser to prevent drive-by downloads.
await promise_rejects_dom(
t,
'NotAllowedError',
SemanticEmbedder.create()
);
}, 'Create requires sticky user activation when availability is "downloadable"');
promise_test(async t => {
// 1. Ensure the browser is currently reporting 'downloadable'
const availability = await SemanticEmbedder.availability();
assert_implements_optional(availability === 'downloadable', 'Model should be downloadable');
// 2. Simulate a user clicking on the page
await test_driver.bless('activate embedder creation');
// 3. Now that the user has clicked, create() should be allowed to proceed
// (and trigger the download in the background).
const embedder = await SemanticEmbedder.create();
assert_true(!!embedder, 'Embedder should be successfully created');
}, 'Create succeeds with user activation when availability is "downloadable"');