From 0ca337367f8a00e2f31aa2f11ce20c6e5ec92ebd Mon Sep 17 00:00:00 2001 From: "bbaetz%cs.mcgill.ca" Date: Sun, 29 Apr 2001 20:48:29 +0000 Subject: [PATCH] Bug 74019 - r=jag, sr=ben Bug 76587 - r=morse, sr=ben Both bugs fix errors in the context menu js, which caused the context menu to show all possible items. --- .../resources/content/nsContextMenu.js | 48 +++++++++++-------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/xpfe/communicator/resources/content/nsContextMenu.js b/xpfe/communicator/resources/content/nsContextMenu.js index 595adc0b0749..402d98abf6b2 100644 --- a/xpfe/communicator/resources/content/nsContextMenu.js +++ b/xpfe/communicator/resources/content/nsContextMenu.js @@ -274,12 +274,12 @@ nsContextMenu.prototype = { // (which should be the href). var root = this.target; while ( root && !this.link ) { + if ( root.tagName == "tree" ) { + // Hit root of tree; must have clicked in empty space; + // thus, no link. + break; + } if ( root.getAttribute( "URL" ) ) { - if ( root.tagName == "tree" ) { - // Hit root of tree; must have clicked in empty space; - // thus, no link. - break; - } // Build pseudo link object so link-related functions work. this.onLink = true; this.link = { href : root.getAttribute("URL") }; @@ -354,22 +354,28 @@ nsContextMenu.prototype = { }, // Returns true iff clicked on link is saveable. isLinkSaveable : function ( link ) { - // Test for missing protocol property. - if ( !link.protocol ) { - // We must resort to testing the URL string :-(. - var protocol; - if (link.href) { - protocol = link.href.substr( 0, 11 ); - } else { - protocol = link.getAttributeNS("http://www.w3.org/1999/xlink","href"); - if (protocol) { - protocol = protocol.substr( 0, 11 ); - } - } - return protocol.toLowerCase() != "javascript:"; - } else { - // Presume all but javascript: urls are saveable. - return link.protocol.toLowerCase() != "javascript:"; + try { + // Test for missing protocol property. + if ( !link.protocol ) { + // We must resort to testing the URL string :-(. + var protocol; + if (link.href) { + protocol = link.href.substr( 0, 11 ); + } else { + protocol = link.getAttributeNS("http://www.w3.org/1999/xlink","href"); + if (protocol) { + protocol = protocol.substr( 0, 11 ); + } + } + return protocol.toLowerCase() != "javascript:"; + } else { + // Presume all but javascript: urls are saveable. + return link.protocol.toLowerCase() != "javascript:"; + } + } catch (e) { + // something was wrong with the link, + // so we won't be able to save it anyway + return false; } }, // Open linked-to URL in a new window.