| Index: LayoutTests/fast/html/eventhandler-attribute-non-callable.html
|
| diff --git a/LayoutTests/fast/html/eventhandler-attribute-non-callable.html b/LayoutTests/fast/html/eventhandler-attribute-non-callable.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..45dcb79e481c244bf6d543675fde4a19f1d23783
|
| --- /dev/null
|
| +++ b/LayoutTests/fast/html/eventhandler-attribute-non-callable.html
|
| @@ -0,0 +1,48 @@
|
| +<html>
|
| +<head>
|
| +<link rel="help" href="http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#eventhandler">
|
| +<script src="../js/resources/js-test-pre.js"></script>
|
| +</head>
|
| +<body>
|
| +<div id="div"></div>
|
| +<script>
|
| +description("This test checks that EventHandler attributes only accept JS functions as input.");
|
| +
|
| +var div = document.getElementById("div");
|
| +var callbackCount = 0;
|
| +
|
| +function callback() {
|
| + ++callbackCount;
|
| +}
|
| +
|
| +function dispatchKeyEvent()
|
| +{
|
| + var event = new KeyboardEvent('keydown', { bubbles: true, cancelable: true, view: null, keyIdentifier: 'Enter' });
|
| + div.dispatchEvent(event);
|
| +}
|
| +
|
| +// Input is a JS function, this should work.
|
| +shouldBeNull('div.onkeydown');
|
| +shouldNotThrow('div.onkeydown = callback');
|
| +shouldBe('div.onkeydown', 'callback');
|
| +shouldBe('callbackCount', '0');
|
| +dispatchKeyEvent();
|
| +shouldBe('callbackCount', '1');
|
| +
|
| +// Non callable input should be treated as null.
|
| +var o = { handleEvent: callback };
|
| +shouldNotBe('div.onkeydown', 'null');
|
| +shouldNotThrow('div.onkeydown = o');
|
| +shouldBeNull('div.onkeydown');
|
| +dispatchKeyEvent();
|
| +shouldBe('callbackCount', '1');
|
| +
|
| +// Test null assignment.
|
| +shouldNotThrow('div.onkeydown = callback');
|
| +shouldBe('div.onkeydown', 'callback');
|
| +shouldNotThrow('div.onkeydown = null');
|
| +shouldBeNull('div.onkeydown');
|
| +</script>
|
| +<script src="../js/resources/js-test-post.js"></script>
|
| +</body>
|
| +</html>
|
|
|