Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(893)

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/serviceworker/chromium/navigation-preload-origin-trial-interfaces.html

Issue 2627023002: Introduce Origin-Trial for Service Worker Navigation Preload (Closed)
Patch Set: add LayoutTests Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <meta charset="utf-8">
3 <!-- Generate these token with the commands:
4 generate_token.py http://127.0.0.1:8000 ServiceWorkerNavigationPreload -expire- timestamp=2000000000
5 -->
6 <meta http-equiv="origin-trial" content="AsAA4dg2Rm+GSgnpyxxnpVk1Bk8CcE+qVBTDpPb IFNscyNRJOdqw1l0vkC4dtsGm1tmP4ZDAKwycQDzsc9xr7gMAAABmeyJvcmlnaW4iOiAiaHR0cDovLzE yNy4wLjAuMTo4MDAwIiwgImZlYXR1cmUiOiAiU2VydmljZVdvcmtlck5hdmlnYXRpb25QcmVsb2FkIiw gImV4cGlyeSI6IDIwMDAwMDAwMDB9" />
7 <title>Navigation Preload origin trial</title>
8 <script src="../../resources/testharness.js"></script>
9 <script src="../../resources/testharnessreport.js"></script>
10 <script src="../resources/test-helpers.js"></script>
11 <script src="./resources/get_interface_names.js"></script>
12 <script>
13 test(t => {
14 var intercaces =
falken 2017/01/13 03:43:41 interfaces
horo 2017/01/13 08:41:32 Done.
15 get_interface_names(this, ['NavigationPreloadManager',
16 'FetchEvent',
17 'ServiceWorkerRegistration']);
18 console.log('Interfaces in document\n' + intercaces);
19 }, "Navigation preload related interfaces in Origin-Trial enabled document.");
20
21 function check_interfaces_in_sw(t, script, scope) {
22 var worker;
23 var message;
24 return service_worker_unregister_and_register(t, script, scope)
25 .then(function(registration) {
26 worker = registration.installing;
27 return wait_for_state(t, worker, 'activated');
28 })
29 .then(function() {
30 var channel = new MessageChannel();
31 var saw_message = new Promise(function(resolve) {
32 channel.port1.onmessage = function(e) { resolve(e.data); }
33 });
34 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.
35 return saw_message;
36 })
37 .then(function(msg) {
38 message = msg;
39 return service_worker_unregister(t, scope);
40 })
41 .then(function() {
42 return message;
43 });
44 }
45
46 promise_test(t => {
47 var script =
48 './resources/navigation-preload-origin-trial-interfaces-worker.php';
49 var scope =
50 './resources/navigagion-preload-origin-trial-interfaces-scope-normal';
falken 2017/01/13 03:43:41 navigation
horo 2017/01/13 08:41:32 Done.
51 return check_interfaces_in_sw(t, script, scope)
52 .then(message => {
53 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
54 });
55 }, "Navigation preload related interfaces in normal SW.");
56
57 promise_test(t => {
58 var script =
59 './resources/navigation-preload-origin-trial-interfaces-worker.php?' +
60 'origintrial=true';
61 var scope =
62 './resources/navigagion-preload-origin-trial-interfaces-scope-enabled';
falken 2017/01/13 03:43:41 navigation
horo 2017/01/13 08:41:32 Done.
63 return check_interfaces_in_sw(t, script, scope)
64 .then(message => {
65 console.log('Interfaces in Origin-Trial enabled Service Worker\n' +
66 message);
67 });
68 }, "Navigation preload related interfaces in Origin-Trial enabled SW.");
69 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698