Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

<!DOCTYPE html>
<title>navigator.install() rejects with TypeError for bad inputs</title>
<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>
// String-form calls (e.g. navigator.install(url)) no longer exist as a
// WebIDL overload. Because install() returns a Promise, overload resolution
// and binding failures reject the returned promise.
promise_test(function(t) {
return promise_rejects_js(t, TypeError,
navigator.install('https://example.com/install.html'),
'The removed one-argument overload should reject with TypeError');
}, 'navigator.install(url) rejects with TypeError.');
promise_test(function(t) {
return promise_rejects_js(t, TypeError,
navigator.install('https://example.com/install.html',
'The removed two-argument overload should reject with TypeError');
}, 'navigator.install(url, manifestId) rejects with TypeError.');
// Dictionary form: navigator.install({manifest, manifestId}).
// Note: unlike the positional form above, {manifestId: null} and
// {manifestId: undefined} are
// treated as "manifestId 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 whitespace-only manifest in dict');
return promise_rejects_js(t, TypeError,
navigator.install({manifest: ' \t\n '}),
'Whitespace-only manifest URL should reject with TypeError');
}, 'navigator.install({manifest: " \\t\\n "}) rejects with TypeError for a ' +
'whitespace-only 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: 'https://['}),
'Invalid manifest URL should reject with TypeError');
}, 'navigator.install({manifest: "https://["}) 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({
manifestId: '',
}),
'Empty id should reject with TypeError');
}, 'navigator.install({manifest, manifestId: ""}) rejects with TypeError for ' +
'empty manifestId.');
promise_test(async function(t) {
await test_driver.bless('install with invalid id in dict');
return promise_rejects_js(t, TypeError,
navigator.install({
manifestId: '://invalid',
}),
'Invalid id should reject with TypeError');
}, 'navigator.install({manifest, manifestId: "://invalid"}) rejects with ' +
'TypeError for invalid manifestId.');
promise_test(function(t) {
return promise_rejects_js(t, TypeError,
navigator.install({
}),
'Missing required manifest member should reject with TypeError');
}, 'navigator.install({installurl}) rejects with TypeError when manifest is ' +
'missing.');
</script>
</body>