video.currentSrc should return empty when no resource is loaded
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Nov 2013 20:11:31 +0000 (20:11 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Nov 2013 20:11:31 +0000 (20:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=124898

Reviewed by Dan Bernstein.

Source/WebCore:

Test: media/video-currentsrc-cleared.html

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::prepareForLoad): Set m_currentSrc to empty in
    preparation for attempting to load a new url.

LayoutTests:

* media/video-currentsrc-cleared-expected.txt: Added.
* media/video-currentsrc-cleared.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/media/video-currentsrc-cleared-expected.txt [new file with mode: 0644]
LayoutTests/media/video-currentsrc-cleared.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLMediaElement.cpp

index 3ad3f79..6a8dee7 100644 (file)
@@ -1,3 +1,13 @@
+2013-11-26  Eric Carlson  <eric.carlson@apple.com>
+
+        video.currentSrc should return empty when no resource is loaded
+        https://bugs.webkit.org/show_bug.cgi?id=124898
+
+        Reviewed by Dan Bernstein.
+
+        * media/video-currentsrc-cleared-expected.txt: Added.
+        * media/video-currentsrc-cleared.html: Added.
+
 2013-11-26  Hans Muller  <hmuller@adobe.com>
 
         [CSS Shapes] Support for shape-margin in BoxShape
diff --git a/LayoutTests/media/video-currentsrc-cleared-expected.txt b/LayoutTests/media/video-currentsrc-cleared-expected.txt
new file mode 100644 (file)
index 0000000..da0d10a
--- /dev/null
@@ -0,0 +1,12 @@
+
+Check that 'currentsrc' is cleared when there is no media resource.
+
+EVENT(canplaythrough)
+EXPECTED (video.currentSrc.indexOf("content/test") > '-1') OK
+RUN(video.src = "")
+
+EVENT(error)
+EXPECTED (video.currentSrc == '') OK
+
+END OF TEST
+
diff --git a/LayoutTests/media/video-currentsrc-cleared.html b/LayoutTests/media/video-currentsrc-cleared.html
new file mode 100644 (file)
index 0000000..527eb0b
--- /dev/null
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <script src=media-file.js></script>
+        <script src=video-test.js></script>
+        <script>
+            function error()
+            {
+                testExpected('video.currentSrc', '');
+                consoleWrite('');
+                endTest();
+            }
+
+            function canplaythrough()
+            {
+                testExpected('video.currentSrc.indexOf("content/test")', -1, '>');
+                run('video.src = ""');
+                consoleWrite('');
+            }
+
+            function start()
+            {
+                findMediaElement();
+                waitForEvent('error', error);
+                waitForEvent('canplaythrough', canplaythrough);
+                video.src = findMediaFile("video", "content/test");
+            }
+        </script>
+    </head>
+    <body onload="start()">
+        <video ></video>
+        <p>Check that 'currentsrc' is cleared when there is no media resource.</p>
+    </body>
+</html>
index 9ef4e0b..932dc13 100644 (file)
@@ -1,3 +1,16 @@
+2013-11-26  Eric Carlson  <eric.carlson@apple.com>
+
+        video.currentSrc should return empty when no resource is loaded
+        https://bugs.webkit.org/show_bug.cgi?id=124898
+
+        Reviewed by Dan Bernstein.
+
+        Test: media/video-currentsrc-cleared.html
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::prepareForLoad): Set m_currentSrc to empty in 
+            preparation for attempting to load a new url.
+
 2013-11-26  Hans Muller  <hmuller@adobe.com>
 
         [CSS Shapes] Support for shape-margin in BoxShape
index a76cf0b..44744d9 100644 (file)
@@ -815,6 +815,7 @@ void HTMLMediaElement::prepareForLoad()
     m_completelyLoaded = false;
     m_havePreparedToPlay = false;
     m_displayMode = Unknown;
+    m_currentSrc = URL();
 
     // 1 - Abort any already-running instance of the resource selection algorithm for this element.
     m_loadState = WaitingForSource;