Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/windowclient-navigate.https.html |
| diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/windowclient-navigate.html b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/windowclient-navigate.https.html |
| similarity index 62% |
| rename from third_party/WebKit/LayoutTests/http/tests/serviceworker/windowclient-navigate.html |
| rename to third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/windowclient-navigate.https.html |
| index bde2ce831f4b5826c5d54b9ba21eee2fd3616ea2..c2764458561a56a3b9e86ca3d6f59a3f47503e2f 100644 |
| --- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/windowclient-navigate.html |
| +++ b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/windowclient-navigate.https.html |
| @@ -1,25 +1,26 @@ |
| <!DOCTYPE html> |
| <title>Service Worker: WindowClient.navigate() tests</title> |
| -<script src="../resources/testharness.js"></script> |
| -<script src="../resources/testharnessreport.js"></script> |
| -<script src="../resources/get-host-info.js"></script> |
| -<script src="resources/test-helpers.js"></script> |
| +<script src="/resources/testharness.js"></script> |
| +<script src="/resources/testharnessreport.js"></script> |
| +<script src="/common/get-host-info.sub.js"></script> |
| +<script src="resources/test-helpers.sub.js"></script> |
| <body> |
| <script> |
| +'use strict'; |
| const SCOPE = 'resources/blank.html'; |
| const SCRIPT_URL = 'resources/windowclient-navigate-worker.js'; |
| -const CROSS_ORIGIN_URL = get_host_info()['HTTP_REMOTE_ORIGIN'] + |
| - '/serviceworker/resources/blank.html'; |
| +const CROSS_ORIGIN_URL = get_host_info()['HTTPS_REMOTE_ORIGIN'] + base_path() + |
| + 'resources/blank.html'; |
| navigate_test({ |
| - description: 'normal test', |
| + description: 'normal', |
| dest_url: 'blank.html?navigate', |
| expected: normalizeURL(SCOPE) + '?navigate', |
| }); |
| navigate_test({ |
| - description: 'blank url test', |
| + description: 'blank url', |
| dest_url: '', |
| expected: normalizeURL(SCRIPT_URL) |
| }); |
| @@ -39,38 +40,38 @@ navigate_test({ |
| }); |
| navigate_test({ |
| - description: 'out scope test', |
| - src_url: 'out_scope/blank.html', |
| + description: 'out of scope', |
| + src_url: '/common/blank.html', |
| dest_url: 'blank.html?navigate', |
| expected: 'TypeError', |
| }); |
| navigate_test({ |
| - description: 'cross orgin url test', |
| + description: 'cross orgin url', |
| dest_url: CROSS_ORIGIN_URL, |
| expected: null |
| }); |
| navigate_test({ |
| - description: 'invalid url(http://[example.com]) test', |
| + description: 'invalid url (http://[example.com])', |
| dest_url: 'http://[example].com', |
| expected: 'TypeError' |
| }); |
| navigate_test({ |
| - description: 'invalid url(view-source://example.com) test', |
| + description: 'invalid url (view-source://example.com)', |
| dest_url: 'view-source://example.com', |
| expected: 'TypeError' |
| }); |
| navigate_test({ |
| - description: 'invalid url(file:///) test', |
| + description: 'invalid url (file:///)', |
| dest_url: 'file:///', |
| expected: 'TypeError' |
| }); |
| navigate_test({ |
| - description: 'invalid url(about:blank) test', |
| + description: 'invalid url (about:blank)', |
| dest_url: 'about:blank', |
| expected: 'TypeError' |
| }); |
| @@ -86,6 +87,7 @@ function navigate_test(override_parameters) { |
| scope: SCOPE, |
| should_be_reload: true |
| }; |
| + var key; |
| for (key in override_parameters) |
| parameters[key] = override_parameters[key]; |
| @@ -93,24 +95,46 @@ function navigate_test(override_parameters) { |
| promise_test(function(test) { |
| var service_worker; |
| var client_frame; |
| + var registration; |
| + var port; |
| var script_url = SCRIPT_URL; |
| // For in-scope-but-not-controlled test on installing worker, |
| // if the wait_state is "installing", then append the query to script_url. |
| - if (parameters.wait_state == 'installing') |
| + if (parameters.wait_state == 'installing') { |
| script_url += '?' + parameters.wait_state; |
| - return with_iframe(parameters.src_url) |
| + navigator.serviceWorker.addEventListener('message', function(event) { |
| + port = event.data.port; |
| + }); |
| + } |
| + |
| + var cleanup = function() { |
| + if (client_frame && client_frame) { |
| + client_frame.remove(); |
| + } |
| + |
| + if (port) { |
| + port.postMessage(''); |
|
falken
2017/05/29 04:54:08
why's this needed in cleanup? could we comment or
mike3
2017/05/29 17:00:50
Done.
|
| + } |
| + |
| + if (registration) { |
| + return registration.unregister(); |
| + } |
| + }; |
| + |
| + var body = with_iframe(parameters.src_url) |
|
falken
2017/05/29 04:54:08
Could we name this "test_promise" or something. "b
mike3
2017/05/29 17:00:50
Done.
|
| .then(function(frame) { |
| client_frame = frame; |
| return service_worker_unregister_and_register( |
| test, script_url, parameters.scope); |
| }) |
| - .then(function(registration) { |
| + .then(function(r) { |
| + registration = r; |
| service_worker = registration.installing; |
| return wait_for_state(test, service_worker, parameters.wait_state); |
| }) |
| - .then(function(state) { |
| + .then(function() { |
| if (parameters.should_be_reload) { |
| client_frame.remove(); |
| return with_iframe(parameters.src_url); |
| @@ -129,12 +153,18 @@ function navigate_test(override_parameters) { |
| }); |
| }) |
| .then(function(response) { |
| - client_frame && client_frame.remove() |
| assert_equals(response.data, parameters.expected); |
| - return service_worker_unregister_and_done(test, parameters.scope); |
| - }) |
| + }); |
| + |
| + // Ensure that test "clean up" is deferred until after the test body |
| + // executes. `Test#add_cleanup` cannot be used for this purpose because the |
| + // operation is asynchronous, and `add_cleanup` does not support |
| + // asynchronous operations at the time of this writing. Ensure also that |
|
falken
2017/05/29 04:54:08
If there's a bug to link to about add_cleanup, it'
mike3
2017/05/29 17:00:50
There wasn't but there ought to have been.
https:/
|
| + // test failure is not hidden by successful cleanup operation. |
| + return body |
| + .then(cleanup, cleanup) |
| + .then(function() { return body; }); |
| }, parameters.description); |
| } |
| - |
| </script> |
| </body> |