Automatic update from web-platform-tests [WebInstallAPI] Add navigator.install manifest url support and plumbing Introduce a new `install()` entry point that accepts an `InstallParams` dictionary, enabling installation of a web app from its manifest URL rather than from a document install URL. Mark the existing `install_url`-based code paths with TODOs for follow-up cleanup once the manifest-based API is fully landed. - Add `InstallParams` IDL dictionary with a required `manifest` member and an optional `id` member, and expose a matching `install(params)` overload on `Navigator`. - Add `ManifestInstallOptions` and `InstallFromManifest()` to the `WebInstallService` Mojo interface; eliminate manifest id from the result for privacy reasons. - Implement `NavigatorWebInstall::InstallFromParamsImpl()` to validate preconditions, require a transient user activation, parse and validate `manifest` and optional `id`, and dispatch the request to the browser. - Stub out `WebInstallServiceImpl::InstallFromManifest()` - Update `HTMLInstallElement` test fake to satisfy the new interface method. Dev doc - https://docs.google.com/document/d/1rGvLhD4SR8Y9M1wVmqgyesPNkbZGU7HOqlttjEFJ5Vo/edit?tab=t.eiywj6swkfs6#bookmark=id.axc7sk5axe17 Bug: 333795265 Change-Id: I404736594f3c07af279b493ddef6dad676e4f396 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7903790 Reviewed-by: Mike West <mkwst@chromium.org> Commit-Queue: Lia Hiscock <liahiscock@microsoft.com> Reviewed-by: Lu Huang <luhua@microsoft.com> Reviewed-by: Daniel Murphy <dmurph@chromium.org> Cr-Commit-Position: refs/heads/main@{#1649184} -- wpt-commits: fb83e524cf722ecfbf87c0ea1af5a79e963f271f wpt-pr: 60719
104 lines
4.5 KiB
HTML
104 lines
4.5 KiB
HTML
<!DOCTYPE html>
|
|
<title>navigator.install() rejects with TypeError for bad inputs</title>
|
|
<link rel="help" href="https://github.com/MicrosoftEdge/MSEdgeExplainers/blob/main/WebInstall/explainer.md">
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
<script src="/resources/testdriver.js"></script>
|
|
<script src="/resources/testdriver-vendor.js"></script>
|
|
<body>
|
|
<script>
|
|
// These tests verify that navigator.install() rejects with TypeError for
|
|
// malformed or invalid inputs. Each test requires a user activation via
|
|
// test_driver.bless() since the activation is consumed by each call.
|
|
|
|
promise_test(async function(t) {
|
|
await test_driver.bless('install with empty url');
|
|
return promise_rejects_js(t, TypeError, navigator.install(''),
|
|
'Empty install_url should reject with TypeError');
|
|
}, 'navigator.install("") rejects with TypeError for empty install URL.');
|
|
|
|
promise_test(async function(t) {
|
|
await test_driver.bless('install with invalid url');
|
|
return promise_rejects_js(t, TypeError, navigator.install('://invalid'),
|
|
'Invalid install_url should reject with TypeError');
|
|
}, 'navigator.install("://invalid") rejects with TypeError for invalid URL.');
|
|
|
|
promise_test(async function(t) {
|
|
await test_driver.bless('install with empty manifest_id');
|
|
return promise_rejects_js(t, TypeError,
|
|
navigator.install('https://example.com', ''),
|
|
'Empty manifest_id should reject with TypeError');
|
|
}, 'navigator.install(url, "") rejects with TypeError for empty manifest ID.');
|
|
|
|
promise_test(async function(t) {
|
|
await test_driver.bless('install with whitespace-only url');
|
|
return promise_rejects_js(t, TypeError, navigator.install(' '),
|
|
'Whitespace-only install_url should reject with TypeError');
|
|
}, 'navigator.install(" ") rejects with TypeError for whitespace-only URL.');
|
|
|
|
promise_test(async function(t) {
|
|
await test_driver.bless('install with null manifest_id');
|
|
return promise_rejects_js(t, TypeError,
|
|
navigator.install('https://example.com', null),
|
|
'Null manifest_id should reject with TypeError');
|
|
}, 'navigator.install(url, null) rejects with TypeError for null manifest ID.');
|
|
|
|
promise_test(async function(t) {
|
|
await test_driver.bless('install with undefined manifest_id');
|
|
var manifest_id;
|
|
return promise_rejects_js(t, TypeError,
|
|
navigator.install('https://example.com', manifest_id),
|
|
'Undefined manifest_id should reject with TypeError');
|
|
}, 'navigator.install(url, undefined) rejects with TypeError for undefined ' +
|
|
'manifest ID.');
|
|
|
|
// Dictionary form: navigator.install({manifest, id}).
|
|
// Note: unlike the positional form above, {id: null} and {id: undefined} are
|
|
// treated as "id omitted" and do NOT reject here.
|
|
|
|
promise_test(async function(t) {
|
|
await test_driver.bless('install with missing required manifest');
|
|
return promise_rejects_js(t, TypeError, navigator.install({}),
|
|
'Missing required manifest member should reject with TypeError');
|
|
}, 'navigator.install({}) rejects with TypeError when manifest is missing.');
|
|
|
|
promise_test(async function(t) {
|
|
await test_driver.bless('install with empty manifest in dict');
|
|
return promise_rejects_js(t, TypeError,
|
|
navigator.install({manifest: ''}),
|
|
'Empty manifest URL should reject with TypeError');
|
|
}, 'navigator.install({manifest: ""}) rejects with TypeError for empty ' +
|
|
'manifest URL.');
|
|
|
|
promise_test(async function(t) {
|
|
await test_driver.bless('install with invalid manifest in dict');
|
|
return promise_rejects_js(t, TypeError,
|
|
navigator.install({manifest: '://invalid'}),
|
|
'Invalid manifest URL should reject with TypeError');
|
|
}, 'navigator.install({manifest: "://invalid"}) rejects with TypeError for ' +
|
|
'invalid manifest URL.');
|
|
|
|
promise_test(async function(t) {
|
|
await test_driver.bless('install with empty id in dict');
|
|
return promise_rejects_js(t, TypeError,
|
|
navigator.install({
|
|
manifest: 'https://example.com/manifest.json',
|
|
id: '',
|
|
}),
|
|
'Empty id should reject with TypeError');
|
|
}, 'navigator.install({manifest, id: ""}) rejects with TypeError for empty ' +
|
|
'id.');
|
|
|
|
promise_test(async function(t) {
|
|
await test_driver.bless('install with invalid id in dict');
|
|
return promise_rejects_js(t, TypeError,
|
|
navigator.install({
|
|
manifest: 'https://example.com/manifest.json',
|
|
id: '://invalid',
|
|
}),
|
|
'Invalid id should reject with TypeError');
|
|
}, 'navigator.install({manifest, id: "://invalid"}) rejects with TypeError ' +
|
|
'for invalid id.');
|
|
</script>
|
|
</body>
|