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 55% |
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..8fb467a3f9bf81be9af270857a8fedc392492aa4 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,52 @@ function navigate_test(override_parameters) { |
promise_test(function(test) { |
var service_worker; |
var client_frame; |
+ var registration; |
+ var pausedLifecyclePort; |
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) { |
+ pausedLifecyclePort = event.data.port; |
+ }); |
+ } |
+ |
+ var cleanup = function() { |
+ if (client_frame && client_frame) { |
+ client_frame.remove(); |
+ } |
+ |
+ // Some tests require that the worker remain in a given lifecycle phase. |
+ // "Clean up" logic for these tests requires signaling the worker to |
+ // release the hold; this allows the worker to be properly discarded |
+ // prior to the execution of additional tests. |
+ if (pausedLifecyclePort) { |
+ // The value of the posted message is inconsequential. A string is |
+ // specified here solely to aid in test debugging. |
+ pausedLifecyclePort.postMessage('continue lifecycle'); |
falken
2017/05/30 01:11:01
Thanks for the comments and explanation!
|
+ } |
+ |
+ if (registration) { |
+ return registration.unregister(); |
+ } |
+ }; |
+ |
+ var test_body = with_iframe(parameters.src_url) |
.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 +159,20 @@ 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. See |
+ // https://github.com/w3c/web-platform-tests/issues/6075 |
+ // Ensure also that test failure is not hidden by successful cleanup |
+ // operation. |
+ return test_body |
+ .then(cleanup, cleanup) |
+ .then(function() { return test_body; }); |
}, parameters.description); |
} |
- |
</script> |
</body> |