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";
9 paragraph.style.color = color;
10 document.getElementById("console").appendChild(paragraph);
13 if (window.layoutTestController) {
14 layoutTestController.dumpAsText();
17 var results = [true, true, false, false];
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.)",
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.)",
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.)" ]
23 function outputResults() {
24 for (index = 0; index < 4; index++) {
25 print("[" + index +"] " + description[index], "black");
27 print("PASS", "green");
34 <body onload="outputResults();">
35 <p>This page tests loading image with empty src attribute.</p>
37 <div id="console"></div>
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;" />
40 <img id="image3" style="display:none" src="" onerror="results[2] = true;" />
41 <script type="text/javascript">
42 var imgNode1 = document.getElementById("image1");
43 imgNode1.removeAttribute("src");
44 document.getElementById("head").appendChild(document.createElement("base")).setAttribute("href", "http://127.0.0.1:8888/");
46 <img id="image4" style="display:none" src="" onerror="results[3] = true;" />