Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(203)

Unified Diff: LayoutTests/http/tests/serviceworker/install-phase-event-waituntil.html

Issue 466723002: ServiceWorker: Enable ServiceWorkerRegistration and update layout tests (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@updatefound
Patch Set: update comments in service-worker-gc.html Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: LayoutTests/http/tests/serviceworker/install-phase-event-waituntil.html
diff --git a/LayoutTests/http/tests/serviceworker/install-phase-event-waituntil.html b/LayoutTests/http/tests/serviceworker/install-phase-event-waituntil.html
index a7cfc252446e1fd48f1e14ee9c208e13da50358f..72c93d22f8f322d09b44d596531efeac46fa4adf 100644
--- a/LayoutTests/http/tests/serviceworker/install-phase-event-waituntil.html
+++ b/LayoutTests/http/tests/serviceworker/install-phase-event-waituntil.html
@@ -5,112 +5,115 @@
<script src="resources/test-helpers.js"></script>
<script>
function runTest(test, scope, onRegister) {
- var script = 'resources/install-phase-event-waituntil.js';
- test.step(function() {
- service_worker_unregister_and_register(
- test, script, scope
- ).then(
- test.step_func(onRegister)
- );
+ var script = 'resources/install-phase-event-waituntil.js';
+ test.step(function() {
+ service_worker_unregister_and_register(test, script, scope)
+ .then(function(registration) {
falken 2014/08/14 14:23:14 the .then chain should be indented an additional 2
nhiroki 2014/08/14 16:37:53 Done.
+ return wait_for_update(test, registration);
+ })
+ .then(test.step_func(onRegister));
});
}
function syncWorker(test, worker, obj) {
- var channel = new MessageChannel();
- channel.port1.onmessage = test.step_func(function(e) {
- var message = e.data;
- assert_equals(message, 'SYNC', 'Should receive sync message from worker.');
- obj.synced = true;
- channel.port1.postMessage('ACK');
+ var channel = new MessageChannel();
+ channel.port1.onmessage = test.step_func(function(e) {
+ var message = e.data;
+ assert_equals(message, 'SYNC',
+ 'Should receive sync message from worker.');
+ obj.synced = true;
+ channel.port1.postMessage('ACK');
});
- worker.postMessage({port: channel.port2}, [channel.port2]);
+ worker.postMessage({port: channel.port2}, [channel.port2]);
}
async_test(function(t) {
// Passing scope as the test switch for worker script.
var scope = 'install-fulfilled';
var onRegister = function(worker) {
- var obj = {};
- worker.onstatechange = t.step_func(function() {
- if (worker.state == 'installing') {
- syncWorker(t, worker, obj);
- } else if (worker.state == 'installed') {
- assert_true(obj.synced,
- 'state should be "installed" after the waitUntil promise for "oninstall" is fulfilled.');
- service_worker_unregister_and_done(t, scope);
- }
+ var obj = {};
+ worker.onstatechange = t.step_func(function() {
+ if (worker.state == 'installing') {
+ syncWorker(t, worker, obj);
+ } else if (worker.state == 'installed') {
+ assert_true(
+ obj.synced,
falken 2014/08/14 14:23:14 additional 2 spaces (and throughout this file)
nhiroki 2014/08/14 16:37:53 Done.
+ 'state should be "installed" after the waitUntil promise for "oninstall" is fulfilled.');
+ service_worker_unregister_and_done(t, scope);
+ }
});
};
runTest(t, scope, onRegister);
-}, 'Test install event waitUntil fulfilled');
+ }, 'Test install event waitUntil fulfilled');
async_test(function(t) {
var scope = 'activate-fulfilled';
var onRegister = function(worker) {
- var obj = {};
- worker.onstatechange = t.step_func(function() {
- if (worker.state == 'activating') {
- syncWorker(t, worker, obj);
- } else if (worker.state == 'activated') {
- assert_true(obj.synced,
- 'state should be "activated" after the waitUntil promise for "onactivate" is fulfilled.');
- service_worker_unregister_and_done(t, scope);
- }
+ var obj = {};
+ worker.onstatechange = t.step_func(function() {
+ if (worker.state == 'activating') {
+ syncWorker(t, worker, obj);
+ } else if (worker.state == 'activated') {
+ assert_true(
+ obj.synced,
+ 'state should be "activated" after the waitUntil promise for "onactivate" is fulfilled.');
+ service_worker_unregister_and_done(t, scope);
+ }
});
};
runTest(t, scope, onRegister);
-}, 'Test activate event waitUntil fulfilled');
+ }, 'Test activate event waitUntil fulfilled');
async_test(function(t) {
var scope = 'install-rejected';
var onRegister = function(worker) {
- worker.onstatechange = t.step_func(function() {
- console.log(worker.state);
- if (worker.state == 'redundant')
- service_worker_unregister_and_done(t, scope);
+ worker.onstatechange = t.step_func(function() {
+ if (worker.state == 'redundant')
+ service_worker_unregister_and_done(t, scope);
});
};
runTest(t, scope, onRegister);
-}, 'Test install event waitUntil rejected');
+ }, 'Test install event waitUntil rejected');
async_test(function(t) {
var scope = 'activate-rejected';
var onRegister = function(worker) {
worker.onstatechange = t.step_func(function() {
if (worker.state == 'redundant')
- service_worker_unregister_and_done(t, scope);
- });
- };
+ service_worker_unregister_and_done(t, scope);
+ });
+ };
runTest(t, scope, onRegister);
-}, 'Test activate event waitUntil rejected.');
+ }, 'Test activate event waitUntil rejected.');
async_test(function(t) {
var scope = 'activate-multiple-fulfilled';
var onRegister = function(worker) {
- var obj1 = {};
- var obj2 = {};
- worker.onstatechange = t.step_func(function() {
- if (worker.state == 'activating') {
- syncWorker(t, worker, obj1);
- syncWorker(t, worker, obj2);
- } else if (worker.state == 'activated') {
- assert_true(obj1.synced && obj2.synced,
- 'state should be "activated" after all waitUnitl promises for "onactivate" are fulfilled.');
- service_worker_unregister_and_done(t, scope);
- }
+ var obj1 = {};
+ var obj2 = {};
+ worker.onstatechange = t.step_func(function() {
+ if (worker.state == 'activating') {
+ syncWorker(t, worker, obj1);
+ syncWorker(t, worker, obj2);
+ } else if (worker.state == 'activated') {
+ assert_true(
+ obj1.synced && obj2.synced,
+ 'state should be "activated" after all waitUnitl promises for "onactivate" are fulfilled.');
+ service_worker_unregister_and_done(t, scope);
+ }
});
};
runTest(t, scope, onRegister);
-}, 'Test InstallPhaseEvent multiple waitUntil fulfilled.');
+ }, 'Test InstallPhaseEvent multiple waitUntil fulfilled.');
async_test(function(t) {
var scope = 'activate-reject-precedence';
var onRegister = function(worker) {
- worker.onstatechange = t.step_func(function() {
- if (worker.state == 'redundant')
- service_worker_unregister_and_done(t, scope);
- });
+ worker.onstatechange = t.step_func(function() {
+ if (worker.state == 'redundant')
+ service_worker_unregister_and_done(t, scope);
+ });
};
runTest(t, scope, onRegister);
-}, 'Test InstallPhaseEvent waitUntil reject precedence.');
+ }, 'Test InstallPhaseEvent waitUntil reject precedence.');
</script>

Powered by Google App Engine
This is Rietveld 408576698