| 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>
 | 
| 
 |