-
-
Save jugglinmike/97ee7ef533207b9c985f5e54dff1eb06 to your computer and use it in GitHub Desktop.
sw-migration-ready.diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/ready.html b/ready.http.html | |
index 6458093..d5b6990 100644 | |
--- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/ready.html | |
+++ b/ready.http.html | |
@@ -1,8 +1,8 @@ | |
<!DOCTYPE html> | |
<title>Service Worker: navigator.serviceWorker.ready</title> | |
-<script src="../resources/testharness.js"></script> | |
-<script src="../resources/testharnessreport.js"></script> | |
-<script src="resources/test-helpers.js"></script> | |
+<script src="/resources/testharness.js"></script> | |
+<script src="/resources/testharnessreport.js"></script> | |
+<script src="resources/test-helpers.sub.js"></script> | |
<body> | |
<script> | |
test(function() { | |
@@ -16,6 +16,10 @@ promise_test(function(t) { | |
return with_iframe('resources/blank.html?uncontrolled') | |
.then(t.step_func(function(frame) { | |
var promise = frame.contentWindow.navigator.serviceWorker.ready; | |
+ t.add_cleanup(function() { | |
+ frame.remove(); | |
+ }); | |
+ | |
assert_equals(Object.getPrototypeOf(promise), | |
frame.contentWindow.Promise.prototype, | |
'the Promise should be in the context of the ' + | |
@@ -31,11 +35,16 @@ promise_test(function(t) { | |
return service_worker_unregister_and_register(t, url, scope) | |
.then(function(registration) { | |
- add_completion_callback(function() { registration.unregister(); }); | |
+ add_completion_callback(function() { | |
+ registration.unregister(); | |
+ }); | |
return wait_for_state(t, registration.installing, 'activated'); | |
}) | |
.then(function() { return with_iframe(scope); }) | |
.then(function(f) { | |
+ t.add_cleanup(function() { | |
+ f.remove(); | |
+ }); | |
frame = f; | |
return frame.contentWindow.navigator.serviceWorker.ready; | |
}) | |
@@ -65,11 +74,16 @@ promise_test(function(t) { | |
return with_iframe(scope) | |
.then(function(f) { | |
+ t.add_cleanup(function() { | |
+ f.remove(); | |
+ }); | |
frame = f; | |
return navigator.serviceWorker.register(url, {scope:scope}); | |
}) | |
.then(function(r) { | |
- add_completion_callback(function() { r.unregister(); }); | |
+ add_completion_callback(function() { | |
+ r.unregister(); | |
+ }); | |
return frame.contentWindow.navigator.serviceWorker.ready; | |
}) | |
.then(function(registration) { | |
@@ -92,25 +106,24 @@ promise_test(function(t) { | |
promise_test(function(t) { | |
var url = 'resources/empty-worker.js'; | |
var scope = 'resources/blank.html?ready-installing'; | |
- | |
+ | |
return service_worker_unregister(t, scope) | |
.then(function() { | |
return with_iframe(scope); | |
}) | |
.then(function(f) { | |
var promise = f.contentWindow.navigator.serviceWorker.ready; | |
+ t.add_cleanup(function() { | |
+ f.remove(); | |
+ }); | |
navigator.serviceWorker.register(url, {scope: scope}); | |
return promise; | |
}) | |
.then(function(registration) { | |
- // add_completion_callback(function() { registration.unregister(); }) | |
- // might not work because the registration is associated with an | |
- // iframe's context, and if the iframe is removed before calling the | |
- // callback, unregistraion would fail. Hence we manually call | |
- // unregister() before finishing this test and removing the iframe. | |
- var promise = registration.unregister(); | |
- | |
- // |registration| should still be valid even after unregister(). | |
+ add_completion_callback(function() { | |
+ registration.unregister(); | |
+ }); | |
+ | |
assert_equals(registration.installing, null, | |
'installing should be null'); | |
assert_equals(registration.waiting, null, 'waiting should be null'); | |
@@ -120,7 +133,6 @@ promise_test(function(t) { | |
['activating', 'activated'], | |
'.ready should be resolved when the registration ' + | |
'has an active worker'); | |
- return promise; | |
}); | |
}, 'ready on an iframe whose parent registers a new service worker'); | |
@@ -128,20 +140,19 @@ promise_test(function(t) { | |
var url = 'resources/empty-worker.js'; | |
var scope = 'resources/register-iframe.html'; | |
var expected_url = normalizeURL(url); | |
- | |
+ | |
return with_iframe(scope) | |
.then(function(f) { | |
+ t.add_cleanup(function() { | |
+ f.remove(); | |
+ }); | |
return f.contentWindow.navigator.serviceWorker.ready; | |
}) | |
.then(function(registration) { | |
- // add_completion_callback(function() { registration.unregister(); }) | |
- // might not work because the registration is associated with an | |
- // iframe's context, and if the iframe is removed before calling the | |
- // callback, unregistraion would fail. Hence we manually call | |
- // unregister() before finishing this test and removing the iframe. | |
- var promise = registration.unregister(); | |
- | |
- // |registration| should still be valid even after unregister(). | |
+ add_completion_callback(function() { | |
+ registration.unregister(); | |
+ }); | |
+ | |
assert_equals(registration.installing, null, | |
'installing should be null'); | |
assert_equals(registration.waiting, null, 'waiting should be null'); | |
@@ -150,7 +161,6 @@ promise_test(function(t) { | |
assert_in_array(registration.active.state, | |
['activating', 'activated'], | |
'.ready should be resolved with "active worker"'); | |
- return promise; | |
}); | |
}, 'ready on an iframe with installing a new service worker by itself'); | |
@@ -166,11 +176,16 @@ promise_test(function(t) { | |
return with_iframe(longer_matched_scope); | |
}) | |
.then(function(f) { | |
+ t.add_cleanup(function() { | |
+ f.remove(); | |
+ }); | |
frame = f; | |
return navigator.serviceWorker.register(url, {scope: matched_scope}); | |
}) | |
.then(function(r) { | |
- add_completion_callback(function() { r.unregister(); }); | |
+ add_completion_callback(function() { | |
+ r.unregister(); | |
+ }); | |
registration = r; | |
return wait_for_state(t, r.installing, 'activated'); | |
}) | |
@@ -179,7 +194,9 @@ promise_test(function(t) { | |
url, {scope: longer_matched_scope}); | |
}) | |
.then(function(r) { | |
- add_completion_callback(function() { r.unregister(); }); | |
+ add_completion_callback(function() { | |
+ r.unregister(); | |
+ }); | |
return frame.contentWindow.navigator.serviceWorker.ready; | |
}) | |
.then(function(r) { | |
@@ -199,7 +216,9 @@ promise_test(function(t) { | |
return service_worker_unregister_and_register(t, url, matched_scope) | |
.then(function(r) { | |
- add_completion_callback(function() { r.unregister(); }); | |
+ add_completion_callback(function() { | |
+ r.unregister(); | |
+ }); | |
registration = r; | |
return wait_for_state(t, r.installing, 'activated'); | |
}) | |
@@ -207,6 +226,9 @@ promise_test(function(t) { | |
return with_iframe(longer_matched_scope); | |
}) | |
.then(function(f) { | |
+ t.add_cleanup(function() { | |
+ f.remove(); | |
+ }); | |
frame = f; | |
return f.contentWindow.navigator.serviceWorker.ready; | |
}) | |
@@ -217,7 +239,9 @@ promise_test(function(t) { | |
url, {scope: longer_matched_scope}); | |
}) | |
.then(function(r) { | |
- add_completion_callback(function() { r.unregister(); }); | |
+ add_completion_callback(function() { | |
+ r.unregister(); | |
+ }); | |
return frame.contentWindow.navigator.serviceWorker.ready; | |
}) | |
.then(function(r) { | |
@@ -225,5 +249,4 @@ promise_test(function(t) { | |
'ready should only be resolved once'); | |
}); | |
}, 'access ready after it has been resolved'); | |
- | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment