| OLD | NEW |
| 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <script src="../../resources/js-test.js"></script> | 4 <script src="../../resources/js-test.js"></script> |
| 5 </head> | 5 </head> |
| 6 <body> | 6 <body> |
| 7 <script src="script-tests/URL-attribute-reflection.js"></script> | 7 <script> |
| 8 description("Test reflecting URL attributes with empty string values."); |
| 9 |
| 10 function testURLReflection(attributeName, tag, scriptAttributeName) |
| 11 { |
| 12 if (!scriptAttributeName) |
| 13 scriptAttributeName = attributeName.toLowerCase(); |
| 14 |
| 15 var element; |
| 16 if (tag === "html") |
| 17 element = document.documentElement; |
| 18 else { |
| 19 element = document.createElement(tag); |
| 20 document.body.appendChild(element); |
| 21 } |
| 22 element.setAttribute(scriptAttributeName, "x"); |
| 23 var xValue = element[attributeName]; |
| 24 element.setAttribute(scriptAttributeName, ""); |
| 25 var emptyValue = element[attributeName]; |
| 26 if (tag !== "html") |
| 27 document.body.removeChild(element); |
| 28 |
| 29 if (xValue === undefined) |
| 30 return "none"; |
| 31 if (xValue === "x") |
| 32 return "non-URL"; |
| 33 if (xValue !== document.baseURI.replace(/[^\/]+$/, "x")) |
| 34 return "error (x): " + xValue; |
| 35 if (emptyValue === "") |
| 36 return "non-empty URL"; |
| 37 if (emptyValue === document.baseURI) |
| 38 return "URL"; |
| 39 return "error (empty): " + emptyValue; |
| 40 } |
| 41 |
| 42 shouldBe("testURLReflection('attribute', 'element')", "'none'"); |
| 43 shouldBe("testURLReflection('id', 'element')", "'non-URL'"); |
| 44 |
| 45 // The following list comes from the HTML5 document’s attributes index. |
| 46 // These are the URL attributes from that list. |
| 47 |
| 48 shouldBe("testURLReflection('action', 'form')", "'URL'"); |
| 49 shouldBe("testURLReflection('cite', 'blockquote')", "'URL'"); |
| 50 shouldBe("testURLReflection('cite', 'del')", "'URL'"); |
| 51 shouldBe("testURLReflection('cite', 'ins')", "'URL'"); |
| 52 shouldBe("testURLReflection('cite', 'q')", "'URL'"); |
| 53 shouldBe("testURLReflection('data', 'object')", "'URL'"); |
| 54 shouldBe("testURLReflection('formaction', 'button')", "'URL'"); |
| 55 shouldBe("testURLReflection('formaction', 'input')", "'URL'"); |
| 56 shouldBe("testURLReflection('href', 'a')", "'URL'"); |
| 57 shouldBe("testURLReflection('href', 'area')", "'URL'"); |
| 58 shouldBe("testURLReflection('href', 'link')", "'URL'"); |
| 59 shouldBe("testURLReflection('href', 'base')", "'URL'"); |
| 60 shouldBe("testURLReflection('icon', 'command')", "'URL'"); |
| 61 shouldBe("testURLReflection('poster', 'video')", "'URL'"); |
| 62 shouldBe("testURLReflection('src', 'audio')", "'URL'"); |
| 63 shouldBe("testURLReflection('src', 'embed')", "'URL'"); |
| 64 shouldBe("testURLReflection('src', 'iframe')", "'URL'"); |
| 65 shouldBe("testURLReflection('src', 'img')", "'URL'"); |
| 66 shouldBe("testURLReflection('src', 'input')", "'URL'"); |
| 67 shouldBe("testURLReflection('src', 'script')", "'URL'"); |
| 68 shouldBe("testURLReflection('src', 'source')", "'URL'"); |
| 69 shouldBe("testURLReflection('src', 'video')", "'URL'"); |
| 70 |
| 71 // Other reflected URL attributes. |
| 72 |
| 73 shouldBe("testURLReflection('longDesc', 'img')", "'URL'"); |
| 74 shouldBe("testURLReflection('lowsrc', 'img')", "'URL'"); |
| 75 </script> |
| 8 </body> | 76 </body> |
| 9 </html> | 77 </html> |
| OLD | NEW |