Debian Codegraph @

dijit/tests/robot/_Widget-ondijitclick_mouse.html

raw symbols SCIP
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
3 <html>
4 <head>
5
6 <title>Test Dijit Internal Event: "ondijitclick"</title>
7
8 <script type="text/javascript" src="../../../dojo/dojo.js" data-dojo-config="isDebug: true"></script>
9 <script type="text/javascript">
10 require([
11 "doh/runner", "dojo/robotx",
12 "dojo/aspect", "dojo/dom", "dojo/on", "dojo/domReady!"
13 ], function(doh, robot, aspect, dom, on){
14
15 robot.initRobot('../_Widget-ondijitclick.html');
16
17 // Event monitoring
18 var widgetClicks = 0, buttonClicks = 0;
19 var w;
20
21 doh.register(function setup(){
22 // get pointer to registry in the iframe
23 registry = robot.window.require("dijit/registry");
24 });
25
26 doh.register("ondijitclick w/mouse", {
27 timeout:5000,
28 runTest:function(){
29 var d = new doh.Deferred();
30
31 robot.sequence(function(){
32 w = registry.byId("first");
33 aspect.after(w, "_onClick", function(){
34 widgetClicks++;
35 }, true);
36 on(dom.byId("plainbutton", robot.doc), "click", function(){
37 buttonClicks++;
38 });
39 w.domNode.focus();
40 }, 100);
41
42 // click the widget
43 robot.mouseMoveAt("first", 500);
44 robot.mouseClick({left: true}, 500);
45
46 robot.sequence(d.getTestCallback(function(){
47 doh.is(1, widgetClicks, "ondijitclick handler fired once");
48 }), 1000);
49
50 return d;
51 }
52 });
53
54 // Test clicking on a <button> with an ondijitclick handler.
55 doh.register("click ondijitclick button", [
56 {
57 name: "click",
58 timeout: 5000,
59 runTest: function(){
60
61 var d = new doh.Deferred(),
62 buttonWidget = registry.byId("widgetbutton");
63
64 buttonWidget.clickCount = 0;
65
66 robot.mouseMoveAt("widgetbutton", 500);
67 robot.mouseClick({left: true}, 500);
68
69 // Check that ondijitclick fired exactly once
70 robot.sequence(d.getTestCallback(function(){
71 doh.is(1, buttonWidget.clickCount, "one click event");
72 }), 500);
73
74 return d;
75 }
76 }
77 ]);
78
79 doh.register("bubbling", [
80 {
81 name: "bubbling",
82 timeout: 5000,
83 runTest: function(){
84
85 var d = new doh.Deferred(),
86 outerDiv = dom.byId("outer", robot.doc),
87 buttonNode = dom.byId("bubbleTestWidget", robot.doc),
88 buttonWidget = registry.byId("bubbleTestWidget");
89
90 // Listen for click events on the outer DOMNode.
91 var clicks = 0;
92 on(outerDiv, "click", function(){
93 clicks++;
94 });
95
96 // click the widget button
97 robot.mouseMoveAt("bubbleTestWidget", 500);
98 robot.mouseClick({left: true}, 500);
99
100 // Check that one click event bubbled
101 robot.sequence(d.getTestCallback(function(){
102 doh.is(1, buttonWidget.clickCount, "one click event");
103 doh.is(1, clicks, "one click event bubbled");
104 }), 500);
105
106 return d;
107 }
108 }
109 ]);
110
111 doh.run();
112 });
113
114 </script>
115 </head>
116 </html>