diff --git a/mozilla/browser/base/content/browser.js b/mozilla/browser/base/content/browser.js index ec29c08aafd..4e16012b391 100644 --- a/mozilla/browser/base/content/browser.js +++ b/mozilla/browser/base/content/browser.js @@ -3972,12 +3972,24 @@ nsContextMenu.prototype = { #endif this.showItem( "context-setDesktopBackground", haveSetDesktopBackground && this.onImage ); - if( haveSetDesktopBackground && this.onImage ) - // Disable the Set as Desktop Background menu item if we're still trying - // to load the image - this.setItemAttr( "context-setDesktopBackground", "disabled", - (("complete" in this.target) && !this.target.complete) ? - "true" : null ); + if ( haveSetDesktopBackground && this.onImage ) { + // Disable the Set as Desktop Background menu item if we're still trying + // to load the image or the load failed + const nsIImageLoadingContent = Components.interfaces.nsIImageLoadingContent; + var disableDesktopBackground = false; + if (("complete" in this.target) && !this.target.complete) + disableSetWallpaper = true; + else if (this.target instanceof nsIImageLoadingContent) { + var request = this.target.QueryInterface(nsIImageLoadingContent) + .getRequest(nsIImageLoadingContent.CURRENT_REQUEST); + if (!request) + disableDesktopBackground = true; + } + else if (makeURI(this.target.src).scheme == "javascript") + disableDesktopBackground = true; + + this.setItemAttr( "context-setDesktopBackground", "disabled", disableDesktopBackground); + } // View Image depends on whether an image was clicked on. this.showItem( "context-viewimage", this.onImage && !this.onStandaloneImage ); diff --git a/mozilla/browser/components/shell/content/setDesktopBackground.js b/mozilla/browser/components/shell/content/setDesktopBackground.js index 9a9146dfc31..fe70d0d1357 100644 --- a/mozilla/browser/components/shell/content/setDesktopBackground.js +++ b/mozilla/browser/components/shell/content/setDesktopBackground.js @@ -198,6 +198,17 @@ var gSetBackground = { _createImage: function () { var img = document.createElementNS(kXUL_NS, "image"); + const nsIImageLoadingContent = Components.interfaces.nsIImageLoadingContent; + if (window.arguments[0] instanceof nsIImageLoadingContent) { + var request = window.arguments[0].QueryInterface(nsIImageLoadingContent) + .getRequest(nsIImageLoadingContent.CURRENT_REQUEST); + if (!request) + return false; + } + + if (makeURI(window.arguments[0].src).scheme == "javascript") + return false; + img.setAttribute("src", this._image.src); return img; },