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

Unified Diff: LayoutTests/http/tests/serviceworker/chromium/service-worker-gc.html

Issue 466723002: ServiceWorker: Enable ServiceWorkerRegistration and update layout tests (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@updatefound
Patch Set: add multiple-register.html and unregister-then-register.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/chromium/service-worker-gc.html
diff --git a/LayoutTests/http/tests/serviceworker/chromium/service-worker-gc.html b/LayoutTests/http/tests/serviceworker/chromium/service-worker-gc.html
index 18e09f603fb74b31cb7594bc4af669a5cb0de62f..3b3def52b9aae798c5d6305ab53821fce2c2c57a 100644
--- a/LayoutTests/http/tests/serviceworker/chromium/service-worker-gc.html
+++ b/LayoutTests/http/tests/serviceworker/chromium/service-worker-gc.html
@@ -3,6 +3,7 @@
<script>
window.jsTestIsAsync = true;
description('Test that a registered Service Worker with an event handler is not garbage collected prematurely');
falken 2014/08/14 13:13:36 replace with 'Test that ServiceWorker and ServiceW
nhiroki 2014/08/14 13:22:08 Done.
+var registrationObservation = null;
var swObservation = null;
var scope = 'gc';
@@ -27,7 +28,14 @@ function unregisterAndRegister(url, scope) {
});
}
-function onRegister(sw) {
+function onRegister(registration) {
+ registrationObservation = internals.observeGC(registration);
+ registration.addEventListener('updatefound', (function() {
+ onUpdate(registration.installing);
+ }));
+}
+
+function onUpdate(sw) {
swObservation = internals.observeGC(sw);
sw.addEventListener('statechange', onStateChange);
}
@@ -48,6 +56,7 @@ function unregister() {
// The worker has an event handler that can still receive the state change
// to 'redundant', so it shouldn't be collected yet.
gc();
+ shouldBeFalse('registrationObservation.wasCollected');
shouldBeFalse('swObservation.wasCollected');
navigator.serviceWorker.unregister(scope).catch(function(error) {
testFailed('Could not unregister worker: ' + error);
@@ -58,7 +67,8 @@ function unregister() {
function finish()
{
falken 2014/08/14 13:13:36 add comment: // The worker is 'redundant' but
nhiroki 2014/08/14 13:22:08 Done.
gc();
- shouldBeTrue('swObservation.wasCollected');
+ shouldBeFalse('registrationObservation.wasCollected');
+ shouldBeFalse('swObservation.wasCollected');
finishJSTest();
}
</script>

Powered by Google App Engine
This is Rietveld 408576698