websocket.https.html (1728B)
1 <!DOCTYPE html> 2 <title>Service Worker: WebSocket handshake channel is not intercepted</title> 3 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharnessreport.js"></script> 5 <script src="/common/get-host-info.sub.js"></script> 6 <script src="resources/test-helpers.sub.js?pipe=sub"></script> 7 <script> 8 9 promise_test(function(t) { 10 var path = new URL(".", window.location).pathname 11 var url = 'resources/websocket.js'; 12 var scope = 'resources/blank.html?websocket'; 13 var host_info = get_host_info(); 14 var frameURL = host_info['HTTPS_ORIGIN'] + path + scope; 15 var frame; 16 17 return service_worker_unregister_and_register(t, url, scope) 18 .then(function(registration) { 19 t.add_cleanup(function() { 20 return service_worker_unregister(t, scope); 21 }); 22 23 return wait_for_state(t, registration.installing, 'activated'); 24 }) 25 .then(function() { return with_iframe(frameURL); }) 26 .then(function(f) { 27 frame = f; 28 return websocket(t, frame); 29 }) 30 .then(function() { 31 var channel = new MessageChannel(); 32 return new Promise(function(resolve) { 33 channel.port1.onmessage = resolve; 34 frame.contentWindow.navigator.serviceWorker.controller.postMessage({port: channel.port2}, [channel.port2]); 35 }); 36 }) 37 .then(function(e) { 38 for (var url in e.data.urls) { 39 assert_equals(url.indexOf(get_websocket_url()), -1, 40 "Observed an unexpected FetchEvent for the WebSocket handshake"); 41 } 42 frame.remove(); 43 }); 44 }, 'Verify WebSocket handshake channel does not get intercepted'); 45 </script>