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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/serviceworker/ServiceWorkerGlobalScope/service-worker-error-event.html

Issue 2804533002: Update Error Event inside a worker to provide the exact exception value (Closed)
Patch Set: Created 3 years, 8 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/ServiceWorkerGlobalScope/service-worker-error-event.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/ServiceWorkerGlobalScope/service-worker-error-event.html b/third_party/WebKit/LayoutTests/http/tests/serviceworker/ServiceWorkerGlobalScope/service-worker-error-event.html
new file mode 100644
index 0000000000000000000000000000000000000000..6d610db1a775f4c87b9dd198b50dd51fa88cb2dd
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/serviceworker/ServiceWorkerGlobalScope/service-worker-error-event.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<title>ServiceWorkerGlobalScope: Error event error message</title>
+<script src='../../resources/testharness.js'></script>
+<script src='../../resources/testharnessreport.js'></script>
+<script src='../resources/test-helpers.js'></script>
+<script>
+
+promise_test(function(t) {
+ var script = 'resources/error-worker-script.js';
+ var scope = 'resources/scope/service-worker-error-event';
+ var serviceworker;
+ return service_worker_unregister_and_register(t, script, scope)
+ .then(function(registration) {
+ serviceworker = registration.installing;
+ return wait_for_state(t, registration.installing, 'activated');
shimazu 2017/04/05 07:23:22 I think you don't need to wait for activation. How
yiyix 2017/04/05 09:02:55 Done.
+ })
shimazu 2017/04/05 07:23:22 +2 indent to follow the coding style: https://www.
yiyix 2017/04/05 09:02:55 Thank you so much. I thought the closing bracket s
+ .then(function() { return with_iframe(scope); })
shimazu 2017/04/05 07:23:22 I think you don't need to trigger fetch request in
yiyix 2017/04/05 09:02:55 removed.
+ .then(function() {
+ return new Promise(function(resolve) {
+ navigator.serviceWorker.onmessage = function(event) {
shimazu 2017/04/05 07:23:22 'navigator.serviceWorker.onmessage = resolve' woul
yiyix 2017/04/05 09:02:55 is it similar approach as worker.onmessage = resol
shimazu 2017/04/05 09:29:40 Yes, that's right!
+ resolve(event.data);
+ };
+ serviceworker.postMessage('');
+ });
+ })
+ .then(function(e) {
+ assert_true(e.source == 'event listener');
shimazu 2017/04/05 07:23:22 You can use assert_equals for comparison.
yiyix 2017/04/05 09:02:55 Done.
+ assert_equals(e.value, 'testError');
+
+ })
+ }, 'Error handlers inside serviceworker should see the error value');
+
+</script>

Powered by Google App Engine
This is Rietveld 408576698