Opening a URL in a MediaDocument does not propagate MIME type info to media element
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Mar 2012 21:34:23 +0000 (21:34 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Mar 2012 21:34:23 +0000 (21:34 +0000)
https://bugs.webkit.org/show_bug.cgi?id=81148

Reviewed by Eric Carlson.

Source/WebCore:

Test: http/tests/media/media-document.html

Pass through the mime type from the DocumentLoader into the <source type=""> attribute of the
generated video element.

* html/MediaDocument.cpp:
(WebCore::MediaDocumentParser::createDocumentStructure):

LayoutTests:

* http/tests/media/media-document-expected.txt: Added.
* http/tests/media/media-document.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/http/tests/media/media-document-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/media/media-document.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/html/MediaDocument.cpp

index ed8f5c6..b47f06b 100644 (file)
@@ -1,3 +1,13 @@
+2012-03-14  Jer Noble  <jer.noble@apple.com>
+
+        Opening a URL in a MediaDocument does not propagate MIME type info to media element
+        https://bugs.webkit.org/show_bug.cgi?id=81148
+
+        Reviewed by Eric Carlson.
+
+        * http/tests/media/media-document-expected.txt: Added.
+        * http/tests/media/media-document.html: Added.
+
 2012-03-14  David Grogan  <dgrogan@chromium.org>
 
         IndexedDB layout tests: factor out prefix-handling-code
diff --git a/LayoutTests/http/tests/media/media-document-expected.txt b/LayoutTests/http/tests/media/media-document-expected.txt
new file mode 100644 (file)
index 0000000..4b690ed
--- /dev/null
@@ -0,0 +1,6 @@
+
+Tests that a media document can open a media URL with an ambiguous extension. 
+
+EXPECTED (frame.contentDocument.getElementsByTagName('video')[0].error == 'null') OK
+END OF TEST
+
diff --git a/LayoutTests/http/tests/media/media-document.html b/LayoutTests/http/tests/media/media-document.html
new file mode 100644 (file)
index 0000000..cd2d9cb
--- /dev/null
@@ -0,0 +1,29 @@
+<html>
+    <head>
+        <script src=../../media-resources/video-test.js></script>
+        <script src=../../media-resources/media-file.js></script>
+        <script>
+            var frame;
+            function loadMediaFrame() 
+            {
+                var movie = findMediaFile('video', 'test');
+                var type = mimeTypeForExtension(movie.split('.').pop());
+                frame = document.createElement('iframe');
+                frame.addEventListener('load', function () {
+                    testExpected("frame.contentDocument.getElementsByTagName('video')[0].error", null);
+                    endTest();
+                });
+                waitForEventAndFail('error');
+                waitForEventAndEnd('canplay');
+                frame.src = 'resources/video-check-useragent.php?name=' + movie + '&type=' + type;
+                document.body.appendChild(frame);
+            }
+        </script>
+    </head>
+
+    <body onload="loadMediaFrame()">
+        <br>
+        Tests that a media document can open a media URL with an ambiguous extension.
+        <br>
+    </body>
+</html>
index bfd481e..11b1b98 100644 (file)
@@ -1,3 +1,18 @@
+2012-03-14  Jer Noble  <jer.noble@apple.com>
+
+        Opening a URL in a MediaDocument does not propagate MIME type info to media element
+        https://bugs.webkit.org/show_bug.cgi?id=81148
+
+        Reviewed by Eric Carlson.
+
+        Test: http/tests/media/media-document.html
+
+        Pass through the mime type from the DocumentLoader into the <source type=""> attribute of the
+        generated video element. 
+
+        * html/MediaDocument.cpp:
+        (WebCore::MediaDocumentParser::createDocumentStructure):
+
 2012-03-14  Stephen White  <senorblanco@chromium.org>
 
         [chromium] Fix accelerated Canvas2D with threaded compositing.
index cb971f5..58ff496 100644 (file)
@@ -35,6 +35,7 @@
 #include "HTMLEmbedElement.h"
 #include "HTMLHtmlElement.h"
 #include "HTMLNames.h"
+#include "HTMLSourceElement.h"
 #include "HTMLVideoElement.h"
 #include "KeyboardEvent.h"
 #include "MainResourceLoader.h"
@@ -89,8 +90,15 @@ void MediaDocumentParser::createDocumentStructure()
     m_mediaElement->setAttribute(autoplayAttr, "");
 
     m_mediaElement->setAttribute(nameAttr, "media");
-    m_mediaElement->setSrc(document()->url());
-    
+
+    RefPtr<Element> sourceElement = document()->createElement(sourceTag, false);
+    HTMLSourceElement* source = static_cast<HTMLSourceElement*>(sourceElement.get());
+    source->setSrc(document()->url());
+
+    if (DocumentLoader* loader = document()->loader())
+        source->setType(loader->responseMIMEType());
+
+    m_mediaElement->appendChild(sourceElement, ec);
     body->appendChild(mediaElement, ec);
 
     Frame* frame = document()->frame();