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

Side by Side 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: Improve global-interface-listing-service-worker.html, adjust touch-pointer-event-properties-expecte… 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 unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>ServiceWorkerGlobalScope expose test.</title> 4 <title>ServiceWorkerGlobalScope expose test.</title>
5 <script src="../../resources/testharness.js"></script> 5 <script src="../../js-test-resources/js-test.js"></script>
6 <script src="../../resources/testharnessreport.js"></script>
7 <script src="../resources/test-helpers.js"></script>
8 </head> 6 </head>
9 <body> 7 <body>
10 <script> 8 <div id="console"></div>
9 <script>
10 // We can't use testharness.js in this test because this needs to dump text
11 // other than PASS/FAIL.
11 12
12 async_test(function(t) { 13 jsTestIsAsync = true;
13 service_worker_unregister_and_register(
14 t, 'resources/global-interface-listing-worker.js',
15 'resources/global-interface-listing-worker')
16 .then(function(registration) {
17 var sw = registration.installing;
18 var message_channel = new MessageChannel;
19 message_channel.port1.onmessage = t.step_func(on_message);
20 sw.postMessage(null, [message_channel.port2]);
21 }).catch(unreached_rejection(t));
22 14
23 function on_message(evt) { 15 function unregister_service_worker(documentUrl) {
falken 2016/05/17 01:51:33 document_url for consistency
tkent 2016/05/17 03:38:24 Done
24 var pre = document.createElement('pre'); 16 return navigator.serviceWorker.getRegistration(documentUrl)
25 pre.appendChild(document.createTextNode(evt.data.result.join('\n'))); 17 .then(function(registration) {
26 document.body.appendChild(pre); 18 if (registration)
19 return registration.unregister();
20 }).catch(function() {
21 testFailed('getRegistration() should not fail');
22 finishJSTest();
23 });
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.
24 }
27 25
28 service_worker_unregister_and_done(t); 26 var scope = 'resources/global-interface-listing-worker';
29 }; 27 var options = { scope: scope };
30 }, 'Verify the interface of ServiceWorkerGlobalScope'); 28 unregister_service_worker(scope)
31 29 .then(() => {
32 </script> 30 return navigator.serviceWorker.register(
31 'resources/global-interface-listing-worker.js',
32 options);
33 })
34 .then(registration => {
35 var sw = registration.installing;
36 return new Promise(resolve => {
37 var message_channel = new MessageChannel;
38 message_channel.port1.onmessage = (evt => resolve(evt));
39 sw.postMessage(null, [message_channel.port2]);
40 });
41 })
42 .then(evt => {
43 var pre = document.createElement('pre');
44 pre.appendChild(document.createTextNode(evt.data.result.join('\n')));
45 document.body.insertBefore(pre, document.body.firstChild);
46 return unregister_service_worker(scope);
47 })
48 .then(() => {
49 testPassed('Verify the interface of ServiceWorkerGlobalScope');
50 finishJSTest();
51 })
52 .catch(error => {
53 testFailed('error: ' + (error.message || error.name || error));
54 finishJSTest();
55 });
56 </script>
33 </body> 57 </body>
34 </html> 58 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698