fd75b22a520395fdb464881e55c407386eb737bb
[WebKit-https.git] / LayoutTests / fast / dom / tabindex-defaults.html
1 <!DOCTYPE HTML><!-- webkit-test-runner [ enableKeygenElement=true ] -->
2 <html>
3 <head>
4 <script src="../../resources/js-test-pre.js"></script>
5 </head>
6 <body>
7 <div id="container">
8 <!-- Focusable elements -->
9 <a id="anchor" href="tabindex-defaults.html">anchor</a>
10 <iframe id="iframe"></iframe>
11 <object id="object"></object>
12 <button id="button">button</button>
13 <input id="input">
14 <select id="select"></select>
15 <textarea id="textarea"></textarea>
16 <keygen id="keygen"></keygen>
17 <div id="editableDiv" contenteditable="true"></div>
18 <details><summary id="activeSummary"></summary></details>
19
20 <!-- Unfocusable element -->
21 <div id="normalDiv"></div>
22 <output id="output"></output>
23 <fieldset id="fieldset"></fieldset>
24 <video id="video"></video>
25 <video id="videoWithControls" controls></video>
26 <details><summary></summary><summary id="summary"></summary></details>
27 <iframe id="iframeForDesignMode"></iframe>
28 <svg><g id="g" onfocus="alert('fail')"></g></svg>
29 </div>
30
31 <script>
32 description('Default value of tabIndex IDL attribute');
33
34 var anchor = document.getElementById('anchor');
35 var iframe = document.getElementById('iframe');
36 iframe.contentDocument.open();
37 iframe.contentDocument.write('<!DOCTYPE><html><frameset cols="50%,50%"><frame></frame></frameset>');
38 var frame = iframe.contentDocument.querySelector('frame');
39 var object = document.getElementById('object');
40 var button = document.getElementById('button');
41 var input = document.getElementById('input');
42 var select = document.getElementById('select');
43 var textarea = document.getElementById('textarea');
44 var keygen = document.getElementById('keygen');
45 var editableDiv = document.getElementById('editableDiv');
46 var normalDiv = document.getElementById('normalDiv');
47 var output = document.getElementById('output');
48 var fieldset = document.getElementById('fieldset');
49 var video = document.getElementById('video');
50 var videoWithControls = document.getElementById('videoWithControls');
51 var summary = document.getElementById('summary');
52 var activeSummary = document.getElementById('activeSummary');
53 var iframeForDesignMode = document.getElementById('iframeForDesignMode');
54 iframeForDesignMode.contentDocument.designMode = 'on';
55 var bodyInDesignMode = iframeForDesignMode.contentDocument.body;
56 var g = document.getElementById('g');
57
58 shouldBe('anchor.tabIndex', '0');
59 shouldBe('iframe.tabIndex', '0');
60 shouldBe('frame.tabIndex', '0');
61 shouldBe('object.tabIndex', '0');
62 shouldBe('button.tabIndex', '0');
63 shouldBe('input.tabIndex', '0');
64 shouldBe('select.tabIndex', '0');
65 shouldBe('textarea.tabIndex', '0');
66 shouldBe('keygen.tabIndex', '0');
67 shouldBe('activeSummary.tabIndex', '0');
68 shouldBe('editableDiv.tabIndex', '-1');
69 shouldBe('normalDiv.tabIndex', '-1');
70 shouldBe('output.tabIndex', '-1');
71 shouldBe('fieldset.tabIndex', '-1');
72 shouldBe('video.tabIndex', '-1');
73 shouldBe('videoWithControls.tabIndex', '-1');
74 shouldBe('summary.tabIndex', '-1');
75 shouldBe('bodyInDesignMode.tabIndex', '-1');
76 shouldBe('g.tabIndex', '-1');
77
78 shouldBe('anchor.setAttribute("tabindex", "invalid"); anchor.tabIndex', '0');
79 shouldBe('iframe.setAttribute("tabindex", "invalid"); iframe.tabIndex', '0');
80 shouldBe('frame.setAttribute("tabindex", "invalid"); frame.tabIndex', '0');
81 shouldBe('object.setAttribute("tabindex", "invalid"); object.tabIndex', '0');
82 shouldBe('button.setAttribute("tabindex", "invalid"); button.tabIndex', '0');
83 shouldBe('input.setAttribute("tabindex", "invalid"); input.tabIndex', '0');
84 shouldBe('select.setAttribute("tabindex", "invalid"); select.tabIndex', '0');
85 shouldBe('textarea.setAttribute("tabindex", "invalid"); textarea.tabIndex', '0');
86 shouldBe('keygen.setAttribute("tabindex", "invalid"); keygen.tabIndex', '0');
87 shouldBe('activeSummary.setAttribute("tabindex", "invalid"); activeSummary.tabIndex', '0');
88 shouldBe('editableDiv.setAttribute("tabindex", "invalid"); editableDiv.tabIndex', '-1');
89 shouldBe('normalDiv.setAttribute("tabindex", "invalid"); normalDiv.tabIndex', '-1');
90 shouldBe('output.setAttribute("tabindex", "invalid"); output.tabIndex', '-1');
91 shouldBe('fieldset.setAttribute("tabindex", "invalid"); fieldset.tabIndex', '-1');
92 shouldBe('video.setAttribute("tabindex", "invalid"); video.tabIndex', '-1');
93 shouldBe('videoWithControls.setAttribute("tabindex", "invalid"); videoWithControls.tabIndex', '-1');
94 shouldBe('summary.setAttribute("tabindex", "invalid"); summary.tabIndex', '-1');
95 shouldBe('bodyInDesignMode.setAttribute("tabindex", "invalid"); bodyInDesignMode.tabIndex', '-1');
96 shouldBe('g.setAttribute("tabindex", "invalid"); g.tabIndex', '-1');
97
98 shouldBe('anchor.setAttribute("tabindex", "9999999999"); anchor.tabIndex', '0');
99 shouldBe('iframe.setAttribute("tabindex", "9999999999"); iframe.tabIndex', '0');
100 shouldBe('frame.setAttribute("tabindex", "9999999999"); frame.tabIndex', '0');
101 shouldBe('object.setAttribute("tabindex", "invalid"); object.tabIndex', '0');
102 shouldBe('button.setAttribute("tabindex", "9999999999"); button.tabIndex', '0');
103 shouldBe('input.setAttribute("tabindex", "9999999999"); input.tabIndex', '0');
104 shouldBe('select.setAttribute("tabindex", "9999999999"); select.tabIndex', '0');
105 shouldBe('textarea.setAttribute("tabindex", "9999999999"); textarea.tabIndex', '0');
106 shouldBe('keygen.setAttribute("tabindex", "9999999999"); keygen.tabIndex', '0');
107 shouldBe('activeSummary.setAttribute("tabindex", "9999999999"); activeSummary.tabIndex', '0');
108 shouldBe('editableDiv.setAttribute("tabindex", "9999999999"); editableDiv.tabIndex', '-1');
109 shouldBe('normalDiv.setAttribute("tabindex", "9999999999"); normalDiv.tabIndex', '-1');
110 shouldBe('output.setAttribute("tabindex", "9999999999"); output.tabIndex', '-1');
111 shouldBe('fieldset.setAttribute("tabindex", "9999999999"); fieldset.tabIndex', '-1');
112 shouldBe('video.setAttribute("tabindex", "9999999999"); video.tabIndex', '-1');
113 shouldBe('videoWithControls.setAttribute("tabindex", "9999999999"); videoWithControls.tabIndex', '-1');
114 shouldBe('summary.setAttribute("tabindex", "9999999999"); summary.tabIndex', '-1');
115 shouldBe('bodyInDesignMode.setAttribute("tabindex", "9999999999"); bodyInDesignMode.tabIndex', '-1');
116 shouldBe('g.setAttribute("tabindex", "9999999999"); g.tabIndex', '-1');
117
118 document.getElementById('container').innerHTML = '';
119 </script>
120 <script src="../../resources/js-test-post.js"></script>
121 </body>
122 </html>