remove-error.tentative.https.html (2774B)
1 <!DOCTYPE html> 2 <title>Sub Apps: Error cases for remove()</title> 3 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharnessreport.js"></script> 5 <script src="resources/subapps-helpers.js"></script> 6 7 <body></body> 8 9 <script> 10 11 promise_test(async t => { 12 const iframe = document.createElement('iframe'); 13 document.body.appendChild(iframe); 14 15 const iframeNavigator = iframe.contentWindow.navigator; 16 const iframeDOMException = iframe.contentWindow.DOMException; 17 18 // Detach the frame. 19 iframe.remove(); 20 21 // At this point the iframe is detached and unloaded, and its execution 22 // context is gone. 23 await promise_rejects_dom(t, 'NotFoundError', iframeDOMException, iframeNavigator.subApps.remove(['/sub-app-id'])); 24 }, "The object is no longer associated to a document."); 25 26 promise_test(async t => { 27 const iframe = document.createElement('iframe'); 28 document.body.appendChild(iframe); 29 30 const iframeNavigator = iframe.contentWindow.navigator; 31 const iframeDOMException = iframe.contentWindow.DOMException; 32 t.add_cleanup(() => iframe.remove()); 33 34 await promise_rejects_dom(t, 'InvalidStateError', iframeDOMException, iframeNavigator.subApps.remove(['/sub-app-id'])); 35 }, "API is only supported in top-level browsing contexts."); 36 37 promise_test(async t => { 38 const full_url = document.location.origin + '/sub-app-id'; 39 40 await promise_rejects_dom(t, 'NotSupportedError', navigator.subApps.remove([full_url])); 41 }, 'API supports only root-relative paths.'); 42 43 promise_test(async t => { 44 const url_1 = '/sub-app-1'; 45 const url_2 = '/sub-app-2'; 46 const url_3 = '/sub-app-3'; 47 48 let remove_call_params = [url_1, url_2, url_3]; 49 50 let mocked_response = [ 51 { "manifestIdPath": url_1, "resultCode": Status.FAILURE }, 52 { "manifestIdPath": url_2, "resultCode": Status.FAILURE }, 53 { "manifestIdPath": url_3, "resultCode": Status.FAILURE } 54 ]; 55 56 let expected_results = { 57 [url_1]: "failure", 58 [url_2]: "failure", 59 [url_3]: "failure" 60 }; 61 62 await subapps_remove_expect_reject_with_result(t, remove_call_params, mocked_response, expected_results); 63 }, 'Remove call fails.'); 64 65 promise_test(async t => { 66 const url_1 = '/sub-app-1'; 67 const url_2 = '/sub-app-2'; 68 const url_3 = '/sub-app-3'; 69 70 let remove_call_params = [url_1, url_2, url_3]; 71 72 let mocked_response = [ 73 { "manifestIdPath": url_1, "resultCode": Status.SUCCESS }, 74 { "manifestIdPath": url_2, "resultCode": Status.SUCCESS }, 75 { "manifestIdPath": url_3, "resultCode": Status.FAILURE } 76 ]; 77 78 let expected_results = { 79 [url_1]: "success", 80 [url_2]: "success", 81 [url_3]: "failure" 82 }; 83 84 await subapps_remove_expect_reject_with_result(t, remove_call_params, mocked_response, expected_results); 85 }, 'Remove call fails with mixed results.'); 86 87 </script>