Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: LayoutTests/fast/html/eventhandler-attribute-non-callable.html

Issue 22687002: Treat non-callable input as null for EventHandler attributes (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Do not call v8::Null() is value is already null Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <html>
2 <head>
3 <link rel="help" href="http://www.whatwg.org/specs/web-apps/current-work/multipa ge/webappapis.html#eventhandler">
4 <script src="../js/resources/js-test-pre.js"></script>
5 <body>
haraken 2013/08/08 13:57:35 Super Nit: </head> is missing.
do-not-use 2013/08/08 14:05:48 Done.
6 <div id="div"></div>
7 <script>
8 description("This test checks that EventHandler attributes only accept JS functi ons as input.");
9
10 var div = document.getElementById("div");
11 var wasCallbackCalled = false;
12
13 function callback() {
14 wasCallbackCalled = true;
15 }
16
17 function dispatchKeyEvent()
18 {
19 var event = document.createEvent("KeyboardEvent");
20 event.initKeyboardEvent("keydown", true, true, null, "Enter", "");
21 div.dispatchEvent(event);
22 }
23
24 // Input is a JS function, this should work.
25 shouldBeNull('div.onkeydown');
26 shouldNotThrow('div.onkeydown = callback');
27 shouldBe('div.onkeydown', 'callback');
28 dispatchKeyEvent();
29 shouldBeTrue('wasCallbackCalled');
30
31 // Non callable input should be treated as null.
32 var o = {};
33 o.__defineGetter__("handleEvent", callback);
haraken 2013/08/08 13:55:47 We want to use Object.defineProperty()
do-not-use 2013/08/08 14:05:48 Done.
34 shouldNotBe('div.onkeydown', 'null');
35 shouldNotThrow('div.onkeydown = o');
36 shouldBeNull('div.onkeydown');
37 wasCallbackCalled = false;
38 dispatchKeyEvent();
39 shouldBeFalse('wasCallbackCalled');
40
haraken 2013/08/08 13:55:47 We might want to add a test case for 'div.onkeydow
do-not-use 2013/08/08 14:05:48 Done.
41 </script>
42 <script src="../js/resources/js-test-post.js"></script>
43 </body>
44 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698