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

Unified 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: Restructure tests for readability. 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/http/tests/serviceworker/clients-matchall.html
diff --git a/LayoutTests/http/tests/serviceworker/clients-matchall.html b/LayoutTests/http/tests/serviceworker/clients-matchall.html
index b76e6482902d04fa7ad00ca38fcd8a808783d556..756383447dd7a8703d6262876088c3a2e60eeaf4 100644
--- a/LayoutTests/http/tests/serviceworker/clients-matchall.html
+++ b/LayoutTests/http/tests/serviceworker/clients-matchall.html
@@ -5,42 +5,58 @@
<script src="resources/test-helpers.js"></script>
<script>
var scope = 'resources/blank.html?clients-matchAll';
-var t = async_test('Test Clients.matchAll()');
+var expectedFirst = [
+ /* visibilityState, focused, url, frameType */
+ ['visible', true, new URL(scope + '#1', location).toString(), 'nested'],
+ ['visible', false, new URL(scope + '#2', location).toString(), 'nested']
+];
+var expectedSecond = [
+ /* visibilityState, focused, url, frameType */
+ ['visible', true, new URL(scope + '#2', location).toString(), 'nested'],
+ ['visible', false, new URL(scope + '#1', location).toString(), 'nested']
+];
+
var frame1, frame2;
-t.step(function() {
- service_worker_unregister_and_register(
+var worker;
+promise_test(function(t) {
+ return service_worker_unregister_and_register(
t, 'resources/clients-matchall-worker.js', scope)
.then(function(registration) {
- return wait_for_state(t, registration.installing, 'activated');
+ worker = registration.installing;
+ return wait_for_state(t, worker, 'activated');
})
.then(function() { return with_iframe(scope + '#1'); })
.then(function(f) {
frame1 = f;
- f.focus();
return with_iframe(scope + '#2');
})
.then(function(f) {
frame2 = f;
- var channel = new MessageChannel();
- channel.port1.onmessage = t.step_func(onMessage);
- f.contentWindow.navigator.serviceWorker.controller.postMessage(
- {port:channel.port2}, [channel.port2]);
+ return new Promise(function(resolve) {
+ frame1.focus();
+ var channel = new MessageChannel();
+ channel.port1.onmessage = resolve;
+ worker.postMessage({port:channel.port2}, [channel.port2]);
+ });
})
- .catch(unreached_rejection(t));
- });
-
-var expected = [
- /* visibilityState, focused, url, frameType */
- ['visible', true, new URL(scope + '#1', location).toString(), 'nested'],
- ['visible', false, new URL(scope + '#2', location).toString(), 'nested']
-];
-
-function onMessage(e) {
- assert_equals(e.data.length, 2);
- assert_array_equals(e.data[0], expected[0]);
- assert_array_equals(e.data[1], expected[1]);
- frame1.remove();
- frame2.remove();
- service_worker_unregister_and_done(t, scope);
-}
+ .then(function(message) {
+ assert_equals(message.data.length, 2);
+ assert_array_equals(message.data[0], expectedFirst[0]);
+ assert_array_equals(message.data[1], expectedFirst[1]);
+ return new Promise(function(resolve) {
+ frame2.focus();
+ var channel = new MessageChannel();
+ channel.port1.onmessage = resolve;
+ worker.postMessage({port:channel.port2}, [channel.port2]);
+ });
+ })
+ .then(function(message) {
+ assert_equals(message.data.length, 2);
+ assert_array_equals(message.data[0], expectedSecond[0]);
+ assert_array_equals(message.data[1], expectedSecond[1]);
+ frame1.remove();
+ frame2.remove();
+ return service_worker_unregister_and_done(t, scope);
+ })
+ }, 'Test Clients.matchAll()');
</script>
« 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