OLD | NEW |
1 description("Ensure that clicking in the margins around editable divs does not g
rant focus.") | 1 description("Ensure that clicking in the margins around editable divs does not g
rant focus.") |
2 | 2 |
3 document.body.style.margin = "20px"; | 3 document.body.style.margin = "20px"; |
4 | 4 |
5 var outerDiv = document.createElement("div"); | 5 var outerDiv = document.createElement("div"); |
6 outerDiv.style.cssText = "width: 100px; padding: 100px; background-color: blue;"
; | 6 outerDiv.style.cssText = "width: 100px; padding: 100px; background-color: blue;"
; |
7 var innerDiv = document.createElement("div"); | 7 var innerDiv = document.createElement("div"); |
8 innerDiv.style.cssText = "height: 100px; border: 1px solid pink; background-colo
r: green;"; | 8 innerDiv.style.cssText = "height: 100px; border: 1px solid pink; background-colo
r: green;"; |
9 innerDiv.contentEditable = true; | 9 innerDiv.contentEditable = true; |
10 outerDiv.appendChild(innerDiv); | 10 outerDiv.appendChild(innerDiv); |
11 document.body.insertBefore(outerDiv, document.body.firstChild); | 11 document.body.insertBefore(outerDiv, document.body.firstChild); |
12 | 12 |
| 13 // Mouse events only work after an initial layout |
| 14 document.body.offsetLeft; |
| 15 |
13 var lastClickCausedFocus = false; | 16 var lastClickCausedFocus = false; |
14 document.documentElement.addEventListener("mouseup", function(e) { | 17 document.documentElement.addEventListener("mouseup", function(e) { |
15 var lastClick = e || window.event; | 18 var lastClick = e || window.event; |
16 if (lastClickCausedFocus) { | 19 if (lastClickCausedFocus) { |
17 testFailed("Click @ " + lastClick.clientX + ", " + lastClick.clientY + "
caused innerdiv to focus!"); | 20 testFailed("Click @ " + lastClick.clientX + ", " + lastClick.clientY + "
caused innerdiv to focus!"); |
18 } else { | 21 } else { |
19 testPassed("Click @ " + lastClick.clientX + ", " + lastClick.clientY + "
did not cause focus."); | 22 testPassed("Click @ " + lastClick.clientX + ", " + lastClick.clientY + "
did not cause focus."); |
20 } | 23 } |
21 innerDiv.blur(); | 24 innerDiv.blur(); |
22 lastClickCausedFocus = false; | 25 lastClickCausedFocus = false; |
(...skipping 17 matching lines...) Expand all Loading... |
40 | 43 |
41 clickAt(70, 270); | 44 clickAt(70, 270); |
42 clickAt(170, 270); | 45 clickAt(170, 270); |
43 clickAt(270, 270); | 46 clickAt(270, 270); |
44 } else { | 47 } else { |
45 debug("To test, cick above and to the left of the blue box, then above it, t
hen to the left " + | 48 debug("To test, cick above and to the left of the blue box, then above it, t
hen to the left " + |
46 "of it and finally, click in all 8 regions around the green div."); | 49 "of it and finally, click in all 8 regions around the green div."); |
47 } | 50 } |
48 | 51 |
49 var successfullyParsed = true; | 52 var successfullyParsed = true; |
OLD | NEW |