OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE html> | |
2 <script src="../resources/testharness.js"></script> | |
dominicc (has gone to gerrit)
2014/06/12 22:23:38
This should use the Blink test harness. GC is an i
falken
2014/06/13 19:22:59
Done.
| |
3 <script src="../resources/testharnessreport.js"></script> | |
4 <script src="resources/test-helpers.js"></script> | |
5 <script src="resources/gc.js"></script> | |
6 <body> | |
7 <script> | |
8 (function() { | |
9 var t = async_test('A registered Service Worker with an event handler is not garbage collected'); | |
dominicc (has gone to gerrit)
2014/06/12 22:23:38
FYI I have started doing
async_test(function(t) {
| |
10 var worker = 'resources/empty-worker.js' | |
11 var scope = 'gc'; | |
12 var swObservation = null; | |
13 service_worker_unregister_and_register(t, worker, scope, onRegister); | |
14 | |
15 function collectGarbage(shouldBeCollected, description) { | |
16 gc(); | |
17 if (swObservation) | |
18 assert_equals(swObservation.wasCollected, shouldBeCollected, descrip tion); | |
19 } | |
20 | |
21 function onUnregister() { | |
22 // FIXME: The expectation should be reversed, but our implementation cur rently fails it. | |
dominicc (has gone to gerrit)
2014/06/12 22:23:38
I think you want to rephrase this as a "leak test"
falken
2014/06/13 19:22:59
OK, the idea being that the test would succeed on
| |
23 // When properly implemented, the SW should be garbage collected here. | |
24 t.step(collectGarbage.bind(undefined, false, 'Service Worker should be g c\'d after unregistration')); | |
25 t.done(); | |
26 } | |
27 | |
28 function onRegister(sw) { | |
dominicc (has gone to gerrit)
2014/06/12 22:23:38
FYI I am moving to using promises instead of callb
falken
2014/06/13 19:22:59
Done. Yes, I think that's a good idea. Our test-he
| |
29 sw.addEventListener('statechange', t.step_func(onStateChange)); | |
30 if (window.internals) | |
31 swObservation = internals.observeGC(sw); | |
32 setTimeout(t.step_func(collectGarbage.bind(undefined, false, 'Service Wo rker should not be gc\'d after registration')), 0); | |
33 } | |
34 | |
35 function onStateChange(event) { | |
36 t.step(collectGarbage.bind(undefined, false, 'Service Worker should not be gc\'d inside onStateChange handler')); | |
37 if (event.target.state != 'active') | |
38 return; | |
39 navigator.serviceWorker.unregister(scope).then(t.step_func(onUnregister) ); | |
40 } | |
41 }()); | |
42 </script> | |
43 </body> | |
OLD | NEW |