tizen beta release
[framework/web/webkit-efl.git] / LayoutTests / fast / dom / script-tests / boolean-attribute-reflection.js
1 description("Test reflecting boolean attributes.");
2
3 var attributes = [
4     [ "area", "noHref" ],
5     [ "dir", "compact" ],
6     [ "dl", "compact" ],
7     [ "form", "noValidate" ],
8     [ "frame", "noResize" ],
9     [ "hr", "noShade" ],
10     [ "img", "isMap" ],
11     [ "input", "autofocus" ],
12     [ "input", "defaultChecked", "checked" ],
13     [ "input", "disabled" ],
14     [ "input", "formNoValidate" ],
15     [ "input", "multiple" ],
16     [ "input", "readOnly" ],
17     [ "input", "required" ],
18     [ "link", "disabled" ],
19     [ "menu", "compact" ],
20     [ "object", "declare" ],
21     [ "ol", "compact" ],
22     [ "option", "defaultSelected", "selected" ],
23     [ "pre", "wrap" ],
24     [ "script", "defer" ],
25     [ "select", "multiple" ],
26     [ "td", "noWrap" ],
27     [ "ul", "compact" ],
28     [ "video", "autoplay" ],
29     [ "video", "controls" ],
30     [ "video", "loop" ],
31 ];
32
33 function make(tag)
34 {
35     return document.createElement(tag);
36 }
37
38 for (var i = 0; i < attributes.length; ++i) {
39     var tag = attributes[i][0];
40     var reflectingAttribute = attributes[i][1];
41     var contentAttribute = attributes[i][2] || reflectingAttribute.toLowerCase();
42     shouldBe("e = make('" + tag + "'); "
43         + "e.removeAttribute('" + contentAttribute + "'); "
44         + "e." + reflectingAttribute,
45         "false");
46     shouldBe("e = make('" + tag + "'); "
47         + "e.setAttribute('" + contentAttribute + "', ''); "
48         + "e." + reflectingAttribute,
49         "true");
50     shouldBe("e = make('" + tag + "'); "
51         + "e.setAttribute('" + contentAttribute + "', 'x'); "
52         + "e." + reflectingAttribute + " = false; "
53         + "e.getAttribute('" + contentAttribute + "')",
54         "null");
55     shouldBe("e = make('" + tag + "'); "
56         + "e.setAttribute('" + contentAttribute + "', 'x'); "
57         + "e." + reflectingAttribute + " = true; "
58         + "e.getAttribute('" + contentAttribute + "')",
59         "''");
60 }