1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31

content / test / data / content_index / test.html [blame]

<!DOCTYPE html>
<html>
 <head>
  <title>Content Index API Test</title>
  <script src="../format_error.js"></script>
 </head>
 <body>
  <h1>Content Index Test</h1>
  <script>
    navigator.serviceWorker.register('sw.js');

    async function addContent(id, icons = [], url = '/content_index/test.html') {
      try {
        const registration = await navigator.serviceWorker.ready;
        await registration.index.add({
          id,
          title: 'Title!',
          description: 'Description!',
          category: 'article',
          icons,
          url,
        });
        return 'ok';
      } catch (e) {
        return formatError(e);
      }
    }

   </script>
 </body>
</html>