Bug 797297 - Remove hasAttribute check from outer loop of BrowserElementChild::_contextMenuHandler. r=jlebar
authorDale Harvey <dale@arandomurl.com>
Sat, 13 Oct 2012 20:27:00 -0400
changeset 110369 574ec568513b51210d5f0e97643405f1b06a979a
parent 110368 78022080a795fbe19558b35474dc24a3b04b71a7
child 110370 1949f7d5c6ed2b6c04cffc03f3309967f491d3f1
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersjlebar
bugs797297
milestone19.0a1
Bug 797297 - Remove hasAttribute check from outer loop of BrowserElementChild::_contextMenuHandler. r=jlebar
dom/browser-element/BrowserElementChild.js
dom/browser-element/mochitest/browserElement_ContextmenuEvents.js
--- a/dom/browser-element/BrowserElementChild.js
+++ b/dom/browser-element/BrowserElementChild.js
@@ -396,26 +396,26 @@ BrowserElementChild.prototype = {
 
     this._ctxCounter++;
     this._ctxHandlers = {};
 
     var elem = e.target;
     var menuData = {systemTargets: [], contextmenu: null};
     var ctxMenuId = null;
 
-    while (elem && elem.hasAttribute) {
+    while (elem && elem.parentNode) {
       var ctxData = this._getSystemCtxMenuData(elem);
       if (ctxData) {
         menuData.systemTargets.push({
           nodeName: elem.nodeName,
           data: ctxData
         });
       }
 
-      if (!ctxMenuId && elem.hasAttribute('contextmenu')) {
+      if (!ctxMenuId && 'hasAttribute' in elem && elem.hasAttribute('contextmenu')) {
         ctxMenuId = elem.getAttribute('contextmenu');
       }
       elem = elem.parentNode;
     }
 
     if (ctxMenuId) {
       var menu = e.target.ownerDocument.getElementById(ctxMenuId);
       if (menu) {
--- a/dom/browser-element/mochitest/browserElement_ContextmenuEvents.js
+++ b/dom/browser-element/mochitest/browserElement_ContextmenuEvents.js
@@ -15,17 +15,17 @@ var iframeScript = function() {
   };
 
   XPCNativeWrapper.unwrap(content).onerror = function(e) {
     sendAsyncMessage('test:errorTriggered', {data: e});
   };
 
   content.fireContextMenu(content.document.body);
   content.fireContextMenu(content.document.getElementById('menu1-trigger'));
-  content.fireContextMenu(content.document.getElementById('inner-link'));
+  content.fireContextMenu(content.document.getElementById('inner-link').childNodes[0]);
   content.fireContextMenu(content.document.getElementById('menu2-trigger'));
 }
 
 var trigger1 = function() {
   content.fireContextMenu(content.document.getElementById('menu1-trigger'));
 };
 
 function runTest() {