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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/serviceworker/webexposed/global-interface-listing-service-worker.html

Issue 1977313003: testharnessreport: Clear BODY content regardless of existence of <div id=log> (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unregister_service_worker() Created 4 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/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..1d513295fc2653ff403b3cb92adedb11fe6377e0 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,54 @@
<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(document_url) {
+ return navigator.serviceWorker.getRegistration(document_url)
+ .then(registration => {
+ if (registration)
+ return registration.unregister();
+ });
+}
- 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>

Powered by Google App Engine
This is Rietveld 408576698