var t = async_test('Registration: end-to-end');
t.step(function() {
- var scope = '/in-scope/';
+ var scope = 'resources/in-scope/';
var serviceWorkerStates = [];
var lastServiceWorkerState = '';
var receivedMessageFromPort = '';
assert_true(navigator.serviceWorker instanceof ServiceWorkerContainer);
assert_equals(typeof navigator.serviceWorker.register, 'function');
- assert_equals(typeof navigator.serviceWorker.unregister, 'function');
+ assert_equals(typeof navigator.serviceWorker.getRegistration, 'function');
navigator.serviceWorker.oncurrentchange = function() {
++currentChangeCount;
service_worker_unregister_and_register(
t, 'resources/end-to-end-worker.js', scope)
- .then(function(registration) {
- return wait_for_update(t, registration);
- })
.then(onRegister)
.catch(unreached_rejection(t));
return messageChannel.port1;
}
- function onRegister(sw) {
+ function onRegister(registration) {
+ var sw = registration.installing;
serviceWorkerStates.push(sw.state);
lastServiceWorkerState = sw.state;
serviceWorkerStates.push(sw.state);
switch (sw.state) {
- case 'installing':
- assert_equals(lastServiceWorkerState, 'parsed');
- break;
case 'installed':
assert_equals(lastServiceWorkerState, 'installing');
break;
Promise.all([sawMessage, sawActive]).then(t.step_func(function() {
assert_array_equals(serviceWorkerStates,
- ['parsed', 'installing', 'installed', 'activating', 'activated'],
+ ['installing', 'installed', 'activating', 'activated'],
'Service worker should pass through all states');
assert_equals(currentChangeCount, 0,
resolve();
});
}));
- navigator.serviceWorker.unregister(scope);
+ registration.unregister();
sawRedundant.then(t.step_func(function() {
t.done();
}));