summaryrefslogtreecommitdiff
path: root/includes/js/dijit/tests/ondijitclick.html
diff options
context:
space:
mode:
Diffstat (limited to 'includes/js/dijit/tests/ondijitclick.html')
-rw-r--r--includes/js/dijit/tests/ondijitclick.html95
1 files changed, 95 insertions, 0 deletions
diff --git a/includes/js/dijit/tests/ondijitclick.html b/includes/js/dijit/tests/ondijitclick.html
new file mode 100644
index 0000000..36de0e0
--- /dev/null
+++ b/includes/js/dijit/tests/ondijitclick.html
@@ -0,0 +1,95 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+ "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+<head>
+
+ <title>Test Dijit Internal Event: "ondijitclick"</title>
+
+ <script type="text/javascript" src="../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true"></script>
+ <script type="text/javascript">
+ dojo.require("doh.runner");
+ dojo.require("dijit._Widget");
+ dojo.require("dojo.parser");
+
+ dojo.declare("dijit.WidgetWithOndijitclick",
+ dijit._Widget,
+ {
+ clickCount: 0,
+ _onClick: function() {
+ this.clickCount++;
+ },
+ postCreate: function() {
+ this.connect(this.domNode, "ondijitclick", "_onClick");
+ }
+ }
+ );
+
+ dojo.addOnLoad(function(){
+ doh.register("ondijitclick",
+ [
+ {
+ name: "ondijitclick fires once on a space-key-up",
+ runTest: function(t){
+ var w = dijit.byId("widget1");
+ if (dojo.isSafari){ // safari has error
+ this.name += " * SKIPPED *";
+ return;
+ }
+
+ // simulate space up
+ if (document.createEvent){
+ var e = document.createEvent("KeyboardEvent");
+ e.initKeyEvent("keyup",true,true,null,false,false,false,false,32,0);
+ w.domNode.focus();
+ w.clickCount = 0;
+ w.domNode.dispatchEvent(e);
+ t.is(1, w.clickCount);
+ }
+ }
+ },
+ {
+ name: "ondijitclick fires once on an enter-key-down",
+ runTest: function(t){
+ var w = dijit.byId("widget1");
+ if (dojo.isSafari){ // safari has error
+ this.name += " * SKIPPED *";
+ return;
+ }
+
+ // simulate enter down
+ if (document.createEvent && !dojo.isSafari){
+ var e = document.createEvent("KeyboardEvent");
+ e.initKeyEvent("keydown",true,true,null,false,false,false,false,13,0);
+ w.domNode.focus();
+ w.clickCount = 0;
+ w.domNode.dispatchEvent(e);
+ t.is(1, w.clickCount);
+ }
+ }
+ },
+ {
+ name: "ondijitclick fires once on a mouse click",
+ runTest: function(t){
+ var w = dijit.byId("widget1");
+
+ // simulate enter up
+ if (document.createEvent){
+ var e = document.createEvent("MouseEvents");
+ e.initMouseEvent('click', true, true, document.defaultView, 1, 0, 0, 3, 3, false, false, false, false, 0, w.domNode);
+ w.clickCount = 0;
+ w.domNode.dispatchEvent(e);
+ t.is(1, w.clickCount);
+ }
+ }
+ }
+ ]
+ );
+ doh.run();
+ });
+
+ </script>
+</head>
+<body class="tundra">
+ <div id="widget1" dojoType="dijit.WidgetWithOndijitclick"></div>
+</body>
+</html>