LayoutTests/imported/w3c:
[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 <math><mrow id="mrow" onfocus="alert('fail')"></mrow></math>
30 </div>
31
32 <script>
33 description('Default value of tabIndex IDL attribute');
34
35 var anchor = document.getElementById('anchor');
36 var iframe = document.getElementById('iframe');
37 iframe.contentDocument.open();
38 iframe.contentDocument.write('<!DOCTYPE><html><frameset cols="50%,50%"><frame></frame></frameset>');
39 var frame = iframe.contentDocument.querySelector('frame');
40 var object = document.getElementById('object');
41 var button = document.getElementById('button');
42 var input = document.getElementById('input');
43 var select = document.getElementById('select');
44 var textarea = document.getElementById('textarea');
45 var keygen = document.getElementById('keygen');
46 var editableDiv = document.getElementById('editableDiv');
47 var normalDiv = document.getElementById('normalDiv');
48 var output = document.getElementById('output');
49 var fieldset = document.getElementById('fieldset');
50 var video = document.getElementById('video');
51 var videoWithControls = document.getElementById('videoWithControls');
52 var summary = document.getElementById('summary');
53 var activeSummary = document.getElementById('activeSummary');
54 var iframeForDesignMode = document.getElementById('iframeForDesignMode');
55 iframeForDesignMode.contentDocument.designMode = 'on';
56 var bodyInDesignMode = iframeForDesignMode.contentDocument.body;
57 var g = document.getElementById('g');
58 var mrow = document.getElementById('mrow');
59
60 shouldBe('anchor.tabIndex', '0');
61 shouldBe('iframe.tabIndex', '0');
62 shouldBe('frame.tabIndex', '0');
63 shouldBe('object.tabIndex', '0');
64 shouldBe('button.tabIndex', '0');
65 shouldBe('input.tabIndex', '0');
66 shouldBe('select.tabIndex', '0');
67 shouldBe('textarea.tabIndex', '0');
68 shouldBe('keygen.tabIndex', '0');
69 shouldBe('activeSummary.tabIndex', '0');
70 shouldBe('editableDiv.tabIndex', '-1');
71 shouldBe('normalDiv.tabIndex', '-1');
72 shouldBe('output.tabIndex', '-1');
73 shouldBe('fieldset.tabIndex', '-1');
74 shouldBe('video.tabIndex', '-1');
75 shouldBe('videoWithControls.tabIndex', '-1');
76 shouldBe('summary.tabIndex', '-1');
77 shouldBe('bodyInDesignMode.tabIndex', '-1');
78 shouldBe('g.tabIndex', '-1');
79 shouldBe('mrow.tabIndex', '-1');
80
81 shouldBe('anchor.setAttribute("tabindex", "invalid"); anchor.tabIndex', '0');
82 shouldBe('iframe.setAttribute("tabindex", "invalid"); iframe.tabIndex', '0');
83 shouldBe('frame.setAttribute("tabindex", "invalid"); frame.tabIndex', '0');
84 shouldBe('object.setAttribute("tabindex", "invalid"); object.tabIndex', '0');
85 shouldBe('button.setAttribute("tabindex", "invalid"); button.tabIndex', '0');
86 shouldBe('input.setAttribute("tabindex", "invalid"); input.tabIndex', '0');
87 shouldBe('select.setAttribute("tabindex", "invalid"); select.tabIndex', '0');
88 shouldBe('textarea.setAttribute("tabindex", "invalid"); textarea.tabIndex', '0');
89 shouldBe('keygen.setAttribute("tabindex", "invalid"); keygen.tabIndex', '0');
90 shouldBe('activeSummary.setAttribute("tabindex", "invalid"); activeSummary.tabIndex', '0');
91 shouldBe('editableDiv.setAttribute("tabindex", "invalid"); editableDiv.tabIndex', '-1');
92 shouldBe('normalDiv.setAttribute("tabindex", "invalid"); normalDiv.tabIndex', '-1');
93 shouldBe('output.setAttribute("tabindex", "invalid"); output.tabIndex', '-1');
94 shouldBe('fieldset.setAttribute("tabindex", "invalid"); fieldset.tabIndex', '-1');
95 shouldBe('video.setAttribute("tabindex", "invalid"); video.tabIndex', '-1');
96 shouldBe('videoWithControls.setAttribute("tabindex", "invalid"); videoWithControls.tabIndex', '-1');
97 shouldBe('summary.setAttribute("tabindex", "invalid"); summary.tabIndex', '-1');
98 shouldBe('bodyInDesignMode.setAttribute("tabindex", "invalid"); bodyInDesignMode.tabIndex', '-1');
99 shouldBe('g.setAttribute("tabindex", "invalid"); g.tabIndex', '-1');
100 shouldBe('mrow.setAttribute("tabindex", "invalid"); mrow.tabIndex', '-1');
101
102 shouldBe('anchor.setAttribute("tabindex", "9999999999"); anchor.tabIndex', '0');
103 shouldBe('iframe.setAttribute("tabindex", "9999999999"); iframe.tabIndex', '0');
104 shouldBe('frame.setAttribute("tabindex", "9999999999"); frame.tabIndex', '0');
105 shouldBe('object.setAttribute("tabindex", "invalid"); object.tabIndex', '0');
106 shouldBe('button.setAttribute("tabindex", "9999999999"); button.tabIndex', '0');
107 shouldBe('input.setAttribute("tabindex", "9999999999"); input.tabIndex', '0');
108 shouldBe('select.setAttribute("tabindex", "9999999999"); select.tabIndex', '0');
109 shouldBe('textarea.setAttribute("tabindex", "9999999999"); textarea.tabIndex', '0');
110 shouldBe('keygen.setAttribute("tabindex", "9999999999"); keygen.tabIndex', '0');
111 shouldBe('activeSummary.setAttribute("tabindex", "9999999999"); activeSummary.tabIndex', '0');
112 shouldBe('editableDiv.setAttribute("tabindex", "9999999999"); editableDiv.tabIndex', '-1');
113 shouldBe('normalDiv.setAttribute("tabindex", "9999999999"); normalDiv.tabIndex', '-1');
114 shouldBe('output.setAttribute("tabindex", "9999999999"); output.tabIndex', '-1');
115 shouldBe('fieldset.setAttribute("tabindex", "9999999999"); fieldset.tabIndex', '-1');
116 shouldBe('video.setAttribute("tabindex", "9999999999"); video.tabIndex', '-1');
117 shouldBe('videoWithControls.setAttribute("tabindex", "9999999999"); videoWithControls.tabIndex', '-1');
118 shouldBe('summary.setAttribute("tabindex", "9999999999"); summary.tabIndex', '-1');
119 shouldBe('bodyInDesignMode.setAttribute("tabindex", "9999999999"); bodyInDesignMode.tabIndex', '-1');
120 shouldBe('g.setAttribute("tabindex", "9999999999"); g.tabIndex', '-1');
121 shouldBe('mrow.setAttribute("tabindex", "9999999999"); mrow.tabIndex', '-1');
122
123 document.getElementById('container').innerHTML = '';
124 </script>
125 <script src="../../resources/js-test-post.js"></script>
126 </body>
127 </html>