| 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..617ab0d5a322f7c701a19a4f4b9593be3a088c94
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/http/tests/serviceworker/chromium/navigation-preload-origin-trial-interfaces.html
|
| @@ -0,0 +1,71 @@
|
| +<!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 interfaces =
|
| + get_interface_names(this, ['NavigationPreloadManager',
|
| + 'FetchEvent',
|
| + 'ServiceWorkerRegistration']);
|
| + console.log('Interfaces in document\n' + interfaces);
|
| +}, "Navigation preload related interfaces in Origin-Trial enabled document.");
|
| +
|
| +function check_interfaces_in_sw(t, script, scope) {
|
| + var worker;
|
| + var message;
|
| + var registration;
|
| + return service_worker_unregister_and_register(t, script, scope)
|
| + .then(reg => {
|
| + registration = reg;
|
| + worker = registration.installing;
|
| + return wait_for_state(t, worker, 'activated');
|
| + })
|
| + .then(_ => {
|
| + var saw_message = new Promise(resolve => {
|
| + navigator.serviceWorker.onmessage =
|
| + e => { resolve(e.data); };
|
| + });
|
| + worker.postMessage("");
|
| + return saw_message;
|
| + })
|
| + .then(msg => {
|
| + message = msg;
|
| + return registration.unregister();
|
| + })
|
| + .then(_ => {
|
| + return message;
|
| + });
|
| +}
|
| +
|
| +promise_test(t => {
|
| + var script =
|
| + './resources/navigation-preload-origin-trial-interfaces-worker.php';
|
| + var scope =
|
| + './resources/navigation-preload-origin-trial-interfaces-scope-normal';
|
| + return check_interfaces_in_sw(t, script, scope)
|
| + .then(message => {
|
| + console.log('Interfaces in normal Service Worker\n' + message);
|
| + });
|
| + }, "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/navigation-preload-origin-trial-interfaces-scope-enabled';
|
| + 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>
|
|
|