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

Side by Side Diff: LayoutTests/http/tests/serviceworker/clients-matchall.html

Issue 1286123004: Ensure that Service Worker clients are always returned in MRU order (2) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Switch to promise_test(...) and fix silly copypasta. Created 5 years, 4 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
« no previous file with comments | « no previous file | LayoutTests/http/tests/serviceworker/clients-matchall-client-types.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <title>Service Worker: Clients.matchAll</title> 2 <title>Service Worker: Clients.matchAll</title>
3 <script src="../resources/testharness.js"></script> 3 <script src="../resources/testharness.js"></script>
4 <script src="../resources/testharnessreport.js"></script> 4 <script src="../resources/testharnessreport.js"></script>
5 <script src="resources/test-helpers.js"></script> 5 <script src="resources/test-helpers.js"></script>
6 <script> 6 <script>
7 var scope = 'resources/blank.html?clients-matchAll'; 7 var scope = 'resources/blank.html?clients-matchAll';
8 var t = async_test('Test Clients.matchAll()'); 8 var expectedFirst = [
9 /* visibilityState, focused, url, frameType */
10 ['visible', true, new URL(scope + '#1', location).toString(), 'nested'],
11 ['visible', false, new URL(scope + '#2', location).toString(), 'nested']
12 ];
13 var expectedSecond = [
14 /* visibilityState, focused, url, frameType */
15 ['visible', true, new URL(scope + '#2', location).toString(), 'nested'],
16 ['visible', false, new URL(scope + '#1', location).toString(), 'nested']
17 ];
18
9 var frame1, frame2; 19 var frame1, frame2;
10 t.step(function() { 20 var worker;
11 service_worker_unregister_and_register( 21 promise_test(function(t) {
22 return service_worker_unregister_and_register(
12 t, 'resources/clients-matchall-worker.js', scope) 23 t, 'resources/clients-matchall-worker.js', scope)
13 .then(function(registration) { 24 .then(function(registration) {
14 return wait_for_state(t, registration.installing, 'activated'); 25 worker = registration.installing;
26 return wait_for_state(t, worker, 'activated');
15 }) 27 })
16 .then(function() { return with_iframe(scope + '#1'); }) 28 .then(function() { return with_iframe(scope + '#1'); })
17 .then(function(f) { 29 .then(function(f) {
18 frame1 = f; 30 frame1 = f;
19 f.focus();
20 return with_iframe(scope + '#2'); 31 return with_iframe(scope + '#2');
21 }) 32 })
22 .then(function(f) { 33 .then(function(f) {
23 frame2 = f; 34 return new Promise(function(resolve) {
24 var channel = new MessageChannel(); 35 frame2 = f;
nhiroki 2015/08/19 09:09:45 nit: Can you move this line to line 33?
25 channel.port1.onmessage = t.step_func(onMessage); 36 frame1.focus();
26 f.contentWindow.navigator.serviceWorker.controller.postMessage( 37 var channel = new MessageChannel();
27 {port:channel.port2}, [channel.port2]); 38 channel.port1.onmessage = resolve;
39 worker.postMessage({port:channel.port2}, [channel.port2]);
40 });
28 }) 41 })
29 .catch(unreached_rejection(t)); 42 .then(function(message) {
30 }); 43 return new Promise(function(resolve) {
31 44 assert_equals(message.data.length, 2);
32 var expected = [ 45 assert_array_equals(message.data[0], expectedFirst[0]);
33 /* visibilityState, focused, url, frameType */ 46 assert_array_equals(message.data[1], expectedFirst[1]);
nhiroki 2015/08/19 09:09:45 nit: How about moving these assertions to line 43?
34 ['visible', true, new URL(scope + '#1', location).toString(), 'nested'], 47 frame2.focus();
35 ['visible', false, new URL(scope + '#2', location).toString(), 'nested'] 48 var channel = new MessageChannel();
36 ]; 49 channel.port1.onmessage = resolve;
37 50 worker.postMessage({port:channel.port2}, [channel.port2]);
38 function onMessage(e) { 51 });
39 assert_equals(e.data.length, 2); 52 })
40 assert_array_equals(e.data[0], expected[0]); 53 .then(function(message) {
41 assert_array_equals(e.data[1], expected[1]); 54 assert_equals(message.data.length, 2);
42 frame1.remove(); 55 assert_array_equals(message.data[0], expectedSecond[0]);
43 frame2.remove(); 56 assert_array_equals(message.data[1], expectedSecond[1]);
44 service_worker_unregister_and_done(t, scope); 57 frame1.remove();
45 } 58 frame2.remove();
59 return service_worker_unregister_and_done(t, scope);
60 })
61 }, 'Test Clients.matchAll()');
46 </script> 62 </script>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/http/tests/serviceworker/clients-matchall-client-types.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698