serviceworkerregistration-service-worker-image-redirect.html 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <title>Notifications: Showing a notification with an image having a redirect.</title>
  5. <script src="../resources/testharness.js"></script>
  6. <script src="../resources/testharnessreport.js"></script>
  7. <script src="../serviceworker/resources/test-helpers.js"></script>
  8. <script src="resources/test-helpers.js"></script>
  9. </head>
  10. <body>
  11. <script>
  12. // Tests that showing a notification with an image that redirect to another
  13. // location will still resolve the showNotification() promise.
  14. async_test(function(test) {
  15. var scope = 'resources/scope/' + location.pathname,
  16. script = 'instrumentation-service-worker.js';
  17. testRunner.setPermission('notifications', 'granted', location.origin, location.origin);
  18. getActiveServiceWorkerWithMessagePort(test, script, scope).then(function(info) {
  19. // (1) Display a Web Notification through the Service Worker with
  20. // an image that takes redirects to another image.
  21. return sendCommand(info.port, {
  22. command: 'show',
  23. title: 'My Notification',
  24. options: { body: 'Hello, world!',
  25. icon: '/resources/redirect.php?url=square100.png&refresh=0' }
  26. });
  27. }).then(function(data) {
  28. // (2) Confirm that the service worker displayed the notification successfully.
  29. assert_true(data.success);
  30. test.done();
  31. }).catch(unreached_rejection(test));
  32. }, 'Displaying a notification with an image that redirects still resolves the promise.');
  33. </script>
  34. </body>
  35. </html>