Index: LayoutTests/http/tests/inspector/websocket/websocket-handshake.html |
diff --git a/LayoutTests/http/tests/inspector/websocket/websocket-handshake.html b/LayoutTests/http/tests/inspector/websocket/websocket-handshake.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..7f4c5582821c076d785d5ee9e6ee8f5904bb8131 |
--- /dev/null |
+++ b/LayoutTests/http/tests/inspector/websocket/websocket-handshake.html |
@@ -0,0 +1,65 @@ |
+<html> |
+<head> |
+<script src="../inspector-test.js"></script> |
+<script src="/js-test-resources/js-test.js"></script> |
+<script> |
+var ws; |
+function sendMessages() { |
+ ws = new WebSocket('ws://localhost:8880/duplicated-headers'); |
+ ws.onopen = function() { |
+ debug('onopen'); |
+ }; |
+} |
+ |
+ |
+function test() { |
+ function outputHeaders(name, headers) { |
+ var headersToOutput = []; |
+ for (var i = 0; i < headers.length; ++i) { |
+ if (headers[i].name === 'Sec-WebSocket-Key' || |
+ headers[i].name == 'Sec-WebSocket-Accept' || |
+ headers[i].name == 'User-Agent') { |
+ // We hide the header value of these headers because |
+ // they can be flaky or platform dependent. |
+ headersToOutput.push({name: headers[i].name, value: '***'}); |
+ } else { |
+ headersToOutput.push(headers[i]); |
+ } |
+ } |
+ headersToOutput.sort(function(x, y) { |
+ function compare(x, y) { |
+ if (x < y) { |
+ return -1; |
+ } else if (x === y) { |
+ return 0; |
+ } else { |
+ return 1; |
+ } |
+ } |
+ return x.name === y.name ? compare(x.value, y.value) : compare(x.name, y.name); |
+ }); |
+ console.log(name); |
+ for (var i = 0; i < headersToOutput.length; ++i) { |
+ console.log(' ' + headersToOutput[i].name + ': ' + headersToOutput[i].value); |
+ } |
+ } |
+ function onRequest(event) { |
+ if (event.data.statusCode === 101) { |
+ console.log('requestMethod: ' + event.data.requestMethod); |
+ outputHeaders('requestHeaders', event.data.requestHeaders()); |
+ console.log('statusCode: ' + event.data.statusCode); |
+ console.log('statusText: ' + event.data.statusText); |
+ outputHeaders('responseHeaders', event.data.responseHeaders); |
+ InspectorTest.completeTest(); |
+ } |
+ } |
+ console.log(WebInspector.Network); |
+ WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.RequestUpdated, onRequest); |
+ InspectorTest.evaluateInPage('sendMessages()'); |
+} |
+</script> |
+</head> |
+<body onload="runTest()"> |
+<p>Tests that WebSocket handshake information is passed to Web Inspector.</p> |
+</body> |
+</html> |