123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <body>
- <p>Test for <a href="http://bugs.webkit.org/show_bug.cgi?id=3387">bug 3387</a>:
- Redundant keydown, keypress, keyup events sent for arrow keys.</p>
- <p>Try pressing arrow keys, PgUp/PgDown/Home/End, Esc, or function keys.
- The test passes if the box below doesn't turn red.<p>
- <div id="result" style="width:100px; height:100px; background-color:blue;"></div>
- <script>
- var console_messages = document.createElement("ol");
- document.body.appendChild(console_messages);
-
- window.onkeydown = registerWindow;
- window.onkeypress = registerWindow;
- window.onkeyup = registerWindow;
- document.onkeydown = registerDocument;
- document.onkeypress = registerDocument;
- document.onkeyup = registerDocument;
- document.body.onkeydown = registerBody;
- document.body.onkeypress = registerBody;
- document.body.onkeyup = registerBody;
- document.documentElement.onkeydown = registerDocumentElement;
- document.documentElement.onkeypress = registerDocumentElement;
- document.documentElement.onkeyup = registerDocumentElement;
- var bodyKeyDownCount = 0;
- var documentElementKeyDownCount = 0;
- var windowKeyDownCount = 0;
- var documentKeyDownCount = 0;
- function log(message)
- {
- var item = document.createElement("li");
- item.appendChild(document.createTextNode(message));
- item.style.fontSize = '8px';
- console_messages.appendChild(item);
- }
- function registerBody(e)
- {
- if ((e.type == "keydown" && ++bodyKeyDownCount != 1)
- || (e.type == "keyup" && --bodyKeyDownCount != 0))
- document.getElementById("result").style.backgroundColor = "red";
- if (!e)
- e = window.event;
- log("body: " + e.type);
- return true;
- }
- function registerDocumentElement(e)
- {
- if ((e.type == "keydown" && ++documentElementKeyDownCount != 1)
- || (e.type == "keyup" && --documentElementKeyDownCount != 0))
- document.getElementById("result").style.backgroundColor = "red";
- if (!e)
- e = window.event;
- log(" documentElement: " + e.type);
- return true;
- }
- function registerDocument(e)
- {
- if ((e.type == "keydown" && ++documentKeyDownCount != 1)
- || (e.type == "keyup" && --documentKeyDownCount != 0))
- document.getElementById("result").style.backgroundColor = "red";
- if (!e)
- e = window.event;
- log(" document: " + e.type);
- return true;
- }
- function registerWindow(e)
- {
- if ((e.type == "keydown" && ++windowKeyDownCount != 1)
- || (e.type == "keyup" && --windowKeyDownCount != 0))
- document.getElementById("result").style.backgroundColor = "red";
- if (!e)
- e = window.event;
- log(" window: " + e.type);
- return true;
- }
- </script>
- </body>
|