Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/http/tests/serviceworker/chromium/navigation-preload-origin-trial-interfaces.html |
| diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/chromium/navigation-preload-origin-trial-interfaces.html b/third_party/WebKit/LayoutTests/http/tests/serviceworker/chromium/navigation-preload-origin-trial-interfaces.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b33a7c52524ce55f475ed7d7363f2ec77cd1aeaf |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/http/tests/serviceworker/chromium/navigation-preload-origin-trial-interfaces.html |
| @@ -0,0 +1,69 @@ |
| +<!DOCTYPE html> |
| +<meta charset="utf-8"> |
| +<!-- Generate these token with the commands: |
| +generate_token.py http://127.0.0.1:8000 ServiceWorkerNavigationPreload -expire-timestamp=2000000000 |
| +--> |
| +<meta http-equiv="origin-trial" content="AsAA4dg2Rm+GSgnpyxxnpVk1Bk8CcE+qVBTDpPbIFNscyNRJOdqw1l0vkC4dtsGm1tmP4ZDAKwycQDzsc9xr7gMAAABmeyJvcmlnaW4iOiAiaHR0cDovLzEyNy4wLjAuMTo4MDAwIiwgImZlYXR1cmUiOiAiU2VydmljZVdvcmtlck5hdmlnYXRpb25QcmVsb2FkIiwgImV4cGlyeSI6IDIwMDAwMDAwMDB9" /> |
| +<title>Navigation Preload origin trial</title> |
| +<script src="../../resources/testharness.js"></script> |
| +<script src="../../resources/testharnessreport.js"></script> |
| +<script src="../resources/test-helpers.js"></script> |
| +<script src="./resources/get_interface_names.js"></script> |
| +<script> |
| +test(t => { |
| + var intercaces = |
|
falken
2017/01/13 03:43:41
interfaces
horo
2017/01/13 08:41:32
Done.
|
| + get_interface_names(this, ['NavigationPreloadManager', |
| + 'FetchEvent', |
| + 'ServiceWorkerRegistration']); |
| + console.log('Interfaces in document\n' + intercaces); |
| +}, "Navigation preload related interfaces in Origin-Trial enabled document."); |
| + |
| +function check_interfaces_in_sw(t, script, scope) { |
| + var worker; |
| + var message; |
| + return service_worker_unregister_and_register(t, script, scope) |
| + .then(function(registration) { |
| + worker = registration.installing; |
| + return wait_for_state(t, worker, 'activated'); |
| + }) |
| + .then(function() { |
| + var channel = new MessageChannel(); |
| + var saw_message = new Promise(function(resolve) { |
| + channel.port1.onmessage = function(e) { resolve(e.data); } |
| + }); |
| + worker.postMessage({port: channel.port2}, [channel.port2]); |
|
falken
2017/01/13 03:43:41
nit: No need to use MessageChannel. Just do worker
horo
2017/01/13 08:41:33
Done.
|
| + return saw_message; |
| + }) |
| + .then(function(msg) { |
| + message = msg; |
| + return service_worker_unregister(t, scope); |
| + }) |
| + .then(function() { |
| + return message; |
| + }); |
| +} |
| + |
| +promise_test(t => { |
| + var script = |
| + './resources/navigation-preload-origin-trial-interfaces-worker.php'; |
| + var scope = |
| + './resources/navigagion-preload-origin-trial-interfaces-scope-normal'; |
|
falken
2017/01/13 03:43:41
navigation
horo
2017/01/13 08:41:32
Done.
|
| + return check_interfaces_in_sw(t, script, scope) |
| + .then(message => { |
| + console.log('Interfaces in normal Service Worker\n' + message); |
|
falken
2017/01/13 03:43:41
(As talked in person, my instinct was to move the
horo
2017/01/13 08:41:33
Unfortunately it's impossible.
The body content wi
|
| + }); |
| + }, "Navigation preload related interfaces in normal SW."); |
| + |
| +promise_test(t => { |
| + var script = |
| + './resources/navigation-preload-origin-trial-interfaces-worker.php?' + |
| + 'origintrial=true'; |
| + var scope = |
| + './resources/navigagion-preload-origin-trial-interfaces-scope-enabled'; |
|
falken
2017/01/13 03:43:41
navigation
horo
2017/01/13 08:41:32
Done.
|
| + return check_interfaces_in_sw(t, script, scope) |
| + .then(message => { |
| + console.log('Interfaces in Origin-Trial enabled Service Worker\n' + |
| + message); |
| + }); |
| + }, "Navigation preload related interfaces in Origin-Trial enabled SW."); |
| +</script> |