1 <p>This tests to see if a mouse click inside an editable, focusable node focuses that node. Normally, we focus a node on mouse down, but to make it easier to drag selections containing editable pieces we delay focus until mouse up. The editable table cell should be focused and you should see a 'Success' message below.
</p>
2 <div id=
"div" contenteditable=
"true" onblur=
"handleBlur();"><table contenteditable=
"false" border=
"1"><tr><td>non-editable
</td><td id=
"cell" contenteditable=
"true" onfocus=
"log('Success');">editable
</td></tr></table></div>
3 <div id=
"destination" contenteditable=
"true"><br></div>
7 var text
= document
.createTextNode(str
);
8 var li
= document
.createElement("li");
9 var console
= document
.getElementById("console");
10 console
.appendChild(li
);
13 function handleBlur() {
18 if (!window
.testRunner
)
20 var cell
= document
.getElementById("cell");
21 cell
.addEventListener(handleBlur
, "DOMBlurEvent");
22 var div
= document
.getElementById("div");
24 document
.execCommand("SelectAll");
27 x
= cell
.offsetParent
.offsetLeft
+ cell
.offsetLeft
+ cell
.offsetWidth
/ 2;
28 y
= cell
.offsetParent
.offsetTop
+ cell
.offsetTop
+ cell
.offsetHeight
/ 2;
29 eventSender
.mouseMoveTo(x
, y
);
30 eventSender
.mouseDown();
32 log("Error, focus changed too early.")
33 eventSender
.mouseUp();