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/claim-not-using-registration.html

Issue 2763123002: Upstream service worker `claim` tests to WPT (Closed)
Patch Set: Persist Chromium-specific version of test Created 3 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
Index: third_party/WebKit/LayoutTests/http/tests/serviceworker/claim-not-using-registration.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/claim-not-using-registration.html b/third_party/WebKit/LayoutTests/http/tests/serviceworker/claim-not-using-registration.html
deleted file mode 100644
index a30a62961f5e598be5b5e3141f67998df552ccfa..0000000000000000000000000000000000000000
--- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/claim-not-using-registration.html
+++ /dev/null
@@ -1,122 +0,0 @@
-<!DOCTYPE html>
-<title>Service Worker: claim client not using registration</title>
-<script src="../resources/testharness.js"></script>
-<script src="../resources/testharnessreport.js"></script>
-<script src="resources/test-helpers.js"></script>
-<body>
-<script>
-
-promise_test(function(t) {
- var init_scope = 'resources/blank.html?not-using-init';
- var claim_scope = 'resources/blank.html?not-using';
- var init_worker_url = 'resources/empty.js';
- var claim_worker_url = 'resources/claim-worker.js';
- var claim_worker, claim_registration, frame1, frame2;
- return service_worker_unregister_and_register(
- t, init_worker_url, init_scope)
- .then(function(registration) {
- return wait_for_state(t, registration.installing, 'activated');
- })
- .then(function() {
- return Promise.all(
- [with_iframe(init_scope), with_iframe(claim_scope)]);
- })
- .then(function(frames) {
- frame1 = frames[0];
- frame2 = frames[1];
- assert_equals(
- frame1.contentWindow.navigator.serviceWorker.controller.scriptURL,
- normalizeURL(init_worker_url),
- 'Frame1 controller should not be null');
- assert_equals(
- frame2.contentWindow.navigator.serviceWorker.controller, null,
- 'Frame2 controller should be null');
- return navigator.serviceWorker.register(claim_worker_url,
- {scope: claim_scope});
- })
- .then(function(registration) {
- claim_worker = registration.installing;
- claim_registration = registration;
- return wait_for_state(t, registration.installing, 'activated');
- })
- .then(function() {
- var saw_controllerchanged = new Promise(function(resolve) {
- frame2.contentWindow.navigator.serviceWorker.oncontrollerchange =
- function() { resolve(); }
- });
- var channel = new MessageChannel();
- var saw_message = new Promise(function(resolve) {
- channel.port1.onmessage = t.step_func(function(e) {
- assert_equals(e.data, 'PASS',
- 'Worker call to claim() should fulfill.');
- resolve();
- });
- });
- claim_worker.postMessage({port: channel.port2}, [channel.port2]);
- return Promise.all([saw_controllerchanged, saw_message]);
- })
- .then(function() {
- assert_equals(
- frame1.contentWindow.navigator.serviceWorker.controller.scriptURL,
- normalizeURL(init_worker_url),
- 'Frame1 should not be influenced');
- assert_equals(
- frame2.contentWindow.navigator.serviceWorker.controller.scriptURL,
- normalizeURL(claim_worker_url),
- 'Frame2 should be controlled by the new registration');
- frame1.remove();
- frame2.remove();
- return claim_registration.unregister();
- })
- .then(function() {
- return service_worker_unregister_and_done(t, init_scope);
- });
- }, 'Test claim client which is not using registration');
-
-promise_test(function(t) {
- var scope = 'resources/blank.html?longer-matched';
- var claim_scope = 'resources/blank.html?longer';
- var claim_worker_url = 'resources/claim-worker.js';
- var installing_worker_url = 'resources/empty-worker.js';
- var frame, claim_worker;
- return with_iframe(scope)
- .then(function(f) {
- frame = f;
- return navigator.serviceWorker.register(
- claim_worker_url, {scope: claim_scope});
- })
- .then(function(registration) {
- claim_worker = registration.installing;
- return wait_for_state(t, registration.installing, 'activated');
- })
- .then(function() {
- return navigator.serviceWorker.register(
- installing_worker_url, {scope: scope});
- })
- .then(function() {
- var channel = new MessageChannel();
- var saw_message = new Promise(function(resolve) {
- channel.port1.onmessage = t.step_func(function(e) {
- assert_equals(e.data, 'PASS',
- 'Worker call to claim() should fulfill.');
- resolve();
- });
- });
- claim_worker.postMessage({port: channel.port2}, [channel.port2]);
- return saw_message;
- })
- .then(function() {
- assert_equals(
- frame.contentWindow.navigator.serviceWorker.controller, null,
- 'Frame should not be claimed when a longer-matched ' +
- 'registration exists');
- frame.remove();
- return service_worker_unregister(t, claim_scope);
- })
- .then(function() {
- return service_worker_unregister_and_done(t, scope);
- });
- }, 'Test claim client when there\'s a longer-matched registration not ' +
- 'already used by the page');
-
-</script>

Powered by Google App Engine
This is Rietveld 408576698