diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/WindowWidget.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/WindowWidget.java index 4b933ec530..5160d93494 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/WindowWidget.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/WindowWidget.java @@ -901,7 +901,7 @@ public void handleHoverEvent(MotionEvent aEvent) { } else { GeckoSession session = mSession.getGeckoSession(); - if (session != null) { + if (session != null && !isContextMenuVisible()) { session.getPanZoomController().onMotionEvent(aEvent); } } @@ -1594,6 +1594,11 @@ public void reject() { } } + private boolean isContextMenuVisible() { + return (mContextMenu != null && mContextMenu.isVisible() || + mSelectionMenu != null && mSelectionMenu.isVisible()); + } + // GeckoSession.ContentDelegate @Override diff --git a/app/src/main/assets/web_extensions/webcompat_youtube/main.js b/app/src/main/assets/web_extensions/webcompat_youtube/main.js index 52eb0f8ddd..3e357fb45f 100644 --- a/app/src/main/assets/web_extensions/webcompat_youtube/main.js +++ b/app/src/main/assets/web_extensions/webcompat_youtube/main.js @@ -8,7 +8,8 @@ const YT_SELECTORS = { embedPlayer: '.html5-video-player', largePlayButton: '.ytp-large-play-button', thumbnail: '.ytp-cued-thumbnail-overlay-image', - embedTitle: '.ytp-title-text' + embedTitle: '.ytp-title-text', + queueHandle: 'ytd-playlist-panel-video-renderer' }; const ENABLE_LOGS = true; const logDebug = (...args) => ENABLE_LOGS && console.log(LOGTAG, ...args); @@ -142,6 +143,27 @@ class YoutubeExtension { } } + fixQueueContextMenu() { + const handles = document.querySelectorAll(YT_SELECTORS.queueHandle); + for (var i=0; i { + var evt = document.createEvent("MouseEvents"); + evt.initEvent("mouseup", true, true); + event.target.dispatchEvent(evt); + }); + + // This is supposed to prevent the context menu from showing but it doesn't seem to work + event.preventDefault(); + event.stopPropagation(); + event.stopImmediatePropagation(); + return false; + } + // Runs the callback when the video is ready (has loaded the first frame). waitForVideoReady(callback) { this.retry("VideoReady", () => { @@ -235,6 +257,7 @@ youtube.overrideViewport(); window.addEventListener('load', () => { logDebug('page load'); youtube.overrideVideoProjection(); + youtube.fixQueueContextMenu(); // Wait until video has loaded the first frame to force quality change. // This prevents the infinite spinner problem. // See https://github.com/MozillaReality/FirefoxReality/issues/1433 @@ -246,3 +269,4 @@ window.addEventListener('load', () => { window.addEventListener('pushstate', () => youtube.overrideVideoProjection()); window.addEventListener('popstate', () => youtube.overrideVideoProjection()); window.addEventListener('click', event => youtube.overrideClick(event)); +window.addEventListener('mouseup', event => youtube.fixQueueContextMenu());