Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / icon-url-property.html
blobff71712e93a10e9336922d1551f79612aaa997d1
1 <html>
2 <head>
3 <title>Original Title</title>
4 <link rel="shortcut icon" type="image/x-icon" href="http://test.com/oldfavicon.ico"/>
5 <script>
6 function debugOutput(str) {
7 text = document.createTextNode(str);
8 debugDiv = document.getElementById('debugDiv');
9 div = document.createElement ('div');
10 div.appendChild(text);
11 debugDiv.appendChild(div);
14 function createFavIconElement(iconURL) {
15 var link = document.createElement("link");
16 link.type = "image/x-icon";
17 link.rel = "shortcut icon";
18 link.href = iconURL;
19 return link;
22 function getHeadElement() {
23 return document.getElementsByTagName("head")[0];
26 function setFavIcon(iconURL) {
27 var docHead = getHeadElement();
28 var links = docHead.getElementsByTagName("link");
29 for (var i = 0; i < links.length; ++i) {
30 var link = links[i];
31 if (link.type=="image/x-icon" && link.rel=="shortcut icon") {
32 docHead.removeChild(link);
33 break; // Assuming only one match at most.
36 docHead.appendChild(createFavIconElement(iconURL));
39 function runTests() {
40 if (window.testRunner) {
41 testRunner.dumpAsText();
42 if (testRunner.dumpIconChanges)
43 testRunner.dumpIconChanges();
46 iconURL = document.getElementsByTagName("head")[0].getElementsByTagName("link")[0].href;
47 debugOutput ('Original iconURL is: ' + iconURL);
48 newURL = 'http://test.com/newfavicon.ico';
49 debugOutput ('Setting new icon URL to: ' + newURL);
50 setFavIcon(newURL);
51 iconURL = document.getElementsByTagName("head")[0].getElementsByTagName("link")[0].href;
53 debugOutput ('New iconURL is: ' + iconURL);
55 // check that the URL list in the document is as we expect
56 var expectedURLs = "http://test.com/newfavicon.ico";
57 var iconURLs = window.internals.shortcutIconURLs(document);
58 if (expectedURLs == iconURLs[0])
59 debugOutput('PASS - URL list matches expected');
60 else
61 debugOutput('FAIL - URL list does not match expected');
63 // Add some more fav icons to verify that didChangeIcons gets called.
64 var docHead = getHeadElement();
65 docHead.insertBefore(createFavIconElement("http://example.org/icon1.ico"), docHead.firstChild);
66 docHead.appendChild(createFavIconElement("http://example.org/icon2.ico"));
69 </script>
70 </head>
71 <body onload='runTests();'>
72 <div id='debugDiv'>
73 </div>
74 </body>
75 </html>