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

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

Issue 2853383004: Upstream service worker registration tests to WPT (Closed)
Patch Set: Incorporate review feedback Created 3 years, 8 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 | « third_party/WebKit/LayoutTests/http/tests/serviceworker/getregistration.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/http/tests/serviceworker/getregistrations.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/getregistrations.html b/third_party/WebKit/LayoutTests/http/tests/serviceworker/getregistrations.html
deleted file mode 100644
index 2f514751500df4e1d671e45ad85fae459c3f87d3..0000000000000000000000000000000000000000
--- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/getregistrations.html
+++ /dev/null
@@ -1,149 +0,0 @@
-<!DOCTYPE html>
-<title>Service Worker: getRegistrations()</title>
-<script src="../resources/testharness.js"></script>
-<script src="../resources/testharnessreport.js"></script>
-<script src="resources/test-helpers.js"></script>
-<script src="../resources/get-host-info.js"></script>
-<script>
-// Purge the existing registrations for the origin.
-// getRegistrations() is used in order to avoid adding additional complexity
-// e.g. adding an internal function.
-promise_test(function(t) {
- var resolve;
- var timer;
- var p = new Promise(function(r) { resolve = r; });
- navigator.serviceWorker.getRegistrations()
- .then(function(regs) {
- return Promise.all(regs.map(function(r) { r.unregister(); }));
- })
- .then(function() {
- // As registration.unregister() promises resolve before the
- // corresponding registrations are deleted from the storage, we must
- // wait until the registrations are actually removed from the storage.
- // Spec reference: https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#unregister-algorithm
- timer = setInterval(function() {
- navigator.serviceWorker.getRegistrations()
- .then(function(regs) {
- if (regs.length == 0) {
- clearInterval(timer);
- resolve();
- }
- });
- }, 100);
- });
- return p;
- }, 'Purge the existing registrations.');
-
-promise_test(function(t) {
- var scope = 'resources/scope/getregistrations/normal';
- var script = 'resources/empty-worker.js';
- var registrations = [];
- return service_worker_unregister_and_register(t, script, scope)
- .then(function(r) {
- registrations.push(r);
- return navigator.serviceWorker.getRegistrations();
- })
- .then(function(value) {
- assert_array_equals(
- value,
- registrations,
- 'getRegistrations should resolve with array of registrations.');
- return service_worker_unregister(t, scope);
- });
- }, 'Register then getRegistrations');
-
-promise_test(function(t) {
- var scope1 = 'resources/scope/getregistrations/scope1';
- var scope2 = 'resources/scope/getregistrations/scope2';
- var script = 'resources/empty-worker.js';
- var registrations = [];
- return service_worker_unregister_and_register(t, script, scope1)
- .then(function(r) {
- registrations.push(r);
- return service_worker_unregister_and_register(t, script, scope2);
- })
- .then(function(r) {
- registrations.push(r);
- return navigator.serviceWorker.getRegistrations();
- })
- .then(function(value) {
- assert_array_equals(
- value,
- registrations,
- 'getRegistrations should resolve with array of registrations.');
- return service_worker_unregister(t, scope1);
- })
- .then(function() {
- return service_worker_unregister(t, scope2);
- });
- }, 'Register multiple times then getRegistrations');
-
-promise_test(function(t) {
- var scope = 'resources/scope/getregistrations/register-unregister';
- var script = 'resources/empty-worker.js';
- return service_worker_unregister_and_register(t, script, scope)
- .then(function(registration) {
- return registration.unregister();
- })
- .then(function() {
- return navigator.serviceWorker.getRegistrations();
- })
- .then(function(value) {
- assert_array_equals(
- value,
- [],
- 'getRegistrations should resolve with an empty array.');
- });
- }, 'Register then Unregister then getRegistrations');
-
-promise_test(function(t) {
- // Top-level window's origin: http://127.0.0.1:8000.
- // Frame's origin: http://localhost:8000.
- var host_info = get_host_info();
- var frame_url = host_info['HTTP_REMOTE_ORIGIN'] +
- '/serviceworker/resources/frame-for-getregistrations.html';
- var scope = 'resources/scope-for-getregistrations';
- var script = 'resources/empty-worker.js';
- var frame;
- var registrations = [];
-
- return with_iframe(frame_url)
- .then(function(f) {
- frame = f;
-
- var resolve;
- var p = new Promise(function(r) { resolve = r; });
-
- var channel = new MessageChannel();
-
- channel.port1.onmessage = function(e) {
- // Frame's registration is registered.
- if (e.data == 'registered') {
- // Top-level window registers a registration scoped
- // http://127.0.0.1:8000/serviceworker/resources/scope-for-getregistrations.
- service_worker_unregister_and_register(t, script, scope)
- .then(function(r) {
- registrations.push(r);
- return navigator.serviceWorker.getRegistrations();
- })
- .then(function(value) {
- assert_array_equals(value, registrations,
- 'getRegistrations should return only the same origin ' +
- 'registrations.');
- channel.port1.postMessage('unregister');
- });
- } else if (e.data == 'unregistered') {
- resolve();
- }
- };
- frame.contentWindow.postMessage('register', '*', [channel.port2]);
- return p;
- })
- .then(function() {
- frame.remove();
- return service_worker_unregister(t, scope);
- });
- }, 'getRegistrations promise resolves only with same origin registrations.');
-
-done();
-</script>
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/serviceworker/getregistration.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698