| <!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> |