darin@apple.com | ebecba8 | 2008-03-17 16:43:49 +0000 | [diff] [blame] | 1 | <html> |
mitz@apple.com | ef1d58db | 2008-06-28 17:49:23 +0000 | [diff] [blame] | 2 | <head id="head"> |
darin@apple.com | ebecba8 | 2008-03-17 16:43:49 +0000 | [diff] [blame] | 3 | <script type="text/javascript"> |
| 4 | function print(message, color) { |
| 5 | var paragraph = document.createElement("div"); |
| 6 | paragraph.appendChild(document.createTextNode(message)); |
| 7 | paragraph.style.fontFamily = "monospace"; |
| 8 | if (color) |
| 9 | paragraph.style.color = color; |
| 10 | document.getElementById("console").appendChild(paragraph); |
| 11 | } |
| 12 | |
rniwa@webkit.org | 06ad32a | 2012-06-22 08:52:23 +0000 | [diff] [blame] | 13 | if (window.testRunner) { |
| 14 | testRunner.dumpAsText(); |
darin@apple.com | ebecba8 | 2008-03-17 16:43:49 +0000 | [diff] [blame] | 15 | } |
| 16 | |
japhet@chromium.org | 59e6e21 | 2011-08-31 19:01:08 +0000 | [diff] [blame] | 17 | var results = [true, true, false, false]; |
darin@apple.com | ebecba8 | 2008-03-17 16:43:49 +0000 | [diff] [blame] | 18 | var description = ["remove src attribute of an <img> to see whether it gets loaded. (It should NOT be loaded.)", |
| 19 | "define an <img> with no src specified to see whether it gets loaded. (It should NOT be loaded.)", |
mitz@apple.com | ef1d58db | 2008-06-28 17:49:23 +0000 | [diff] [blame] | 20 | "define a <img> with src='' to see whether it gets loaded. (It should NOT be loaded, because the base URI is a local file.)", |
japhet@chromium.org | 59e6e21 | 2011-08-31 19:01:08 +0000 | [diff] [blame] | 21 | "change the base URI to an http: URL and define a <img> with src='' to see whether it gets loaded. (It should NOT be loaded.)" ] |
darin@apple.com | ebecba8 | 2008-03-17 16:43:49 +0000 | [diff] [blame] | 22 | |
| 23 | function outputResults() { |
mitz@apple.com | ef1d58db | 2008-06-28 17:49:23 +0000 | [diff] [blame] | 24 | for (index = 0; index < 4; index++) { |
darin@apple.com | ebecba8 | 2008-03-17 16:43:49 +0000 | [diff] [blame] | 25 | print("[" + index +"] " + description[index], "black"); |
mitz@apple.com | ac9ca1f | 2008-06-28 07:17:54 +0000 | [diff] [blame] | 26 | if (results[index]) |
darin@apple.com | ebecba8 | 2008-03-17 16:43:49 +0000 | [diff] [blame] | 27 | print("PASS", "green"); |
| 28 | else |
| 29 | print("FAIL", "red"); |
| 30 | } |
| 31 | } |
| 32 | </script> |
| 33 | </head> |
| 34 | <body onload="outputResults();"> |
| 35 | <p>This page tests loading image with empty src attribute.</p> |
| 36 | <hr> |
| 37 | <div id="console"></div> |
mitz@apple.com | ac9ca1f | 2008-06-28 07:17:54 +0000 | [diff] [blame] | 38 | <img id="image1" style="display:none" src="resources/test-load.jpg" onerror="results[0] = false;" /> |
| 39 | <img id="image2" style="display:none" onerror="results[1] = false;" /> |
japhet@chromium.org | 59e6e21 | 2011-08-31 19:01:08 +0000 | [diff] [blame] | 40 | <img id="image3" style="display:none" src="" onerror="results[2] = true;" /> |
darin@apple.com | ebecba8 | 2008-03-17 16:43:49 +0000 | [diff] [blame] | 41 | <script type="text/javascript"> |
| 42 | var imgNode1 = document.getElementById("image1"); |
| 43 | imgNode1.removeAttribute("src"); |
mitz@apple.com | ef1d58db | 2008-06-28 17:49:23 +0000 | [diff] [blame] | 44 | document.getElementById("head").appendChild(document.createElement("base")).setAttribute("href", "http://127.0.0.1:8888/"); |
darin@apple.com | ebecba8 | 2008-03-17 16:43:49 +0000 | [diff] [blame] | 45 | </script> |
mitz@apple.com | ef1d58db | 2008-06-28 17:49:23 +0000 | [diff] [blame] | 46 | <img id="image4" style="display:none" src="" onerror="results[3] = true;" /> |
darin@apple.com | ebecba8 | 2008-03-17 16:43:49 +0000 | [diff] [blame] | 47 | </body> |
| 48 | </html> |