зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1425975 P11 Fix test_workerupdatefound.html not to frame loading against SW activation and updatefound events. r=asuth
This commit is contained in:
Родитель
171584cc47
Коммит
a03dd3c968
|
@ -13,14 +13,15 @@
|
|||
<p id="display"></p>
|
||||
<div id="content"></div>
|
||||
<pre id="test"></pre>
|
||||
<script src="utils.js"></script>
|
||||
<script class="testbody" type="text/javascript">
|
||||
var registration;
|
||||
var promise;
|
||||
|
||||
function start() {
|
||||
return navigator.serviceWorker.register("worker_updatefoundevent.js",
|
||||
{ scope: "./updatefoundevent.html" })
|
||||
.then((swr) => registration = swr);
|
||||
async function start() {
|
||||
registration = await navigator.serviceWorker.register("worker_updatefoundevent.js",
|
||||
{ scope: "./updatefoundevent.html" })
|
||||
await waitForState(registration.installing, 'activated');
|
||||
}
|
||||
|
||||
function startWaitForUpdateFound() {
|
||||
|
|
|
@ -3,21 +3,16 @@
|
|||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
onactivate = function(e) {
|
||||
e.waitUntil(new Promise(function(resolve, reject) {
|
||||
registration.onupdatefound = function(e) {
|
||||
clients.matchAll().then(function(clients) {
|
||||
if (!clients.length) {
|
||||
reject("No clients found");
|
||||
}
|
||||
|
||||
if (registration.scope.match(/updatefoundevent\.html$/)) {
|
||||
clients[0].postMessage("finish");
|
||||
resolve();
|
||||
} else {
|
||||
dump("Scope did not match");
|
||||
}
|
||||
}, reject);
|
||||
registration.onupdatefound = function(e) {
|
||||
clients.matchAll().then(function(clients) {
|
||||
if (!clients.length) {
|
||||
reject("No clients found");
|
||||
}
|
||||
}));
|
||||
|
||||
if (registration.scope.match(/updatefoundevent\.html$/)) {
|
||||
clients[0].postMessage("finish");
|
||||
} else {
|
||||
dump("Scope did not match");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче