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

Unified Diff: LayoutTests/http/tests/serviceworker/ready.html

Issue 912443002: ServiceWorker: Make "ready" fetches registration from browser process(3/3). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: add cleanup Created 5 years, 9 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
« no previous file with comments | « LayoutTests/TestExpectations ('k') | Source/modules/serviceworkers/ServiceWorkerContainer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/http/tests/serviceworker/ready.html
diff --git a/LayoutTests/http/tests/serviceworker/ready.html b/LayoutTests/http/tests/serviceworker/ready.html
index 4878fb4c83d62d046e06bd489e7760dcc66e7c11..19f9dd32774ba05bafdda2ea771d5b316ffbb8cf 100644
--- a/LayoutTests/http/tests/serviceworker/ready.html
+++ b/LayoutTests/http/tests/serviceworker/ready.html
@@ -91,42 +91,82 @@ async_test(function(t) {
async_test(function(t) {
var url = 'resources/empty-worker.js';
- var scope = 'resources/blank.html?ready-after-unregister';
- var expected_url = normalizeURL(url);
- var frame;
- var registration;
+ var matched_scope = 'resources/blank.html?ready-after-match';
+ var longer_matched_scope = 'resources/blank.html?ready-after-match-longer';
+ var frame, registration;
- service_worker_unregister_and_register(t, url, scope)
+ Promise.all([service_worker_unregister(t, matched_scope),
+ service_worker_unregister(t, longer_matched_scope)])
+ .then(function() {
+ return with_iframe(longer_matched_scope);
+ })
+ .then(function(f) {
+ frame = f;
+ return navigator.serviceWorker.register(url, {scope: matched_scope});
+ })
.then(function(r) {
registration = r;
return wait_for_state(t, r.installing, 'activated');
})
- .then(function() { return with_iframe(scope); })
+ .then(function() {
+ return navigator.serviceWorker.register(
+ url, {scope: longer_matched_scope});
+ })
+ .then(function() {
+ return frame.contentWindow.navigator.serviceWorker.ready;
+ })
+ .then(function(r) {
+ assert_equals(r.scope, normalizeURL(longer_matched_scope),
+ 'longer matched registration should be returned');
+ assert_equals(frame.contentWindow.navigator.serviceWorker.controller,
+ null, 'controller should be null');
+ return registration.unregister();
+ })
+ .then(function() {
+ frame.remove();
+ return service_worker_unregister_and_done(t, longer_matched_scope);
+ })
+ .catch(unreached_rejection(t));
+ }, 'ready after a longer matched registration registered');
+
+async_test(function(t) {
+ var url = 'resources/empty-worker.js';
+ var matched_scope = 'resources/blank.html?ready-after-resolve';
+ var longer_matched_scope =
+ 'resources/blank.html?ready-after-resolve-longer';
+ var frame, registration;
+
+ service_worker_unregister_and_register(t, url, matched_scope)
+ .then(function(r) {
+ registration = r;
+ return wait_for_state(t, r.installing, 'activated');
+ })
+ .then(function() {
+ return with_iframe(longer_matched_scope);
+ })
.then(function(f) {
frame = f;
- return registration.unregister();
+ return f.contentWindow.navigator.serviceWorker.ready;
+ })
+ .then(function(r) {
+ assert_equals(r.scope, normalizeURL(matched_scope),
+ 'matched registration should be returned');
+ return navigator.serviceWorker.register(
+ url, {scope: longer_matched_scope});
})
.then(function() {
return frame.contentWindow.navigator.serviceWorker.ready;
})
- .then(function(registration) {
- assert_equals(registration.installing, null,
- 'installing should be null');
- assert_equals(registration.waiting, null,
- 'waiting should be null');
- assert_equals(registration.active.scriptURL, expected_url,
- 'active after ready should not be null');
- assert_equals(
- frame.contentWindow.navigator.serviceWorker.controller.scriptURL,
- expected_url,
- 'controlled document should have a controller');
-
+ .then(function(r) {
+ assert_equals(r.scope, normalizeURL(matched_scope),
+ 'ready should only be resolved once');
+ return registration.unregister();
+ })
+ .then(function() {
frame.remove();
- service_worker_unregister_and_done(t, scope);
+ return service_worker_unregister_and_done(t, longer_matched_scope);
})
.catch(unreached_rejection(t));
- }, 'ready after unregistration');
+ }, 'access ready after it has been resolved');
-// FIXME: When replace() is implemented add a test that .ready is
-// repeatedly created and settled.
</script>
« no previous file with comments | « LayoutTests/TestExpectations ('k') | Source/modules/serviceworkers/ServiceWorkerContainer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698