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