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

Unified Diff: LayoutTests/http/tests/serviceworker/update-error.html

Issue 1268663003: Service Worker: Make ServiceWorkerRegistration.update() return a promise. (Blink Layout 3/3) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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
Index: LayoutTests/http/tests/serviceworker/update-error.html
diff --git a/LayoutTests/http/tests/serviceworker/update-error.html b/LayoutTests/http/tests/serviceworker/update-error.html
new file mode 100644
index 0000000000000000000000000000000000000000..b9950e05310e784008c5dc90a7f06523038179ae
--- /dev/null
+++ b/LayoutTests/http/tests/serviceworker/update-error.html
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<title>Service Worker: ServiceWorkerRegistration.update() error.</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) {
nhiroki 2015/08/06 09:57:28 How about merging this test into serviceworker/upd
jungkees 2015/08/06 10:53:12 Okay. I'll upload a new snapshot when I'm ready wi
+ var scope = 'resources/scope/update';
+ var worker_url = 'resources/update-worker-error.php';
+ var expected_url = normalizeURL(worker_url);
+ var registration;
+
+ return service_worker_unregister_and_register(t, worker_url, scope)
+ .then(function(r) {
+ registration = r;
+ return wait_for_state(t, registration.installing, 'activated');
+ })
+ .then(function() {
+ assert_equals(registration.installing, null,
+ 'installing should be null in the initial state.');
+ assert_equals(registration.waiting, null,
+ 'waiting should be null in the initial state.');
+ assert_equals(registration.active.scriptURL, expected_url,
+ 'active should exist in the initial state.');
+
+ // A new worker(generated by update-worker-error.php) should be found.
+ // The returned promise should reject as update-worker-error.php sets
+ // the mimetype to disallowed value.
+ return registration.update();
+ })
+ .catch(function(e) {
+ assert_throws("SecurityError", function() { throw e; },
+ 'Using a disallowed mimetype should make update() ' +
+ 'promise reject with a SecurityError.');
+ });
+ }, 'Update a registration caught an error.');
+</script>

Powered by Google App Engine
This is Rietveld 408576698