3 <body onselectstart=
"event.preventDefault();">
4 <p>This test ensures selectstart event fires when selecting all and script can prevent the selection change.
</p>
6 <div onselectstart=
"handlerOnDivWasCalled = true;" contenteditable
>hello
</div>
7 <input onselectstart=
"event.preventDefault();" type=
"text" value=
"world">
11 if (window
.testRunner
) {
12 testRunner
.dumpAsText();
13 testRunner
.dumpEditingCallbacks();
16 var handlerOnDivWasCalled
= false;
17 var div
= document
.getElementsByTagName('div')[0];
19 window
.getSelection().collapse(div
.firstChild
, 1);
20 document
.execCommand('SelectAll', false, null);
21 var range
= window
.getSelection().getRangeAt(0);
22 document
.write('div: ');
23 if (!handlerOnDivWasCalled
)
24 document
.writeln('FAIL - handler on div was never called');
25 else if (range
.startOffset
!= 1 || range
.endOffset
!= 1)
26 document
.writeln('FAIL - selection changed');
28 document
.writeln('PASS');
30 var input
= document
.getElementsByTagName('input')[0];
32 input
.selectionStart
= 1;
33 input
.selectionEnd
= 1;
34 document
.execCommand('SelectAll', false, null);
35 document
.writeln('input: ' + (input
.selectionStart
== 1 || input
.selectionEnd
== 1 ? 'PASS' : 'FAIL'));
37 document
.getElementById('test').style
.display
= 'none';