| OLD | NEW |
| (Empty) |
| 1 <html> | |
| 2 <head> | |
| 3 <script src="inspector-test.js"></script> | |
| 4 <script src="console-test.js"></script> | |
| 5 <script> | |
| 6 var testFunctions = [testDNSLookup, testSSLCertificate]; | |
| 7 var nextTestIndex = 0; | |
| 8 | |
| 9 function onload() | |
| 10 { | |
| 11 if (window.testRunner) | |
| 12 testRunner.waitUntilDone(); | |
| 13 if (!window.WebSocket) { | |
| 14 console.log("WebSocket is not supported."); return; | |
| 15 } | |
| 16 doNextTest(); | |
| 17 } | |
| 18 | |
| 19 function doNextTest() | |
| 20 { | |
| 21 if (nextTestIndex == testFunctions.length) { | |
| 22 runTest(); | |
| 23 return; | |
| 24 } | |
| 25 var testFunction = testFunctions[nextTestIndex]; | |
| 26 nextTestIndex++; | |
| 27 testFunction(); | |
| 28 } | |
| 29 | |
| 30 function testDNSLookup() | |
| 31 { | |
| 32 console.log("testDNSLookup: Test started."); | |
| 33 var ws = new WebSocket("ws://nonexistent.domain.invalid/"); // Network error
should be logged to console. | |
| 34 ws.onopen = function() { | |
| 35 console.log("testDNSLookup: onopen is called."); | |
| 36 ws.close(); | |
| 37 }; | |
| 38 ws.onerror = function() { | |
| 39 console.log("testDNSLookup: onerror is called."); | |
| 40 ws.close(); | |
| 41 }; | |
| 42 ws.onclose = function() { | |
| 43 console.log("testDNSLookup: onclose is called."); | |
| 44 doNextTest(); | |
| 45 }; | |
| 46 } | |
| 47 | |
| 48 function testSSLCertificate() | |
| 49 { | |
| 50 console.log("testSSLCertificate: Test started."); | |
| 51 // The following statement should cause "Untrusted root certificate" error. | |
| 52 // Note that port 8443 serves HTTPS content rather than secure WebSocket, | |
| 53 // but it does not matter because the test does not send or receive any payl
oad. | |
| 54 var ws = new WebSocket("wss://127.0.0.1:8443/"); | |
| 55 ws.onopen = function() { | |
| 56 console.log("testSSLCertificate: onopen is called."); | |
| 57 ws.close(); | |
| 58 }; | |
| 59 ws.onerror = function() { | |
| 60 console.log("testSSLCertificate: onerror is called."); | |
| 61 ws.close(); | |
| 62 }; | |
| 63 ws.onclose = function() { | |
| 64 console.log("testSSLCertificate: onclose is called."); | |
| 65 doNextTest(); | |
| 66 }; | |
| 67 } | |
| 68 | |
| 69 function test() | |
| 70 { | |
| 71 InspectorTest.dumpConsoleMessages(); | |
| 72 InspectorTest.completeTest(); | |
| 73 } | |
| 74 | |
| 75 </script> | |
| 76 </head> | |
| 77 | |
| 78 <body onload="onload()"> | |
| 79 <p> | |
| 80 WebSocket's network errors should be logged to console. | |
| 81 </p> | |
| 82 | |
| 83 </body> | |
| 84 </html> | |
| OLD | NEW |