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.
This commit is contained in:
bbaetz%cs.mcgill.ca 2006-07-29 05:36:42 +00:00
Родитель e16c96b590
Коммит 65e22ab838
1 изменённых файлов: 27 добавлений и 21 удалений

Просмотреть файл

@ -274,12 +274,12 @@ nsContextMenu.prototype = {
// (which should be the href). // (which should be the href).
var root = this.target; var root = this.target;
while ( root && !this.link ) { 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.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. // Build pseudo link object so link-related functions work.
this.onLink = true; this.onLink = true;
this.link = { href : root.getAttribute("URL") }; this.link = { href : root.getAttribute("URL") };
@ -354,22 +354,28 @@ nsContextMenu.prototype = {
}, },
// Returns true iff clicked on link is saveable. // Returns true iff clicked on link is saveable.
isLinkSaveable : function ( link ) { isLinkSaveable : function ( link ) {
// Test for missing protocol property. try {
if ( !link.protocol ) { // Test for missing protocol property.
// We must resort to testing the URL string :-(. if ( !link.protocol ) {
var protocol; // We must resort to testing the URL string :-(.
if (link.href) { var protocol;
protocol = link.href.substr( 0, 11 ); if (link.href) {
} else { protocol = link.href.substr( 0, 11 );
protocol = link.getAttributeNS("http://www.w3.org/1999/xlink","href"); } else {
if (protocol) { protocol = link.getAttributeNS("http://www.w3.org/1999/xlink","href");
protocol = protocol.substr( 0, 11 ); if (protocol) {
} protocol = protocol.substr( 0, 11 );
} }
return protocol.toLowerCase() != "javascript:"; }
} else { return protocol.toLowerCase() != "javascript:";
// Presume all but javascript: urls are saveable. } else {
return link.protocol.toLowerCase() != "javascript:"; // 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. // Open linked-to URL in a new window.