1 description("Test reflecting URL attributes with empty string values.");
3 function testURLReflection(attributeName, tag, scriptAttributeName)
5 if (!scriptAttributeName)
6 scriptAttributeName = attributeName.toLowerCase();
10 element = document.documentElement;
12 element = document.createElement(tag);
13 document.body.appendChild(element);
15 element.setAttribute(scriptAttributeName, "x");
16 var xValue = element[attributeName];
17 element.setAttribute(scriptAttributeName, "");
18 var emptyValue = element[attributeName];
20 document.body.removeChild(element);
22 if (xValue === undefined)
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)
32 return "error (empty): " + emptyValue;
35 shouldBe("testURLReflection('attribute', 'element')", "'none'");
36 shouldBe("testURLReflection('id', 'element')", "'non-URL'");
38 // The following list comes from the HTML5 document’s attributes index.
39 // These are the URL attributes from that list.
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('manifest', 'html')", "'URL'");
55 shouldBe("testURLReflection('poster', 'video')", "'URL'");
56 shouldBe("testURLReflection('src', 'audio')", "'URL'");
57 shouldBe("testURLReflection('src', 'embed')", "'URL'");
58 shouldBe("testURLReflection('src', 'iframe')", "'URL'");
59 shouldBe("testURLReflection('src', 'img')", "'URL'");
60 shouldBe("testURLReflection('src', 'input')", "'URL'");
61 shouldBe("testURLReflection('src', 'script')", "'URL'");
62 shouldBe("testURLReflection('src', 'source')", "'URL'");
63 shouldBe("testURLReflection('src', 'video')", "'URL'");
65 // Other reflected URL attributes.
67 shouldBe("testURLReflection('longDesc', 'img')", "'URL'");
68 shouldBe("testURLReflection('lowsrc', 'img')", "'URL'");