| Index: third_party/WebKit/LayoutTests/http/tests/serviceworker/chromium/navigation-preload-origin-trial-methods.html
|
| diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/chromium/navigation-preload-origin-trial-methods.html b/third_party/WebKit/LayoutTests/http/tests/serviceworker/chromium/navigation-preload-origin-trial-methods.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..cd493da2c3fb12d5bd1febd136fcabda6ea79513
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/http/tests/serviceworker/chromium/navigation-preload-origin-trial-methods.html
|
| @@ -0,0 +1,79 @@
|
| +<!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>
|
| +function check_methods(t, script, scope) {
|
| + var registration;
|
| + var worker;
|
| + var message;
|
| + var log = '';
|
| + return service_worker_unregister_and_register(t, script, scope)
|
| + .then(reg => {
|
| + registration = reg;
|
| + worker = registration.installing;
|
| + return wait_for_state(t, worker, 'activated');
|
| + })
|
| + .then(_ => registration.navigationPreload.disable())
|
| + .then(
|
| + result => { log += 'disable() resolved with: ' + result + '\n';},
|
| + error => { log += 'disable() rejected with: ' + error + '\n';})
|
| + .then(_ => registration.navigationPreload.enable())
|
| + .then(
|
| + result => { log += 'enable() resolved with: ' + result + '\n';},
|
| + error => { log += 'enable() rejected with: ' + error + '\n';})
|
| + .then(_ => registration.navigationPreload.getState())
|
| + .then(
|
| + result => {
|
| + log += 'getState() resolved with: ' + JSON.stringify(result) + '\n';
|
| + },
|
| + error => { log += 'getState() rejected with: ' + error + '\n';})
|
| + .then(_ => registration.navigationPreload.setHeaderValue('hello'))
|
| + .then(
|
| + result => { log += 'setHeaderValue() resolved with: ' + result + '\n';},
|
| + error => { log += 'setHeaderValue() rejected with: ' + error + '\n';})
|
| + .then(_ => with_iframe(scope))
|
| + .then(_ => {
|
| + var saw_message = new Promise(resolve => {
|
| + navigator.serviceWorker.onmessage =
|
| + e => { resolve(e.data); };
|
| + });
|
| + worker.postMessage("");
|
| + return saw_message;
|
| + })
|
| + .then(message => {
|
| + log += 'log from SW\n' + message;
|
| + return registration.unregister();
|
| + })
|
| + .then(_ => {
|
| + return log;
|
| + });
|
| +}
|
| +
|
| +promise_test(t => {
|
| + var script = 'resources/navigation-preload-origin-trial-methods-worker.php';
|
| + var scope =
|
| + 'resources/navigation-preload-origin-trial-methods-scope.php?default';
|
| + return check_methods(t, script, scope).then(log => {
|
| + console.log('--normal SW--\n' + log);
|
| + });
|
| + }, 'Calling Navigation preload related methods for normal SW.');
|
| +
|
| +promise_test(t => {
|
| + var script =
|
| + 'resources/navigation-preload-origin-trial-methods-worker.php?' +
|
| + 'origintrial=true';
|
| + var scope =
|
| + 'resources/navigation-preload-origin-trial-methods-scope.php?enabled';
|
| + return check_methods(t, script, scope).then(log => {
|
| + console.log('--Origin-Trial enabled SW--\n' + log);
|
| + });
|
| + }, 'Calling Navigation preload related methods for Origin-Trial enabled SW.');
|
| +</script>
|
|
|