Bug 1568216 - Disable context menu for Picture-in-Picture player window. r=JSON_voorhees
authorMike Conley <mconley@mozilla.com>
Tue, 01 Oct 2019 18:06:52 +0000
changeset 495885 9ba817e4d1bd44a5022cd87aa907533dd3798fb1
parent 495884 5bad9f31e57fb9db6d74e8c1e4a4d40e4dd69f72
child 495886 14d5ab6e22388c6b417a1628214b52da06234432
push id114140
push userdvarga@mozilla.com
push dateWed, 02 Oct 2019 18:04:51 +0000
treeherdermozilla-inbound@32eb0ea893f3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersJSON_voorhees
bugs1568216
milestone71.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1568216 - Disable context menu for Picture-in-Picture player window. r=JSON_voorhees Differential Revision: https://phabricator.services.mozilla.com/D47785
toolkit/components/pictureinpicture/content/player.js
--- a/toolkit/components/pictureinpicture/content/player.js
+++ b/toolkit/components/pictureinpicture/content/player.js
@@ -38,17 +38,24 @@ function setIsPlayingState(isPlaying) {
   Player.isPlaying = isPlaying;
 }
 
 /**
  * The Player object handles initializing the player, holds state, and handles
  * events for updating state.
  */
 let Player = {
-  WINDOW_EVENTS: ["click", "keydown", "mouseout", "resize", "unload"],
+  WINDOW_EVENTS: [
+    "click",
+    "contextmenu",
+    "keydown",
+    "mouseout",
+    "resize",
+    "unload",
+  ],
   mm: null,
   /**
    * Used for resizing Telemetry to avoid recording an event for every resize
    * event. Instead, we wait until RESIZE_DEBOUNCE_RATE_MS has passed since the
    * last resize event before recording.
    */
   resizeDebouncer: null,
   /**
@@ -129,16 +136,21 @@ let Player = {
   handleEvent(event) {
     switch (event.type) {
       case "click": {
         this.onClick(event);
         this.controls.removeAttribute("keying");
         break;
       }
 
+      case "contextmenu": {
+        event.preventDefault();
+        break;
+      }
+
       case "keydown": {
         if (event.keyCode == KeyEvent.DOM_VK_TAB) {
           this.controls.setAttribute("keying", true);
         } else if (event.keyCode == KeyEvent.DOM_VK_ESCAPE) {
           this.controls.removeAttribute("keying");
         }
         break;
       }