3 <title>Original Title
</title>
4 <link rel=
"shortcut icon" type=
"image/x-icon" href=
"http://test.com/oldfavicon.ico"/>
5 <script src=
"../../resources/js-test.js"></script>
8 function setFavIcon(iconURL
) {
9 var docHead
= document
.getElementsByTagName("head")[0];
10 var links
= docHead
.getElementsByTagName("link");
11 for (var i
= 0; i
< links
.length
; ++i
) {
13 if (link
.type
=="image/x-icon" && link
.rel
=="shortcut icon") {
14 docHead
.removeChild(link
);
15 break; // Assuming only one match at most.
18 var link
= document
.createElement("link");
19 link
.type
= "image/x-icon";
20 link
.rel
= "shortcut icon";
22 docHead
.appendChild(link
);
26 if (window
.testRunner
)
27 testRunner
.dumpAsText();
29 iconURL
= document
.getElementsByTagName("head")[0].getElementsByTagName("link")[0].href
;
30 debug('Original iconURL is: ' + iconURL
);
32 // change icon to new icon
33 newURL
= 'http://test.com/newfavicon.ico';
34 debug('Setting new icon URL to: ' + newURL
);
36 iconURL
= document
.getElementsByTagName("link")[0].href
;
37 debug('New iconURL is: ' + iconURL
);
39 // change icon back to old icon and ensure it changes properly
40 oldURL
= 'http://test.com/oldfavicon.ico';
41 debug('Setting icon URL back to: ' + oldURL
);
43 iconURL
= document
.getElementsByTagName("link")[0].href
;
44 debug('Original iconURL is still: ' + iconURL
);
46 // check that the URL list in the document is as we expect
47 var expectedURLs
= "http://test.com/oldfavicon.ico";
48 var iconURLs
= window
.internals
.shortcutIconURLs(document
);
49 if (expectedURLs
== iconURLs
[0])
50 testPassed('URL list matches expected');
52 testFailed('URL list does not match expected');
57 <body onload='runTests();'
>