diff --git a/dom/browser-element/BrowserElementChildPreload.js b/dom/browser-element/BrowserElementChildPreload.js index c2c395246ca6..a802cceb9434 100644 --- a/dom/browser-element/BrowserElementChildPreload.js +++ b/dom/browser-element/BrowserElementChildPreload.js @@ -583,18 +583,14 @@ BrowserElementChild.prototype = { _getSystemCtxMenuData: function(elem) { if ((elem instanceof Ci.nsIDOMHTMLAnchorElement && elem.href) || (elem instanceof Ci.nsIDOMHTMLAreaElement && elem.href)) { - return {uri: elem.href}; + return elem.href; } if (elem instanceof Ci.nsIImageLoadingContent && elem.currentURI) { - return {uri: elem.currentURI.spec}; + return elem.currentURI.spec; } - if (elem instanceof Ci.nsIDOMHTMLImageElement) { - return {uri: elem.src}; - } - if (elem instanceof Ci.nsIDOMHTMLMediaElement) { - let hasVideo = !(elem.readyState >= elem.HAVE_METADATA && - (elem.videoWidth == 0 || elem.videoHeight == 0)); - return {uri: elem.currentSrc || elem.src, hasVideo: hasVideo}; + if ((elem instanceof Ci.nsIDOMHTMLMediaElement) || + (elem instanceof Ci.nsIDOMHTMLImageElement)) { + return elem.currentSrc || elem.src; } return false; }, diff --git a/dom/browser-element/mochitest/Makefile.in b/dom/browser-element/mochitest/Makefile.in index 81ffa6389b78..35452915dd8c 100644 --- a/dom/browser-element/mochitest/Makefile.in +++ b/dom/browser-element/mochitest/Makefile.in @@ -16,8 +16,6 @@ include $(DEPTH)/config/autoconf.mk # process. Default is OOP. MOCHITEST_FILES = \ - $(topsrcdir)/browser/base/content/test/audio.ogg \ - $(topsrcdir)/content/media/test/short-video.ogv \ file_empty_script.js \ file_empty.html \ file_focus.html \ diff --git a/dom/browser-element/mochitest/browserElement_ContextmenuEvents.js b/dom/browser-element/mochitest/browserElement_ContextmenuEvents.js index 2c6ff7941af7..68041e787a0a 100644 --- a/dom/browser-element/mochitest/browserElement_ContextmenuEvents.js +++ b/dom/browser-element/mochitest/browserElement_ContextmenuEvents.js @@ -4,9 +4,6 @@ SimpleTest.waitForExplicitFinish(); browserElementTestHelpers.setEnabledPref(true); browserElementTestHelpers.addPermission(); -let audioUrl = '/tests/dom/browser-element/mochitest/audio.ogg'; -let videoUrl = '/tests/dom/browser-element/mochitest/short-video.ogv'; - function runTests() { createIframe(function onIframeLoaded() { checkEmptyContextMenu(); @@ -117,68 +114,17 @@ function checkCallbackWithoutPreventDefault() { checkContextMenuCallbackForId(detail, id, function onCallbackFired(label) { is(label, null, 'Callback label should be null'); - checkImageContextMenu(); + SimpleTest.finish(); }); }, /* ignorePreventDefault */ true); } -function checkImageContextMenu() { - sendContextMenuTo('#menu3-trigger', function onContextMenu(detail) { - var target = detail.systemTargets[0]; - is(target.nodeName, 'IMG', 'Reports correct nodeName'); - is(target.data.uri, 'example.png', 'Reports correct uri'); - - checkVideoContextMenu(); - }, /* ignorePreventDefault */ true); -} - -function checkVideoContextMenu() { - sendContextMenuTo('#menu4-trigger', function onContextMenu(detail) { - var target = detail.systemTargets[0]; - is(target.nodeName, 'VIDEO', 'Reports correct nodeName'); - is(target.data.uri, videoUrl, 'Reports uri correctly in data'); - is(target.data.hasVideo, true, 'Video data in video tag does "hasVideo"'); - - checkAudioContextMenu(); - }, /* ignorePreventDefault */ true); -} - -function checkAudioContextMenu() { - sendContextMenuTo('#menu6-trigger', function onContextMenu(detail) { - var target = detail.systemTargets[0]; - is(target.nodeName, 'AUDIO', 'Reports correct nodeName'); - is(target.data.uri, audioUrl, 'Reports uri correctly in data'); - - checkAudioinVideoContextMenu(); - }, /* ignorePreventDefault */ true); -} - -function checkAudioinVideoContextMenu() { - sendSrcTo('#menu5-trigger', audioUrl, function onSrcSet() { - sendContextMenuTo('#menu5-trigger', function onContextMenu(detail) { - var target = detail.systemTargets[0]; - is(target.nodeName, 'VIDEO', 'Reports correct nodeName'); - is(target.data.uri, audioUrl, 'Reports uri correctly in data'); - is(target.data.hasVideo, false, 'Audio data in video tag reports no "hasVideo"'); - - SimpleTest.finish(); - }, /* ignorePreventDefault */ true); - }); -} /* Helpers */ var mm = null; var previousContextMenuDetail = null; var currentContextMenuDetail = null; -function sendSrcTo(selector, src, callback) { - mm.sendAsyncMessage('setsrc', { 'selector': selector, 'src': src }); - mm.addMessageListener('test:srcset', function onSrcSet(msg) { - mm.removeMessageListener('test:srcset', onSrcSet); - callback(); - }); -} - function sendContextMenuTo(selector, callback, ignorePreventDefault) { iframe.addEventListener('mozbrowsercontextmenu', function oncontextmenu(e) { iframe.removeEventListener(e.type, oncontextmenu); @@ -232,10 +178,6 @@ function createIframe(callback) { '' + '' + '' + - '' + - '' + - '' + - '' + ''; document.body.appendChild(iframe); @@ -249,15 +191,6 @@ function createIframe(callback) { document.querySelector(msg.data.selector).dispatchEvent(evt); }); - addMessageListener('setsrc', function onContextMenu(msg) { - var wrappedTarget = content.document.querySelector(msg.data.selector); - var target = XPCNativeWrapper.unwrap(wrappedTarget); - target.addEventListener('loadedmetadata', function() { - sendAsyncMessage('test:srcset'); - }); - target.src = msg.data.src; - }); - addMessageListener('browser-element-api:call', function onCallback(msg) { if (msg.data.msg_name != 'fire-ctx-callback') return;