Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/http/tests/serviceworker/claim-with-redirect.html |
| diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/claim-with-redirect.html b/third_party/WebKit/LayoutTests/http/tests/serviceworker/claim-with-redirect.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..3b307e1d6db7ae54eb98b9236f397030cf7065ff |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/http/tests/serviceworker/claim-with-redirect.html |
| @@ -0,0 +1,66 @@ |
| +<!DOCTYPE html> |
| +<title>Service Worker: Claim() when update happens after redirect</title> |
| +<script src="../resources/get-host-info.js"></script> |
| +<script src="../resources/testharness.js"></script> |
| +<script src="../resources/testharnessreport.js"></script> |
| +<script src="resources/test-helpers.js"></script> |
| +<body> |
| +<script> |
| +var host_info = get_host_info(); |
| +var BASE_URL = host_info['HTTP_ORIGIN'] + base_path(); |
| +var OTHER_BASE_URL = host_info['HTTP_REMOTE_ORIGIN'] + base_path(); |
| + |
| +var WORKER_URL = OTHER_BASE_URL + 'resources/update-claim-worker.php' |
| +var SCOPE_URL = OTHER_BASE_URL + 'resources/redirect.php' |
| +var OTHER_IFRAME_URL = OTHER_BASE_URL |
| + + 'resources/claim-with-redirect-iframe.html'; |
| + |
| +/* Different origin from the registration */ |
|
nhiroki
2016/08/19 05:26:51
"//" is more common than "/**/" in our layout test
shimazu
2016/08/19 09:43:15
Done.
|
| +var REDIRECT_TO_URL = BASE_URL |
| + + 'resources/claim-with-redirect-iframe.html?redirected'; |
|
nhiroki
2016/08/19 05:26:52
'+' operator should be placed at the end of the pr
shimazu
2016/08/19 09:43:15
Done.
|
| + |
| +var REGISTER_IFRAME_URL = OTHER_IFRAME_URL + '?register=' |
| + + encodeURIComponent(WORKER_URL) + '&' |
| + + 'scope=' + encodeURIComponent(SCOPE_URL); |
| +var REDIRECT_IFRAME_URL = SCOPE_URL + '?Redirect=' |
| + + encodeURIComponent(REDIRECT_TO_URL); |
| +var UPDATE_IFRAME_URL = OTHER_IFRAME_URL + '?update=' |
| + + encodeURIComponent(SCOPE_URL); |
| +var UNREGISTER_IFRAME_URL = OTHER_IFRAME_URL + '?unregister=' |
| + + encodeURIComponent(SCOPE_URL); |
| + |
| +var waiting_resolver = undefined; |
| + |
| +addEventListener('message', function(e) { |
| + console.log('onmessage: ', e.data); |
|
nhiroki
2016/08/19 05:26:52
Can you remove this debug log?
shimazu
2016/08/19 09:43:15
Oops, done.
|
| + if (waiting_resolver !== undefined) { |
| + waiting_resolver(e.data); |
| + } |
| + }); |
| + |
| + |
|
nhiroki
2016/08/19 05:26:51
nit: There is an extra line.
shimazu
2016/08/19 09:43:15
Done.
|
| +function assert_with_iframe(url, message) { |
| + return new Promise(function(resolve) { |
| + waiting_resolver = resolve; |
| + with_iframe(url); |
| + }) |
| + .then(function(data) { |
|
nhiroki
2016/08/19 05:26:52
I suspect |data| is undefined because the previous
shimazu
2016/08/19 09:43:15
My aim was that waiting_resolver will be resolved
nhiroki
2016/08/19 14:32:53
You're right. Sorry, I misread this part :p
|
| + assert_equals(data.message, message); |
| + }); |
| +} |
| + |
| +promise_test(function(t) { |
| + return assert_with_iframe(REGISTER_IFRAME_URL, 'registered') |
| + .then(function() { |
| + return assert_with_iframe(REDIRECT_IFRAME_URL, 'redirected'); |
| + }) |
| + .then(function() { |
| + return assert_with_iframe(UPDATE_IFRAME_URL, 'updated'); |
| + }) |
| + .then(function() { |
| + return assert_with_iframe(UNREGISTER_IFRAME_URL, 'unregistered'); |
| + }); |
| + }, 'Claim works after redirection to another origin'); |
| + |
| +</script> |
| +</body> |