Title: [107244] trunk
Revision
107244
Author
[email protected]
Date
2012-02-09 07:49:13 -0800 (Thu, 09 Feb 2012)

Log Message

Setting media element 'src' attribute to "" should trigger load
https://bugs.webkit.org/show_bug.cgi?id=47907

Patch by Arun Patole <[email protected]> on 2012-02-09
Reviewed by Eric Carlson.

Source/WebCore:

Test: media/video-src-empty.html

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::attributeChanged):Trigger a load, as long as the 'src' attribute is present.

LayoutTests:

* media/video-src-empty-expected.txt: Added, test for <video> with empty src.
* media/video-src-empty.html: Added.
* media/video-src-none-expected.txt:
* media/video-src-none.html: removed "empty src" test as it is handled in separate test: video-src-empty.html.
* platform/chromium/test_expectations.txt: media/video-empty-source.html needs a rebaseline.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (107243 => 107244)


--- trunk/LayoutTests/ChangeLog	2012-02-09 15:40:32 UTC (rev 107243)
+++ trunk/LayoutTests/ChangeLog	2012-02-09 15:49:13 UTC (rev 107244)
@@ -1,3 +1,16 @@
+2012-02-09  Arun Patole  <[email protected]>
+
+        Setting media element 'src' attribute to "" should trigger load
+        https://bugs.webkit.org/show_bug.cgi?id=47907
+
+        Reviewed by Eric Carlson.
+
+        * media/video-src-empty-expected.txt: Added, test for <video> with empty src.
+        * media/video-src-empty.html: Added.
+        * media/video-src-none-expected.txt:
+        * media/video-src-none.html: removed "empty src" test as it is handled in separate test: video-src-empty.html.
+        * platform/chromium/test_expectations.txt: media/video-empty-source.html needs a rebaseline.
+
 2012-02-09  Pavel Feldman  <[email protected]>
 
         Web Inspector: fix setOuterHTML for the case that adds / removes duplicate.

Added: trunk/LayoutTests/media/video-src-empty-expected.txt (0 => 107244)


--- trunk/LayoutTests/media/video-src-empty-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/media/video-src-empty-expected.txt	2012-02-09 15:49:13 UTC (rev 107244)
@@ -0,0 +1,21 @@
+<video> element with src="" should invoke media element's load algorithm and should fire 'error' event. Network state should be NETWORK_NO_SOURCE and set error to MEDIA_ERR_SRC_NOT_SUPPORTED.
+
+** <video> with valid non-empty 'src' attribute**
+EVENT(loadstart)
+EVENT(loadedmetadata)
+EVENT(loadeddata)
+EVENT(canplaythrough)
+
+** <video> with empty src attribute**
+RUN(video.src = ""
+EVENT(abort)
+EVENT(emptied)
+EVENT(loadstart)
+EVENT(error)
+
+'error' event:
+EXPECTED (event.target == '[object HTMLVideoElement]') OK
+EXPECTED (video.error.code == '4') OK
+EXPECTED (video.networkState == '3') OK
+END OF TEST
+

Added: trunk/LayoutTests/media/video-src-empty.html (0 => 107244)


--- trunk/LayoutTests/media/video-src-empty.html	                        (rev 0)
+++ trunk/LayoutTests/media/video-src-empty.html	2012-02-09 15:49:13 UTC (rev 107244)
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <script src=""
+        <script src=""
+        <script>
+            
+            function start()
+            {
+                findMediaElement();
+
+                waitForEvent("loadstart");
+                waitForEvent("loadedmetadata");
+                waitForEvent("loadeddata");
+                waitForEvent("abort");
+                waitForEvent("emptied");
+                waitForEvent("canplaythrough", testLoad);
+                waitForEvent("error", errorEvent);
+                consoleWrite("** &lt;video&gt; with valid non-empty 'src' attribute**");
+                video.src = "" "content/test");
+            }
+
+            function errorEvent()
+            {
+                consoleWrite("<br>'error' event:");
+                testExpected('event.target', video);
+                testExpected("video.error.code", MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED);
+                testExpected("video.networkState", HTMLMediaElement.NETWORK_NO_SOURCE);
+                endTest();
+            }
+
+            function testLoad()
+            {
+                consoleWrite("<br>** &lt;video&gt; with empty src attribute**");
+                run('video.src = ""
+            }
+        </script>
+    </head>
+    <body _onload_="start()">
+        <video width=320 height=60 controls></video>
+        <p> &lt;video&gt; element with src="" should invoke media element's load algorithm and should fire 'error' event. Network state should be NETWORK_NO_SOURCE and set error to MEDIA_ERR_SRC_NOT_SUPPORTED.</p>
+    </body>
+</html>

Modified: trunk/LayoutTests/media/video-src-none-expected.txt (107243 => 107244)


--- trunk/LayoutTests/media/video-src-none-expected.txt	2012-02-09 15:40:32 UTC (rev 107243)
+++ trunk/LayoutTests/media/video-src-none-expected.txt	2012-02-09 15:49:13 UTC (rev 107244)
@@ -1,22 +1,10 @@
- 
 
-Network state should remain in NETWORK_EMPTY with empty or missing 'src' attribute.
+Network state should remain in NETWORK_EMPTY with missing 'src' attribute.
 ** <video> with no src attribute**
 EXPECTED (videos[0].error == 'null') OK
 EXPECTED (videos[0].networkState == '0') OK
 EXPECTED (videos[0].src == '') OK
-** <video> with empty src attribute **
-EXPECTED (videos[1].error == 'null') OK
-EXPECTED (videos[1].networkState == '0') OK
-EXPECTED (relativeURL(videos[1].src) == 'video-src-none.html') OK
 
-Calling load() with empty 'src' should fire 'error' event, set network state to NETWORK_NO_SOURCE, and set error to MEDIA_ERR_SRC_NOT_SUPPORTED.
-'error' event:
-EXPECTED (state == 'load() with empty 'src'') OK
-EXPECTED ([object HTMLVideoElement] == '[object HTMLVideoElement]') OK
-EXPECTED (videos[1].error.code == '4') OK
-EXPECTED (videos[1].networkState == '3') OK
-
 Calling load() with no 'src' should NOT fire 'error' event, set network state to NETWORK_EMPTY.
 EXPECTED (state == 'load() with missing 'src'') OK
 EXPECTED (videos[0].error == 'null') OK

Modified: trunk/LayoutTests/media/video-src-none.html (107243 => 107244)


--- trunk/LayoutTests/media/video-src-none.html	2012-02-09 15:40:32 UTC (rev 107243)
+++ trunk/LayoutTests/media/video-src-none.html	2012-02-09 15:49:13 UTC (rev 107244)
@@ -16,44 +16,29 @@
 
             function errorEvent()
             {
-                consoleWrite("'error' event:");
-                testExpected("state", "load() with empty 'src'");
-                testExpected(event.target, videos[1]);
-                testExpected("videos[1].error.code", MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED);
-                testExpected("videos[1].networkState", HTMLMediaElement.NETWORK_NO_SOURCE);
-
-                consoleWrite("<br><i>Calling load() with no 'src' should NOT fire 'error' event, set network state to NETWORK_EMPTY.<" + "/i>");
-                state = "load() with missing 'src'";
-                videos[0].load();
-
-                setTimeout(someTimeLater, 100) ;
+                failTest("<br><i>***'error' event fired***<" + "/i>");
             }
 
             function test()
             {
                 videos = document.querySelectorAll('video');
 
-                consoleWrite("<br><i>Network state should remain in NETWORK_EMPTY with empty or missing 'src' attribute.<" + "/i>");
+                consoleWrite("<br><i>Network state should remain in NETWORK_EMPTY with missing 'src' attribute.<" + "/i>");
                 consoleWrite("** &lt;video&gt; with no src attribute**");
                 testExpected("videos[0].error", null);
                 testExpected("videos[0].networkState", HTMLMediaElement.NETWORK_EMPTY);
                 testExpected("videos[0].src", "");
 
-                consoleWrite("** &lt;video&gt; with empty src attribute **");
-                testExpected("videos[1].error", null);
-                testExpected("videos[1].networkState", HTMLMediaElement.NETWORK_EMPTY);
-                testExpected("relativeURL(videos[1].src)", "video-src-none.html");
+                consoleWrite("<br><i>Calling load() with no 'src' should NOT fire 'error' event, set network state to NETWORK_EMPTY.<" + "/i>");
+                state = "load() with missing 'src'";
+                videos[0].load();
 
-                consoleWrite("<br><" + "i>Calling load() with empty 'src' should fire 'error' event, set network state to NETWORK_NO_SOURCE, and set error to MEDIA_ERR_SRC_NOT_SUPPORTED.<" + "/i>");
-                state = "load() with empty 'src'";
-                videos[1].load();
+                setTimeout(someTimeLater, 100) ;
             }
         </script>
     </head>
 
     <body _onload_="setTimeout(test, 100)">
         <video width=320 height=60 controls _onerror_="errorEvent()"></video>
-        <br>
-        <video width=320 height=60 controls src="" _onerror_="errorEvent()"></video>
     </body>
 </html>

Modified: trunk/LayoutTests/platform/chromium/test_expectations.txt (107243 => 107244)


--- trunk/LayoutTests/platform/chromium/test_expectations.txt	2012-02-09 15:40:32 UTC (rev 107243)
+++ trunk/LayoutTests/platform/chromium/test_expectations.txt	2012-02-09 15:49:13 UTC (rev 107244)
@@ -4012,3 +4012,6 @@
 
 // Some of the new baselines don't make any sense.
 BUGWK78175 DEBUG SNOWLEOPARD : compositing/overflow/overflow-scaled-descendant-overlapping.html = IMAGE
+
+// Just needs a rebaseline.
+BUGWK47907 : media/video-empty-source.html = IMAGE+TEXT

Modified: trunk/Source/WebCore/ChangeLog (107243 => 107244)


--- trunk/Source/WebCore/ChangeLog	2012-02-09 15:40:32 UTC (rev 107243)
+++ trunk/Source/WebCore/ChangeLog	2012-02-09 15:49:13 UTC (rev 107244)
@@ -1,3 +1,15 @@
+2012-02-09  Arun Patole  <[email protected]>
+
+        Setting media element 'src' attribute to "" should trigger load
+        https://bugs.webkit.org/show_bug.cgi?id=47907
+
+        Reviewed by Eric Carlson.
+
+        Test: media/video-src-empty.html
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::attributeChanged):Trigger a load, as long as the 'src' attribute is present.
+
 2012-02-09  Jonathan Backer  <[email protected]>
 
         [chromium] Add setNeedsRedraw to WebWidget

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (107243 => 107244)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2012-02-09 15:40:32 UTC (rev 107243)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2012-02-09 15:49:13 UTC (rev 107244)
@@ -327,7 +327,7 @@
     const QualifiedName& attrName = attr->name();
     if (attrName == srcAttr) {
         // Trigger a reload, as long as the 'src' attribute is present.
-        if (!getAttribute(srcAttr).isEmpty())
+        if (fastHasAttribute(srcAttr))
             scheduleLoad(MediaResource);
     } else if (attrName == controlsAttr)
         configureMediaControls();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to