Bug 615573 - widget's MouseOver and MouseOut events have incorrect case. r=myk
authorDrew Willcoxon <adw@mozilla.com>
Tue, 30 Nov 2010 13:57:41 -0800
changeset 1150 dddf3843abcbc618a5b6534378b308d59f86ee71
parent 1136 a669c12d7f07f8c4d73fe9222f7304dd94bfe1ac
child 1151 985136f1b156a4cca06ea44cd880401db7a1edf5
push id472
push userbwarner@mozilla.com
push dateTue, 30 Nov 2010 22:50:14 +0000
reviewersmyk
bugs615573
Bug 615573 - widget's MouseOver and MouseOut events have incorrect case. r=myk
packages/addon-kit/lib/widget.js
packages/addon-kit/tests/test-widget.js
--- a/packages/addon-kit/lib/widget.js
+++ b/packages/addon-kit/lib/widget.js
@@ -45,21 +45,21 @@ const {Cc, Ci} = require("chrome");
 const CONTENT_TYPE_URI    = 1;
 const CONTENT_TYPE_HTML   = 2;
 const CONTENT_TYPE_IMAGE  = 3;
 
 const ERR_CONTENT = "No content or contentURL property found. Widgets must "
                          + "have one or the other.",
       ERR_LABEL = "The widget must have a non-empty label property.";
 
-// Supported events
+// Supported events, mapping from DOM event names to our event names
 const EVENTS = {
   "click": "click",
-  "mouseover": "MouseOver",
-  "mouseout": "MouseOut",
+  "mouseover": "mouseover",
+  "mouseout": "mouseout",
 };
 
 if (!require("xul-app").is("Firefox")) {
   throw new Error([
     "The widget module currently supports only Firefox.  In the future ",
     "it will support other applications. Please see ",
     "https://bugzilla.mozilla.org/show_bug.cgi?id=560716 for more information."
   ].join(""));
@@ -110,20 +110,20 @@ const Widget = Trait.compose(Loader, Tra
 
     if ("width" in options)
       this.width = options.width;
     if ("panel" in options)
       this.panel = options.panel;
 
     if ("onClick" in options)
       this.on("click", options.onClick);
-    if ("onMouseOver" in options)
-      this.on("MouseOver", options.onMouseOver);
-    if ("onMouseOut" in options)
-      this.on("MouseOut", options.onMouseOut);
+    if ("onMouseover" in options)
+      this.on("mouseover", options.onMouseover);
+    if ("onMouseout" in options)
+      this.on("mouseout", options.onMouseout);
     if ("content" in options)
       this._content = options.content;
     if ("contentURL" in options)
       this.contentURL = options.contentURL;
 
     if ("contentScriptWhen" in options)
       this.contentScriptWhen = options.contentScriptWhen;
     if ("contentScriptFile" in options)
@@ -134,17 +134,17 @@ const Widget = Trait.compose(Loader, Tra
       this.allow = options.allow;
     if ("onError" in options)
       this.on("error", options.onError);
     if ("onMessage" in options)
         this.on("message", options.onMessage);
 
     if (!(this._content || this.contentURL))
       throw new Error(ERR_CONTENT);
-    
+
     let self = this;
     this.on('propertyChange', function(change) {
       if ('contentURL' in change)
         browserManager.updateItem(self._public, "contentURL", self.contentURL);
     });
 
     browserManager.addItem(this._public);
   },
--- a/packages/addon-kit/tests/test-widget.js
+++ b/packages/addon-kit/tests/test-widget.js
@@ -180,33 +180,33 @@ exports.testConstructor = function(test)
   // event: onmouseover + content
   tests.push(function() testSingleWidget({
     label: "mouseover test widget - content",
     content: "<div id='me'>foo</div>",
     contentScript: "var evt = document.createEvent('HTMLEvents'); " +
                    "evt.initEvent('mouseover', true, true ); " +
                    "document.getElementById('me').dispatchEvent(evt);",
     contentScriptWhen: "ready",
-    onMouseOver: function(widget) {
-      test.pass("onMouseOver called");
+    onMouseover: function(widget) {
+      test.pass("onMouseover called");
       widget.destroy();
       doneTest();
     }
   }));
 
   // event: onmouseout + content
   tests.push(function() testSingleWidget({
     label: "mouseout test widget - content",
     content: "<div id='me'>foo</div>",
     contentScript: "var evt = document.createEvent('HTMLEvents'); " +
                    "evt.initEvent('mouseout', true, true ); " +
                    "document.getElementById('me').dispatchEvent(evt);",
     contentScriptWhen: "ready",
-    onMouseOut: function(widget) {
-      test.pass("onMouseOut called");
+    onMouseout: function(widget) {
+      test.pass("onMouseout called");
       widget.destroy();
       doneTest();
     }
   }));
 
   // event: onclick + image
   tests.push(function() testSingleWidget({
     label: "click test widget - image",
@@ -225,33 +225,33 @@ exports.testConstructor = function(test)
   // event: onmouseover + image
   tests.push(function() testSingleWidget({
     label: "mouseover test widget - image",
     contentURL: require("self").data.url("moz_favicon.ico"),
     contentScript: "var evt = document.createEvent('HTMLEvents'); " +
                    "evt.initEvent('mouseover', true, true ); " +
                    "document.body.firstElementChild.dispatchEvent(evt);",
     contentScriptWhen: "ready",
-    onMouseOver: function(widget) {
-      test.pass("onMouseOver called");
+    onMouseover: function(widget) {
+      test.pass("onMouseover called");
       widget.destroy();
       doneTest();
     }
   }));
 
   // event: onmouseout + image
   tests.push(function() testSingleWidget({
     label: "mouseout test widget - image",
     contentURL: require("self").data.url("moz_favicon.ico"),
     contentScript: "var evt = document.createEvent('HTMLEvents'); " +
                    "evt.initEvent('mouseout', true, true ); " +
                    "document.body.firstElementChild.dispatchEvent(evt);",
     contentScriptWhen: "ready",
-    onMouseOut: function(widget) {
-      test.pass("onMouseOut called");
+    onMouseout: function(widget) {
+      test.pass("onMouseout called");
       widget.destroy();
       doneTest();
     }
   }));
 
   // test multiple widgets
   tests.push(function() {
     let w1 = widgets.Widget({label: "first widget", content: "first content"});