Setting currentTime on HTMLMediaElement with media controller should throw exception.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 15 Feb 2014 18:00:22 +0000 (18:00 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 15 Feb 2014 18:00:22 +0000 (18:00 +0000)
https://bugs.webkit.org/show_bug.cgi?id=128867.

Patch by Piotr Grad <p.grad@samsung.com> on 2014-02-15
Reviewed by Eric Carlson.

Source/WebCore:

Added implementation for setting currentTime in HTMLMediaElement. Old implementation
was left to be used internally.

Test: media/video-controller-currentTime.html

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::parseAttribute):
* html/HTMLMediaElement.h:
* html/HTMLMediaElement.idl:

LayoutTests:

* media/video-controller-currentTime-expected.txt: Added.
* media/video-controller-currentTime.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@164174 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/media/video-controller-currentTime-expected.txt [new file with mode: 0644]
LayoutTests/media/video-controller-currentTime.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/html/HTMLMediaElement.idl

index aba1e9d..b511e18 100644 (file)
@@ -1,3 +1,13 @@
+2014-02-15  Piotr Grad  <p.grad@samsung.com>
+
+        Setting currentTime on HTMLMediaElement with media controller should throw exception.
+        https://bugs.webkit.org/show_bug.cgi?id=128867.
+
+        Reviewed by Eric Carlson.
+
+        * media/video-controller-currentTime-expected.txt: Added.
+        * media/video-controller-currentTime.html: Added.
+
 2014-02-15  Renata Hodovan  <rhodovan.u-szeged@partner.samsung.com>
 
         ASSERT_WITH_SECURITY_IMPLICATION in WebCore::toElement
diff --git a/LayoutTests/media/video-controller-currentTime-expected.txt b/LayoutTests/media/video-controller-currentTime-expected.txt
new file mode 100644 (file)
index 0000000..e19c77c
--- /dev/null
@@ -0,0 +1,7 @@
+
+Test that seeking video with media controller throws invalid state exception.
+
+EVENT(canplaythrough)
+TEST(video.currentTime = 3) THROWS(DOMException.INVALID_STATE_ERR) OK
+END OF TEST
+
diff --git a/LayoutTests/media/video-controller-currentTime.html b/LayoutTests/media/video-controller-currentTime.html
new file mode 100644 (file)
index 0000000..381350d
--- /dev/null
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <script src=media-file.js></script>
+        <script src=video-test.js></script>
+        <script>
+            function start()
+            {
+                findMediaElement();
+                video.src = findMediaFile("video", "content/test");
+                waitForEventOnce('canplaythrough', canPlayThrough);
+            }
+
+            function canPlayThrough()
+            {
+                testDOMException("video.currentTime = 3", "DOMException.INVALID_STATE_ERR");
+                endTest();
+            }
+        </script>
+    </head>
+    <body onload="start()">
+        <video mediaGroup="group" controls></video>
+        <p>Test that seeking video with media controller throws invalid state exception.</p>
+    </body>
+</html>
\ No newline at end of file
index 0681e57..c4b6302 100644 (file)
@@ -1,3 +1,20 @@
+2014-02-15  Piotr Grad  <p.grad@samsung.com>
+
+        Setting currentTime on HTMLMediaElement with media controller should throw exception.
+        https://bugs.webkit.org/show_bug.cgi?id=128867.
+
+        Reviewed by Eric Carlson.
+
+        Added implementation for setting currentTime in HTMLMediaElement. Old implementation
+        was left to be used internally.
+
+        Test: media/video-controller-currentTime.html
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::parseAttribute):
+        * html/HTMLMediaElement.h:
+        * html/HTMLMediaElement.idl:
+
 2014-02-15  Anders Carlsson  <andersca@apple.com>
 
         Form controls are always painted in the active state
index 998b1ef..1dd2534 100644 (file)
@@ -2520,6 +2520,18 @@ void HTMLMediaElement::setCurrentTime(double time)
     seek(time);
 }
 
+void HTMLMediaElement::setCurrentTime(double time, ExceptionCode& ec)
+{
+    // On setting, if the media element has a current media controller, then the user agent must
+    // throw an InvalidStateError exception
+    if (m_mediaController) {
+        ec = INVALID_STATE_ERR;
+        return;
+    }
+
+    seek(time);
+}
+
 double HTMLMediaElement::duration() const
 {
     if (m_player && m_readyState >= HAVE_METADATA)
index 6d5e4e3..b8a46db 100644 (file)
@@ -180,6 +180,7 @@ public:
 // playback state
     virtual double currentTime() const override;
     virtual void setCurrentTime(double) override;
+    virtual void setCurrentTime(double, ExceptionCode&);
     virtual double duration() const override;
     virtual bool paused() const override;
     virtual double defaultPlaybackRate() const override;
index 301194c..7a26ed1 100644 (file)
@@ -63,7 +63,7 @@
     readonly attribute boolean seeking;
 
     // playback state
-    attribute double currentTime;
+    [SetterRaisesException] attribute double currentTime;
     readonly attribute double duration;
     readonly attribute boolean paused;
     attribute double defaultPlaybackRate;