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

Unified Diff: LayoutTests/http/tests/geofencing/service-worker.html

Issue 543203003: Fix the geofencing test to not break if the promises resolve asynchronously. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 3 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: LayoutTests/http/tests/geofencing/service-worker.html
diff --git a/LayoutTests/http/tests/geofencing/service-worker.html b/LayoutTests/http/tests/geofencing/service-worker.html
new file mode 100644
index 0000000000000000000000000000000000000000..faede801ade47c82dfed0a4497b936f590862a08
--- /dev/null
+++ b/LayoutTests/http/tests/geofencing/service-worker.html
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="../serviceworker/resources/test-helpers.js"></script>
Peter Beverloo 2014/09/11 16:32:21 This feels really fragile because we don't have ex
+<script>
+var test = async_test('Verify geofencing in a Service Worker');
Peter Beverloo 2014/09/11 16:32:21 Please clarify the description a bit (verify which
+test.step(function() {
+ var scope = 'resources/blank.html';
+ service_worker_unregister_and_register(
+ test, 'resources/worker.js', scope)
+ .then(function(registration) {
+ return wait_for_update(test, registration);
+ })
Peter Beverloo 2014/09/11 16:32:21 nit: indentation in this block seems to be off. Pl
Marijn Kruisselbrink 2014/09/11 19:11:06 Since I rewrote this code entirely, this exact iss
+ .then(onRegister)
+ .catch(unreached_rejection(test));
+
+ function onRegister(worker) {
+ var messageChannel = new MessageChannel();
+ messageChannel.port1.onmessage = test.step_func(onMessage);
+ worker.postMessage({port: messageChannel.port2}, [messageChannel.port2]);
+ }
+
+ var result = [];
+ var expected = [
+ 'Rejected',
+ 'Rejected',
+ 'Rejected',
+ ];
+
+ function onMessage(e) {
+ var message = e.data;
+ if (message == 'quit') {
+ assert_array_equals(result, expected, 'Worker should post back expected values.');
+ service_worker_unregister_and_done(test, scope);
+ } else {
+ result.push(message);
+ }
+ }
+});
+</script>

Powered by Google App Engine
This is Rietveld 408576698