011.html (841B)
1 <!doctype html> 2 <title>WebSockets: protocol mismatch</title> 3 <script src=/resources/testharness.js></script> 4 <script src=/resources/testharnessreport.js></script> 5 <script src=../constants.sub.js></script> 6 <meta name="variant" content="?default"> 7 <meta name="variant" content="?wss"> 8 <meta name="variant" content="?wpt_flags=h2"> 9 <div id=log></div> 10 <script> 11 async_test(function(t) { 12 // Sub-protocol matching is case-sensitive. 13 var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/handshake_protocol', 'FOOBAR'); 14 var gotOpen = false; 15 var gotError = false; 16 ws.onopen = t.step_func(function(e) { 17 gotOpen = true; 18 }); 19 ws.onerror = t.step_func(function(e) { 20 gotError = true; 21 }); 22 ws.onclose = t.step_func(function(e) { 23 assert_false(gotOpen, 'got open'); 24 assert_true(gotError, 'got error'); 25 t.done(); 26 }); 27 }); 28 </script>