From 4020ec6404a416962e6f789b1c232b96700e4dde Mon Sep 17 00:00:00 2001 From: Ben Kelly Date: Tue, 24 May 2016 14:08:20 -0700 Subject: [PATCH] Bug 1273920 P3 Add mochitest that demonstrates we cancel sw install if install event is GC'd. r=asuth --- .../blocking_install_event_worker.js | 17 ++++ dom/workers/test/serviceworkers/mochitest.ini | 2 + .../serviceworkers/test_install_event_gc.html | 86 +++++++++++++++++++ 3 files changed, 105 insertions(+) create mode 100644 dom/workers/test/serviceworkers/blocking_install_event_worker.js create mode 100644 dom/workers/test/serviceworkers/test_install_event_gc.html diff --git a/dom/workers/test/serviceworkers/blocking_install_event_worker.js b/dom/workers/test/serviceworkers/blocking_install_event_worker.js new file mode 100644 index 000000000000..b43a70630781 --- /dev/null +++ b/dom/workers/test/serviceworkers/blocking_install_event_worker.js @@ -0,0 +1,17 @@ +function postMessageToTest(msg) { + return clients.matchAll({ includeUncontrolled: true }) + .then(list => { + for (var client of list) { + if (client.url.endsWith('test_install_event_gc.html')) { + client.postMessage(msg); + break; + } + } + }); +} + +addEventListener('install', evt => { + // This must be a simple promise to trigger the CC failure. + evt.waitUntil(new Promise(function() { })); + postMessageToTest({ type: 'INSTALL_EVENT' }); +}); diff --git a/dom/workers/test/serviceworkers/mochitest.ini b/dom/workers/test/serviceworkers/mochitest.ini index 8410463df1d8..a7eb33ebfc6e 100644 --- a/dom/workers/test/serviceworkers/mochitest.ini +++ b/dom/workers/test/serviceworkers/mochitest.ini @@ -203,6 +203,7 @@ support-files = !/dom/security/test/cors/file_CrossSiteXHR_server.sjs !/dom/tests/mochitest/notification/MockServices.js !/dom/tests/mochitest/notification/NotificationTest.js + blocking_install_event_worker.js [test_bug1151916.html] [test_bug1240436.html] @@ -235,6 +236,7 @@ skip-if = (debug && e10s) # Bug 1262224 [test_importscript_mixedcontent.html] tags = mcb [test_install_event.html] +[test_install_event_gc.html] [test_installation_simple.html] [test_match_all.html] [test_match_all_advanced.html] diff --git a/dom/workers/test/serviceworkers/test_install_event_gc.html b/dom/workers/test/serviceworkers/test_install_event_gc.html new file mode 100644 index 000000000000..c852ec17c5b2 --- /dev/null +++ b/dom/workers/test/serviceworkers/test_install_event_gc.html @@ -0,0 +1,86 @@ + + + + + Test install event being GC'd before waitUntil fulfills + + + + + + + + +