|
16 | 16 |
|
17 | 17 | const iframeDOMException = iframe.contentWindow.DOMException; |
18 | 18 |
|
19 | | - // Detach the frame. |
| 19 | + const subApps = iframe.contentWindow.subApps; |
20 | 20 | iframe.remove(); |
21 | | - |
22 | | - // At this point the iframe is detached and unloaded, and its execution |
23 | | - // context is gone. |
24 | | - await promise_rejects_dom(t, 'NotFoundError', iframeDOMException, iframe.contentWindow.subApps.add([])); |
| 21 | + await promise_rejects_dom(t, 'OperationError', iframeDOMException, subApps.add([])); |
25 | 22 | }, "The object is no longer associated to a document."); |
26 | 23 |
|
27 | 24 | promise_test(async t => { |
|
31 | 28 | const iframeDOMException = iframe.contentWindow.DOMException; |
32 | 29 | t.add_cleanup(() => iframe.remove()); |
33 | 30 |
|
34 | | - await promise_rejects_dom(t, 'InvalidStateError', iframeDOMException, iframe.contentWindow.subApps.add([])); |
| 31 | + await promise_rejects_dom(t, 'NotSupportedError', iframeDOMException, iframe.contentWindow.subApps.add([])); |
35 | 32 | }, "API is only supported in top-level browsing contexts."); |
36 | 33 |
|
37 | 34 | promise_test(async t => { |
38 | 35 | const cross_origin_url = 'https://example.com/sub-app'; |
39 | 36 |
|
40 | 37 | let add_call_params = [cross_origin_url]; |
41 | 38 |
|
| 39 | + t.add_cleanup(async () => { |
| 40 | + await mockSubAppsService.reset(); |
| 41 | + mockSubAppsService = null; |
| 42 | + }); |
| 43 | + |
| 44 | + await createMockSubAppsService(Status.SUCCESS, [], [], []); |
42 | 45 | await test_driver.bless("installing subapps", async function () { |
43 | | - await promise_rejects_dom(t, 'NotSupportedError', window.subApps.add(add_call_params)); |
| 46 | + await promise_rejects_js(t, TypeError, window.subApps.add(add_call_params)); |
44 | 47 | }); |
45 | 48 | }, 'API supports only same-origin URLs.'); |
46 | 49 |
|
|
50 | 53 |
|
51 | 54 | let add_call_params = [url_1, url_2]; |
52 | 55 |
|
53 | | - let mocked_response = [ |
54 | | - { "installUrlPath": url_1, "manifestIdPath": url_1, "resultType": SubAppsServiceAddResultType.kOperationError }, |
55 | | - { "installUrlPath": url_2, "manifestIdPath": url_2, "resultType": SubAppsServiceAddResultType.kOperationError } |
| 56 | + let mocked_response = () => [ |
| 57 | + { "installPath": url_1, "manifestId": url_1, "resultType": SubAppsServiceAddResultType.kGenericError }, |
| 58 | + { "installPath": url_2, "manifestId": url_2, "resultType": SubAppsServiceAddResultType.kGenericError } |
56 | 59 | ]; |
57 | 60 |
|
58 | | - let expected_results = { |
| 61 | + let expected_results = () => ({ |
59 | 62 | failedApps: { |
60 | 63 | [url_1]: "OperationError", |
61 | 64 | [url_2]: "OperationError" |
62 | 65 | } |
63 | | - }; |
| 66 | + }); |
64 | 67 |
|
65 | 68 | await test_driver.bless("installing a subapp", async function () { |
66 | 69 | await subapps_add_expect_success_with_result(t, add_call_params, mocked_response, expected_results); |
|
73 | 76 |
|
74 | 77 | let add_call_params = [url_1, url_2]; |
75 | 78 |
|
76 | | - let mocked_response = [ |
77 | | - { "installUrlPath": url_1, "manifestIdPath": url_1, "resultType": SubAppsServiceAddResultType.kSuccess }, |
78 | | - { "installUrlPath": url_2, "manifestIdPath": url_2, "resultType": SubAppsServiceAddResultType.kOperationError } |
| 79 | + let mocked_response = () => [ |
| 80 | + { "installPath": url_1, "manifestId": url_1, "resultType": SubAppsServiceAddResultType.kSuccess }, |
| 81 | + { "installPath": url_2, "manifestId": url_2, "resultType": SubAppsServiceAddResultType.kGenericError } |
79 | 82 | ]; |
80 | 83 |
|
81 | | - let expected_results = { |
| 84 | + let expected_results = () => ({ |
82 | 85 | installedApps: { |
83 | 86 | [url_1]: url_1 |
84 | 87 | }, |
85 | 88 | failedApps: { |
86 | 89 | [url_2]: "OperationError" |
87 | 90 | } |
88 | | - }; |
| 91 | + }); |
89 | 92 |
|
90 | 93 | await test_driver.bless("installing a subapp", async function () { |
91 | 94 | await subapps_add_expect_success_with_result(t, add_call_params, mocked_response, expected_results); |
|
102 | 105 | mockSubAppsService = null; |
103 | 106 | }); |
104 | 107 |
|
105 | | - // 2 corresponds to SubAppsServiceResultCode.kUserDenied |
106 | | - await createMockSubAppsService(2, [], [], []); |
| 108 | + await createMockSubAppsService(Status.USER_DECLINED, [], [], []); |
107 | 109 | await test_driver.bless("installing a subapp", async function () { |
108 | 110 | await window.subApps.add(add_call_params).then( |
109 | 111 | result => { |
|
0 commit comments