3 <body onselectstart="handler(event)">
4 <p>This test ensures selectstart event fires when selecting all.</p>
7 if (window.testRunner) {
8 testRunner.dumpAsText();
9 testRunner.dumpEditingCallbacks();
12 var targetWasBody = true;
14 var listenerCount = 0;
16 function handler(event) {
17 if (event.target != document.body)
18 targetWasBody = false;
22 document.body.addEventListener('selectstart', function (event) {
23 if (event.target != document.body)
24 targetWasBody = false;
28 document.execCommand('SelectAll', false, null);
30 if (handlerCount != 1)
31 document.writeln("FAIL: selectionstart's event handler was called " + handlerCount + ' times');
32 else if (listenerCount != 1)
33 document.writeln("FAIL: selectionstart's event listener was called " + listenerCount + ' times');
34 else if (!targetWasBody)
35 document.writeln("FAIL: target node wasn't body");
36 else if (window.getSelection().toString() != document.body.innerText)
37 document.writeln("FAIL: some contents on document was not selected");
39 document.writeln("PASS");