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

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

Issue 2880823002: Upstream service worker `ready` test to WPT (Closed)
Patch Set: Stengthen expectation Created 3 years, 7 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: third_party/WebKit/LayoutTests/http/tests/serviceworker/ready.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/ready.html b/third_party/WebKit/LayoutTests/http/tests/serviceworker/ready.html
deleted file mode 100644
index 64580939b295e07edd3b0b2ade823b75fe5a566b..0000000000000000000000000000000000000000
--- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/ready.html
+++ /dev/null
@@ -1,229 +0,0 @@
-<!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>
-<body>
-<script>
-test(function() {
- var promise = navigator.serviceWorker.ready;
- assert_equals(promise, navigator.serviceWorker.ready,
- 'repeated access to ready without intervening ' +
- 'registrations should return the same Promise object');
- }, 'ready returns the same Promise object');
-
-promise_test(function(t) {
- return with_iframe('resources/blank.html?uncontrolled')
- .then(t.step_func(function(frame) {
- var promise = frame.contentWindow.navigator.serviceWorker.ready;
- assert_equals(Object.getPrototypeOf(promise),
- frame.contentWindow.Promise.prototype,
- 'the Promise should be in the context of the ' +
- 'related document');
- }));
- }, 'ready returns a Promise object in the context of the related document');
-
-promise_test(function(t) {
- var url = 'resources/empty-worker.js';
- var scope = 'resources/blank.html?ready-controlled';
- var expected_url = normalizeURL(url);
- var frame;
-
- return service_worker_unregister_and_register(t, url, scope)
- .then(function(registration) {
- add_completion_callback(function() { registration.unregister(); });
- return wait_for_state(t, registration.installing, 'activated');
- })
- .then(function() { return with_iframe(scope); })
- .then(function(f) {
- frame = f;
- 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');
- assert_in_array(registration.active.state,
- ['activating', 'activated'],
- '.ready should be resolved when the registration ' +
- 'has an active worker');
- });
- }, 'ready on a controlled document');
-
-promise_test(function(t) {
- var url = 'resources/empty-worker.js';
- var scope = 'resources/blank.html?ready-potential-controlled';
- var expected_url = normalizeURL(url);
- var frame;
-
- return with_iframe(scope)
- .then(function(f) {
- frame = f;
- return navigator.serviceWorker.register(url, {scope:scope});
- })
- .then(function(r) {
- add_completion_callback(function() { r.unregister(); });
- 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_in_array(registration.active.state,
- ['activating', 'activated'],
- '.ready should be resolved when the registration ' +
- 'has an active worker');
- assert_equals(frame.contentWindow.navigator.serviceWorker.controller,
- null,
- 'uncontrolled document should not have a controller');
- });
- }, 'ready on a potential controlled document');
-
-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;
- 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().
- assert_equals(registration.installing, null,
- 'installing should be null');
- assert_equals(registration.waiting, null, 'waiting should be null');
- assert_not_equals(registration.active, null,
- 'active after ready should not be null');
- assert_in_array(registration.active.state,
- ['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');
-
-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) {
- 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().
- assert_equals(registration.installing, null,
- 'installing should be null');
- assert_equals(registration.waiting, null, 'waiting should be null');
- assert_not_equals(registration.active, null,
- 'active after ready should not be null');
- 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');
-
-promise_test(function(t) {
- var url = 'resources/empty-worker.js';
- var matched_scope = 'resources/blank.html?ready-after-match';
- var longer_matched_scope = 'resources/blank.html?ready-after-match-longer';
- var frame, registration;
-
- return 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) {
- add_completion_callback(function() { r.unregister(); });
- registration = r;
- return wait_for_state(t, r.installing, 'activated');
- })
- .then(function() {
- return navigator.serviceWorker.register(
- url, {scope: longer_matched_scope});
- })
- .then(function(r) {
- add_completion_callback(function() { r.unregister(); });
- 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');
- });
- }, 'ready after a longer matched registration registered');
-
-promise_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;
-
- return service_worker_unregister_and_register(t, url, matched_scope)
- .then(function(r) {
- add_completion_callback(function() { r.unregister(); });
- registration = r;
- return wait_for_state(t, r.installing, 'activated');
- })
- .then(function() {
- return with_iframe(longer_matched_scope);
- })
- .then(function(f) {
- frame = f;
- 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(r) {
- add_completion_callback(function() { r.unregister(); });
- return frame.contentWindow.navigator.serviceWorker.ready;
- })
- .then(function(r) {
- assert_equals(r.scope, normalizeURL(matched_scope),
- 'ready should only be resolved once');
- });
- }, 'access ready after it has been resolved');
-
-</script>

Powered by Google App Engine
This is Rietveld 408576698