Bug 1352724 - Pause video at the point when scrubber is being click. r=jaws draft
authorRay Lin <ralin@mozilla.com>
Wed, 26 Apr 2017 17:09:12 +0800
changeset 578180 08f339eddfeab974472548d8bb86324a889305ab
parent 578175 3e166b6838931b3933ca274331f9e0e115af5cc0
child 578181 0349b816121ca4e991c1186751a410c067cb093d
push id58922
push userbmo:ralin@mozilla.com
push dateTue, 16 May 2017 02:12:23 +0000
reviewersjaws
bugs1352724
milestone55.0a1
Bug 1352724 - Pause video at the point when scrubber is being click. r=jaws MozReview-Commit-ID: 5JuDivYzhoJ
toolkit/content/tests/widgets/test_videocontrols.html
toolkit/content/widgets/videocontrols.xml
--- a/toolkit/content/tests/widgets/test_videocontrols.html
+++ b/toolkit/content/tests/widgets/test_videocontrols.html
@@ -384,20 +384,49 @@ function runTest(event) {
         synthesizeKey(" ", {});
       });
       break;
 
     case 28:
       is(event.type, "pause", "checking event type");
 
       SimpleTest.executeSoon(() => {
-        SimpleTest.finish();
+        synthesizeMouse(video, playButtonCenterX, playButtonCenterY, { });
+      });
+      break;
+
+    case 29:
+      is(event.type, "play", "checking event type");
+
+      SimpleTest.executeSoon(() => {
+        // Bug 1352724: Click and hold on timeline should pause video immediately.
+        synthesizeMouse(video, scrubberOffsetX + 10, scrubberCenterY, { type: "mousedown", button: 0 });
       });
       break;
 
+    case 30:
+      is(event.type, "pause", "checking event type");
+      break;
+
+    case 31:
+      is(event.type, "seeking", "checking event type");
+      ok(true, "video position is at " + video.currentTime);
+      break;
+
+    case 32:
+      is(event.type, "seeked", "checking event type");
+      ok(true, "video position is at " + video.currentTime);
+      synthesizeMouse(video, scrubberOffsetX + 10, scrubberCenterY, {});
+      break;
+
+    case 33:
+      is(event.type, "play", "checking event type");
+      ok(true, "video resume after mouseup");
+      SimpleTest.finish();
+      break;
 
 
     default:
       throw "unexpected test #" + testnum + " w/ event " + event.type;
   }
 
   testnum++;
 }
--- a/toolkit/content/widgets/videocontrols.xml
+++ b/toolkit/content/widgets/videocontrols.xml
@@ -650,17 +650,17 @@
             // If we've seen more than 2 timeupdate events,
             // the count is no longer relevant to setupStatusFader.
             if (this.timeUpdateCount <= 2) {
               this.setupStatusFader();
             }
 
             // If the user is dragging the scrubber ignore the delayed seek
             // responses (don't yank the thumb away from the user)
-            if (this.scrubber.isDragging || this.scrubber.startToDrag) {
+            if (this.scrubber.isDragging) {
               return;
             }
             this.showPosition(currentTime, duration);
             this.showBuffered();
             break;
           case "emptied":
             this.bufferBar.value = 0;
             this.showPosition(0, 0);
@@ -894,26 +894,24 @@
           this.video.pause();
         }
       },
 
       onScrubberInput(e) {
         const duration = Math.round(this.video.duration * 1000); // in ms
         let time = this.scrubber.value;
 
-        if (!this.scrubber.startToDrag || this.scrubber.isDragging) {
-          this.seekToPosition(time);
-          this.showPosition(time, duration);
-        }
+        this.seekToPosition(time);
+        this.showPosition(time, duration);
 
-        this.scrubber.startToDrag = true;
+        this.scrubber.isDragging = true;
+        this.pauseVideoDuringDragging();
       },
 
       onScrubberChange(e) {
-        this.scrubber.startToDrag = false;
         this.scrubber.isDragging = false;
 
         if (this.isPausedByDragging) {
           this.video.play();
           this.isPausedByDragging = false;
         }
       },
 
@@ -1028,22 +1026,16 @@
         if (!Utils.scrubber.isDragging) {
           Utils.startFade(Utils.controlBar, false);
           Utils._hideControlsTimeout = 0;
           Utils._controlsHiddenByTimeout = true;
         }
       },
       HIDE_CONTROLS_TIMEOUT_MS: 2000,
       onMouseMove(event) {
-        // Pause playing video when the mouse is dragging over the control bar.
-        if (this.scrubber.startToDrag) {
-          this.scrubber.isDragging = true;
-          this.pauseVideoDuringDragging();
-        }
-
         // If the controls are static, don't change anything.
         if (!this.dynamicControls) {
           return;
         }
 
         clearTimeout(this._hideControlsTimeout);
 
         // Suppress fading out the controls until the video has rendered