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