tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

list-success.tentative.https.html (1684B)


      1 <!DOCTYPE html>
      2 <title>Sub Apps: Valid calls for list()</title>
      3 <script src="/resources/testharness.js"></script>
      4 <script src="/resources/testharnessreport.js"></script>
      5 <script src="resources/subapps-helpers.js"></script>
      6 <script>
      7 
      8 promise_test(async t => {
      9  t.add_cleanup(async () => {
     10    await mockSubAppsService.reset();
     11    mockSubAppsService = null;
     12  });
     13 
     14  const url_1 = '/sub-app-1';
     15  const url_2 = '/sub-app-2';
     16 
     17  const mocked_response = [
     18    { "manifestIdPath": url_1, "appName": "App 1" },
     19    { "manifestIdPath": url_2, "appName": "App 2" },
     20  ];
     21 
     22  let expected_results = {
     23    [url_1]: { "app_name": "App 1" },
     24    [url_2]: { "app_name": "App 2" },
     25  };
     26 
     27  await createMockSubAppsService(Status.SUCCESS, [], mocked_response);
     28 
     29  await navigator.subApps.list()
     30    .catch(e => {
     31      assert_unreached("Should not have rejected.");
     32    })
     33    .then(result => {
     34      for (const app_id in expected_results) {
     35        assert_own_property(result, app_id, "Return results are missing entry for subapp.")
     36        assert_equals(JSON.stringify(result[app_id]), JSON.stringify(expected_results[app_id]), "Return results are not as expected.")
     37      }
     38    })
     39 }, 'List API call works with 2 sub apps.');
     40 
     41 promise_test(async t => {
     42  t.add_cleanup(async () => {
     43    await mockSubAppsService.reset();
     44    mockSubAppsService = null;
     45  });
     46 
     47  let mocked_response = [];
     48  await createMockSubAppsService(Status.SUCCESS, [], mocked_response);
     49  await navigator.subApps.list()
     50  .catch(e => {
     51      assert_unreached("Should not have rejected.");
     52    })
     53  .then(result => {
     54    assert_equals(Object.keys(result).length, 0);
     55  })
     56 }, 'List API call works with no sub apps.');
     57 
     58 </script>