| <html> | |
| <script> | |
| var blockedPorts = [ 1, 7, 9, 11, 13, 15, 17, 19, 20, | |
| 21, 22, 23, 25, 37, 42, 43, 53, 77, 79, 87, 95, 101, 102, | |
| 103, 104, 109, 110, 111, 113, 115, 117, 119, 123, 135, 139, | |
| 143, 179, 389, 465, 512, 513, 514, 515, 526, 530, 531, 532, | |
| 540, 556, 563, 587, 601, 636, 993, 995, 2049, 3659, 4045, | |
| 6000, 6665, 6666, 6667, 6668, 6669, | |
| // Port numbers that we consider to be invalid due to being out of range. | |
| Math.pow(2, 16) - 1, Math.pow(2, 16), Math.pow(2, 32) - 1, Math.pow(2, 32), | |
| // We don't like FTP. | |
| "ftp://255.255.255.255/test.jpg", | |
| "ftp://255.255.255.255:21/test.jpg", | |
| "ftp://255.255.255.255:22/test.jpg", | |
| ]; | |
| var allowedPorts = [0, 80, ""]; | |
| if (window.testRunner) { | |
| testRunner.waitUntilDone(); | |
| testRunner.dumpResourceLoadCallbacks(); | |
| } | |
| function loadHandler(e) { | |
| console.log("FAIL: load event fired for " + currentURL); | |
| nextURL(); | |
| } | |
| function errorHandler(e) { | |
| console.log("PASS: error event fired for " + currentURL); | |
| nextURL(); | |
| } | |
| var baseURL = "http://255.255.255.255"; | |
| var currentPort = 0; | |
| var currentURL = ""; | |
| var theImage; | |
| function nextURL() { | |
| if (currentPort < blockedPorts.length) { | |
| if (typeof blockedPorts[currentPort] === "number") | |
| currentURL = baseURL + ":" + blockedPorts[currentPort] + "/test.jpg"; | |
| else | |
| currentURL = blockedPorts[currentPort] | |
| } else if (currentPort < blockedPorts.length + allowedPorts.length) { | |
| currentURL = baseURL + ":" + allowedPorts[currentPort - blockedPorts.length] + "/test.jpg"; | |
| } else { | |
| return finishTesting(); | |
| } | |
| theImage.src = currentURL; | |
| currentPort++; | |
| } | |
| window.onload = function startTesting() { | |
| theImage = document.createElement('img'); | |
| theImage.addEventListener('error', errorHandler); | |
| theImage.addEventListener('load', errorHandler); | |
| document.body.appendChild(theImage); | |
| nextURL(); | |
| } | |
| function finishTesting() { | |
| if (window.testRunner) { | |
| testRunner.dumpAsText(); | |
| setTimeout("testRunner.notifyDone()", 0); | |
| } | |
| } | |
| </script> | |
| <body> | |
| <p>This test attempts to change the src of an IMG tag to all black listed ports to confirm that each fires an | |
| error event. It also tries the FTP ports for exemptions.</p> | |
| </p> | |
| </body> | |
| </html> |