Bug 1094310 - Disable media context menu items for blob and mediasource URLs. r=gavin
This commit is contained in:
@@ -627,7 +627,10 @@ nsContextMenu.prototype = {
|
||||
this.onCanvas = true;
|
||||
}
|
||||
else if (this.target instanceof HTMLVideoElement) {
|
||||
this.mediaURL = this.target.currentSrc || this.target.src;
|
||||
let mediaURL = this.target.currentSrc || this.target.src;
|
||||
if (this.isMediaURLReusable(mediaURL)) {
|
||||
this.mediaURL = mediaURL;
|
||||
}
|
||||
// Firefox always creates a HTMLVideoElement when loading an ogg file
|
||||
// directly. If the media is actually audio, be smarter and provide a
|
||||
// context menu with audio operations.
|
||||
@@ -640,7 +643,10 @@ nsContextMenu.prototype = {
|
||||
}
|
||||
else if (this.target instanceof HTMLAudioElement) {
|
||||
this.onAudio = true;
|
||||
this.mediaURL = this.target.currentSrc || this.target.src;
|
||||
let mediaURL = this.target.currentSrc || this.target.src;
|
||||
if (this.isMediaURLReusable(mediaURL)) {
|
||||
this.mediaURL = mediaURL;
|
||||
}
|
||||
}
|
||||
else if (editFlags & (SpellCheckHelper.INPUT | SpellCheckHelper.TEXTAREA)) {
|
||||
this.onTextInput = (editFlags & SpellCheckHelper.TEXTINPUT) !== 0;
|
||||
@@ -1504,6 +1510,10 @@ nsContextMenu.prototype = {
|
||||
return !this.focusedWindow.getSelection().isCollapsed;
|
||||
},
|
||||
|
||||
isMediaURLReusable: function(aURL) {
|
||||
return !/^(?:blob|mediasource):/.test(aURL);
|
||||
},
|
||||
|
||||
toString: function () {
|
||||
return "contextMenu.target = " + this.target + "\n" +
|
||||
"contextMenu.onImage = " + this.onImage + "\n" +
|
||||
|
||||
Reference in New Issue
Block a user