Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/http/tests/serviceworker/webexposed/global-interface-listing-service-worker.html |
| diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/webexposed/global-interface-listing-service-worker.html b/third_party/WebKit/LayoutTests/http/tests/serviceworker/webexposed/global-interface-listing-service-worker.html |
| index 1a3a958d538883ee8c35322ca47d72e62086dfa8..25aa5ce7c1655dbba91005716d2e4a7743bfd57a 100644 |
| --- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/webexposed/global-interface-listing-service-worker.html |
| +++ b/third_party/WebKit/LayoutTests/http/tests/serviceworker/webexposed/global-interface-listing-service-worker.html |
| @@ -2,33 +2,57 @@ |
| <html> |
| <head> |
| <title>ServiceWorkerGlobalScope expose test.</title> |
| - <script src="../../resources/testharness.js"></script> |
| - <script src="../../resources/testharnessreport.js"></script> |
| - <script src="../resources/test-helpers.js"></script> |
| + <script src="../../js-test-resources/js-test.js"></script> |
| </head> |
| <body> |
| - <script> |
| +<div id="console"></div> |
| +<script> |
| +// We can't use testharness.js in this test because this needs to dump text |
| +// other than PASS/FAIL. |
| - async_test(function(t) { |
| - service_worker_unregister_and_register( |
| - t, 'resources/global-interface-listing-worker.js', |
| - 'resources/global-interface-listing-worker') |
| - .then(function(registration) { |
| - var sw = registration.installing; |
| - var message_channel = new MessageChannel; |
| - message_channel.port1.onmessage = t.step_func(on_message); |
| - sw.postMessage(null, [message_channel.port2]); |
| - }).catch(unreached_rejection(t)); |
| +jsTestIsAsync = true; |
| - function on_message(evt) { |
| - var pre = document.createElement('pre'); |
| - pre.appendChild(document.createTextNode(evt.data.result.join('\n'))); |
| - document.body.appendChild(pre); |
| +function unregister_service_worker(documentUrl) { |
|
falken
2016/05/17 01:51:33
document_url for consistency
tkent
2016/05/17 03:38:24
Done
|
| + return navigator.serviceWorker.getRegistration(documentUrl) |
| + .then(function(registration) { |
| + if (registration) |
| + return registration.unregister(); |
| + }).catch(function() { |
| + testFailed('getRegistration() should not fail'); |
| + finishJSTest(); |
| + }); |
|
falken
2016/05/17 01:51:33
I would just have this return a promise:
return n
tkent
2016/05/17 03:38:24
Done.
|
| +} |
| - service_worker_unregister_and_done(t); |
| - }; |
| - }, 'Verify the interface of ServiceWorkerGlobalScope'); |
| - |
| - </script> |
| +var scope = 'resources/global-interface-listing-worker'; |
| +var options = { scope: scope }; |
| +unregister_service_worker(scope) |
| + .then(() => { |
| + return navigator.serviceWorker.register( |
| + 'resources/global-interface-listing-worker.js', |
| + options); |
| + }) |
| + .then(registration => { |
| + var sw = registration.installing; |
| + return new Promise(resolve => { |
| + var message_channel = new MessageChannel; |
| + message_channel.port1.onmessage = (evt => resolve(evt)); |
| + sw.postMessage(null, [message_channel.port2]); |
| + }); |
| + }) |
| + .then(evt => { |
| + var pre = document.createElement('pre'); |
| + pre.appendChild(document.createTextNode(evt.data.result.join('\n'))); |
| + document.body.insertBefore(pre, document.body.firstChild); |
| + return unregister_service_worker(scope); |
| + }) |
| + .then(() => { |
| + testPassed('Verify the interface of ServiceWorkerGlobalScope'); |
| + finishJSTest(); |
| + }) |
| + .catch(error => { |
| + testFailed('error: ' + (error.message || error.name || error)); |
| + finishJSTest(); |
| + }); |
| +</script> |
| </body> |
| </html> |