Index: third_party/WebKit/LayoutTests/imported/wpt/service-workers/service-worker/update.https.html |
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/update.html b/third_party/WebKit/LayoutTests/imported/wpt/service-workers/service-worker/update.https.html |
similarity index 75% |
copy from third_party/WebKit/LayoutTests/http/tests/serviceworker/update.html |
copy to third_party/WebKit/LayoutTests/imported/wpt/service-workers/service-worker/update.https.html |
index 82db1920d86ac8be8453caa4023f5ee6edefd8b0..213b72ac837309d43112d7965a17e2162e7ffb9b 100644 |
--- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/update.html |
+++ b/third_party/WebKit/LayoutTests/imported/wpt/service-workers/service-worker/update.https.html |
@@ -1,14 +1,16 @@ |
<!DOCTYPE html> |
<title>Service Worker: Registration update()</title> |
-<script src="../resources/testharness.js"></script> |
-<script src="../resources/testharnessreport.js"></script> |
-<script src="resources/test-helpers.js"></script> |
+<script src="/resources/testharness.js"></script> |
+<script src="/resources/testharnessreport.js"></script> |
+<script src="resources/testharness-helpers.js"></script> |
+<script src="resources/test-helpers.sub.js"></script> |
<script> |
promise_test(function(t) { |
- var scope = 'resources/scope/update'; |
- var worker_url = 'resources/update-worker.php'; |
+ var scope = 'resources/simple.txt'; |
+ var worker_url = 'resources/update-worker.py'; |
var expected_url = normalizeURL(worker_url); |
var registration; |
+ var iframe; |
return service_worker_unregister_and_register(t, worker_url, scope) |
.then(function(r) { |
registration = r; |
@@ -21,8 +23,7 @@ promise_test(function(t) { |
'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.php) should be found. |
+ // A new worker (generated by update-worker.py) should be found. |
// The returned promise should resolve when a new worker script is |
// fetched and starts installing. |
return Promise.all([registration.update(), |
@@ -40,11 +41,13 @@ promise_test(function(t) { |
.then(function() { |
assert_equals(registration.installing, null, |
'installing should be null after installing.'); |
- assert_equals(registration.waiting.scriptURL, expected_url, |
- 'waiting should be set after installing.'); |
- assert_equals(registration.active.scriptURL, expected_url, |
- 'active should still exist after installing.'); |
- return wait_for_state(t, registration.waiting, 'activated'); |
+ if (registration.waiting) { |
+ assert_equals(registration.waiting.scriptURL, expected_url, |
+ 'waiting should be set after installing.'); |
+ assert_equals(registration.active.scriptURL, expected_url, |
+ 'active should still exist after installing.'); |
+ return wait_for_state(t, registration.waiting, 'activated'); |
+ } |
}) |
.then(function() { |
assert_equals(registration.installing, null, |
@@ -55,8 +58,8 @@ promise_test(function(t) { |
'new worker should be promoted to active.'); |
}) |
.then(function() { |
- // A new worker(generated by update-worker.php) should be found. |
- // The returned promise should reject as update-worker.php sets the |
+ // A new worker(generated by update-worker.py) should be found. |
+ // The returned promise should reject as update-worker.py sets the |
// mimetype to a disallowed value for this attempt. |
return registration.update(); |
}) |
@@ -92,11 +95,11 @@ promise_test(function(t) { |
}) |
.then(function() { |
assert_equals(registration.installing.scriptURL, expected_url, |
- 'installing should be set after update resolves (throw-install).'); |
+ 'new installing should be set after update resolves.'); |
assert_equals(registration.waiting, null, |
- 'waiting should still be null after update resolves (throw-install).'); |
+ 'waiting should be null after activated.'); |
assert_equals(registration.active.scriptURL, expected_url, |
- 'active should still exist after update found (throw-install).'); |
+ 'active should still exist after update found.'); |
// We need to hold a client alive so that unregister() below doesn't |
// remove the registration before update() has had a chance to look |
@@ -104,16 +107,17 @@ promise_test(function(t) { |
return with_iframe(scope); |
}) |
.then(function(frame) { |
- return Promise.all([registration.unregister(), |
- registration.update()]); |
+ iframe = frame; |
+ |
+ return assert_promise_rejects( |
+ Promise.all([registration.unregister(), registration.update()]), |
+ new TypeError(), |
+ 'Calling update() while the uninstalling flag is set ' + |
+ 'should return a promise that rejects with a TypeError.'); |
}) |
- .then( |
- function() { assert_unreached("update() should reject."); }, |
- function(e) { |
- assert_throws({name: 'TypeError'}, function () { throw e; }, |
- 'Calling update() while the uninstalling flag is ' + |
- 'set should return a promise that rejects with an ' + |
- 'TypeError.'); |
+ .then(function() { |
+ iframe.remove(); |
+ return t.done(); |
}); |
}, 'Update a registration.'); |
</script> |