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

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: rebase 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..962f24e6d86cf903dd430c0dd9ae818acbb64876 100644
--- a/LayoutTests/http/tests/serviceworker/chromium/service-worker-gc.html
+++ b/LayoutTests/http/tests/serviceworker/chromium/service-worker-gc.html
@@ -2,7 +2,8 @@
<script src="/js-test-resources/js-test.js"></script>
<script>
window.jsTestIsAsync = true;
-description('Test that a registered Service Worker with an event handler is not garbage collected prematurely');
+description('Test that ServiceWorker and ServiceWorkerRegistration are not garbage collected prematurely');
+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);
@@ -57,8 +66,13 @@ function unregister() {
function finish()
{
+ // The worker is 'redundant' but the registration holds a reference to it,
+ // so it shouldn't be collected yet.
+ // FIXME: When crbug.com/398355 is fixed, register a new script URL and
+ // once the new worker is activated, check that the old worker is gc'd.
gc();
- shouldBeTrue('swObservation.wasCollected');
+ shouldBeFalse('registrationObservation.wasCollected');
+ shouldBeFalse('swObservation.wasCollected');
finishJSTest();
}
</script>

Powered by Google App Engine
This is Rietveld 408576698