3 <script src='test.js'
></script>
4 <script src='focus.js'
></script>
7 function testInactiveElement() {
8 var a
= document
.getElementById('a');
10 a
.setSelectionRange(0, 2);
11 assertEquals(0, a
.selectionStart
);
12 assertEquals(2, a
.selectionEnd
);
13 var c
= document
.getElementById('c');
15 assertEquals(c
, document
.activeElement
);
17 assertEquals(3, a
.selectionStart
);
18 assertEquals(3, a
.selectionEnd
);
21 function testActiveElement() {
22 var a
= document
.getElementById('a');
24 var is_blurred
= false;
25 var onBlur = function() {
28 a
.addEventListener('blur', onBlur
, false);
33 a
.removeEventListener('blur', onBlur
, false);
38 function testNonTextInput() {
39 var a
= document
.getElementById('a');
41 assertEquals(a
, document
.activeElement
);
42 var c
= document
.getElementById('c');
44 assertEquals(c
, document
.activeElement
);
47 function testEditableDiv() {
48 var a
= document
.getElementById('a');
50 assertEquals(a
, document
.activeElement
);
51 var d
= document
.getElementById('d');
53 assertEquals(d
, document
.activeElement
);
56 function testNonFocusableChildOfEditableDiv() {
57 var a
= document
.getElementById('a');
59 assertEquals(a
, document
.activeElement
);
61 focus(document
.getElementById('e'));
67 function testFocusableChildOfEditableDiv() {
68 var a
= document
.getElementById('a');
70 assertEquals(a
, document
.activeElement
);
71 var f
= document
.getElementById('f');
73 assertEquals(f
, document
.activeElement
);
76 function testTransparentElement() {
77 var a
= document
.getElementById('a');
79 assertEquals(a
, document
.activeElement
);
80 var g
= document
.getElementById('g');
82 assertEquals(g
, document
.activeElement
);
87 <input type=
"text" id=
"a">
92 <input type=
"button" value=
"c" id=
"c">
94 <div id=
"d" contentEditable=
"true">
96 <div contentEditable=
"true">
97 <div id=
"e">editable
</div>
99 <div contentEditable=
"true">
100 <input id=
"f" type=
"text">
103 <input id=
"g" style='opacity:
0' type='text'
>