Title: [119742] trunk
Revision
119742
Author
[email protected]
Date
2012-06-07 11:37:39 -0700 (Thu, 07 Jun 2012)

Log Message

Plumb CORS attribute information from HTMLMediaElement to media players so it can be used
https://bugs.webkit.org/show_bug.cgi?id=88349

Reviewed by Adam Barth.

Source/WebCore:

Test: http/tests/security/video-cross-origin-readback.html

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::mediaPlayerCORSMode):
(WebCore):
* html/HTMLMediaElement.h:
(HTMLMediaElement):
* html/canvas/CanvasRenderingContext.cpp:
(WebCore::CanvasRenderingContext::wouldTaintOrigin):
* platform/graphics/MediaPlayer.cpp:
(WebCore::MediaPlayer::didPassCORSAccessCheck):
(WebCore):
* platform/graphics/MediaPlayer.h:
(WebCore::MediaPlayerClient::mediaPlayerCORSMode):
(MediaPlayer):
* platform/graphics/MediaPlayerPrivate.h:
(WebCore::MediaPlayerPrivateInterface::didPassCORSAccessCheck):
(MediaPlayerPrivateInterface):

Source/WebKit/chromium:

* public/WebMediaPlayer.h:
(WebMediaPlayer):
* src/AssertMatchingEnums.cpp:
* src/WebMediaPlayerClientImpl.cpp:
(WebKit::WebMediaPlayerClientImpl::loadInternal):
(WebKit::WebMediaPlayerClientImpl::didPassCORSAccessCheck):
(WebKit):
* src/WebMediaPlayerClientImpl.h:
(WebMediaPlayerClientImpl):

LayoutTests:

* http/tests/security/resources/video-cross-origin-allow.php: Added.
* http/tests/security/video-cross-origin-readback-expected.txt: Added.
* http/tests/security/video-cross-origin-readback.html: Added.
* platform/efl/Skipped:
* platform/gtk/TestExpectations:
* platform/mac/Skipped:
* platform/qt/Skipped:
* platform/win/Skipped:
* platform/wk2/Skipped:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (119741 => 119742)


--- trunk/LayoutTests/ChangeLog	2012-06-07 18:32:52 UTC (rev 119741)
+++ trunk/LayoutTests/ChangeLog	2012-06-07 18:37:39 UTC (rev 119742)
@@ -1,3 +1,20 @@
+2012-06-07  Ami Fischman  <[email protected]>
+
+        Plumb CORS attribute information from HTMLMediaElement to media players so it can be used
+        https://bugs.webkit.org/show_bug.cgi?id=88349
+
+        Reviewed by Adam Barth.
+
+        * http/tests/security/resources/video-cross-origin-allow.php: Added.
+        * http/tests/security/video-cross-origin-readback-expected.txt: Added.
+        * http/tests/security/video-cross-origin-readback.html: Added.
+        * platform/efl/Skipped:
+        * platform/gtk/TestExpectations:
+        * platform/mac/Skipped:
+        * platform/qt/Skipped:
+        * platform/win/Skipped:
+        * platform/wk2/Skipped:
+
 2012-06-07  Stephen White  <[email protected]>
 
         Unreviewed; chromium test_expectations update.

Added: trunk/LayoutTests/http/tests/security/resources/video-cross-origin-allow.php (0 => 119742)


--- trunk/LayoutTests/http/tests/security/resources/video-cross-origin-allow.php	                        (rev 0)
+++ trunk/LayoutTests/http/tests/security/resources/video-cross-origin-allow.php	2012-06-07 18:37:39 UTC (rev 119742)
@@ -0,0 +1,13 @@
+<?php
+
+header("Access-Control-Allow-Origin: *");
+
+if ($_SERVER['REQUEST_METHOD'] == "OPTIONS") {
+    header("Access-Control-Allow-Methods: GET");
+    header("Access-Control-Allow-Headers: origin, accept-encoding, referer, range");
+    exit;
+}
+
+@include("../../media/resources/serve-video.php");
+
+?>
\ No newline at end of file

Added: trunk/LayoutTests/http/tests/security/video-cross-origin-readback-expected.txt (0 => 119742)


--- trunk/LayoutTests/http/tests/security/video-cross-origin-readback-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/security/video-cross-origin-readback-expected.txt	2012-06-07 18:37:39 UTC (rev 119742)
@@ -0,0 +1,3 @@
+EVENT(playing)
+END OF TEST
+ 

Added: trunk/LayoutTests/http/tests/security/video-cross-origin-readback.html (0 => 119742)


--- trunk/LayoutTests/http/tests/security/video-cross-origin-readback.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/security/video-cross-origin-readback.html	2012-06-07 18:37:39 UTC (rev 119742)
@@ -0,0 +1,33 @@
+<html>
+  <body _onload_="start()">
+    <script src=""
+    <script src=""
+    <script>
+        waitForEvent('error', function() {
+            failTest("error: " + JSON.stringify(video.error));
+        });
+
+        waitForEvent('playing', function() {
+          try {
+              var ctx = document.getElementsByTagName('canvas')[0].getContext("2d");
+              ctx.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);
+              ctx.getImageData(0, 0, video.videoWidth, video.videoHeight);
+          } catch (e) {
+              failTest("Caught error: " + e);
+          }
+          endTest();
+        });
+
+        function start() {
+            findMediaElement();
+            var mediaFile = findMediaFile("video", "../../media/resources/test");
+            var type = mimeTypeForExtension(mediaFile.split('.').pop());
+            video.src = "" + mediaFile + "&type=" + type;
+            video.play();
+        }
+    </script>
+
+    <video crossorigin></video>
+    <canvas></canvas>
+  </body>
+</head>

Modified: trunk/LayoutTests/platform/efl/Skipped (119741 => 119742)


--- trunk/LayoutTests/platform/efl/Skipped	2012-06-07 18:32:52 UTC (rev 119741)
+++ trunk/LayoutTests/platform/efl/Skipped	2012-06-07 18:37:39 UTC (rev 119742)
@@ -302,6 +302,9 @@
 fast/images/exif-orientation.html
 fast/images/exif-orientation-css.html
 
+# No CORS support for media elements is implemented yet.
+http/tests/security/video-cross-origin-readback.html
+
 # --------------------------------
 # Tests which are expected to fail
 # --------------------------------

Modified: trunk/LayoutTests/platform/gtk/TestExpectations (119741 => 119742)


--- trunk/LayoutTests/platform/gtk/TestExpectations	2012-06-07 18:32:52 UTC (rev 119741)
+++ trunk/LayoutTests/platform/gtk/TestExpectations	2012-06-07 18:37:39 UTC (rev 119742)
@@ -316,6 +316,9 @@
 // CSS Variables are not yet enabled.
 BUGWK85580 SKIP : fast/css/variables = PASS FAIL
 
+// No CORS support for media elements is implemented yet.
+BUGWKGTK SKIP : http/tests/security/video-cross-origin-readback.html = FAIL
+
 //////////////////////////////////////////////////////////////////////////////////////////
 // End of Expected failures
 //////////////////////////////////////////////////////////////////////////////////////////

Modified: trunk/LayoutTests/platform/mac/Skipped (119741 => 119742)


--- trunk/LayoutTests/platform/mac/Skipped	2012-06-07 18:32:52 UTC (rev 119741)
+++ trunk/LayoutTests/platform/mac/Skipped	2012-06-07 18:37:39 UTC (rev 119742)
@@ -813,6 +813,9 @@
 fast/sub-pixel/selection/selection-gaps-at-fractional-offsets.html
 fast/sub-pixel/file-upload-control-at-fractional-offset.html
 
+# No CORS support for media elements is implemented yet.
+http/tests/security/video-cross-origin-readback.html
+
 # media/audio-repaint.html sometimes fails on Lion Debug (Tests)
 # https://bugs.webkit.org/show_bug.cgi?id=84357
 media/audio-repaint.html

Modified: trunk/LayoutTests/platform/qt/Skipped (119741 => 119742)


--- trunk/LayoutTests/platform/qt/Skipped	2012-06-07 18:32:52 UTC (rev 119741)
+++ trunk/LayoutTests/platform/qt/Skipped	2012-06-07 18:37:39 UTC (rev 119742)
@@ -433,6 +433,9 @@
 fast/events/page-visibility-iframe-propagation-test.html
 fast/events/page-visibility-transition-test.html
 
+# No CORS support for media elements is implemented yet.
+http/tests/security/video-cross-origin-readback.html
+
 # =========================================================================== #
 #       Drag and Drop Support in DRT.                                         #
 # =========================================================================== #

Modified: trunk/LayoutTests/platform/win/Skipped (119741 => 119742)


--- trunk/LayoutTests/platform/win/Skipped	2012-06-07 18:32:52 UTC (rev 119741)
+++ trunk/LayoutTests/platform/win/Skipped	2012-06-07 18:37:39 UTC (rev 119742)
@@ -1752,6 +1752,9 @@
 fast/sub-pixel/selection/selection-gaps-at-fractional-offsets.html
 fast/sub-pixel/file-upload-control-at-fractional-offset.html
 
+# No CORS support for media elements is implemented yet.
+http/tests/security/video-cross-origin-readback.html
+
 # http://webkit.org/b/82886
 inspector/styles/override-screen-size.html
 

Modified: trunk/LayoutTests/platform/wk2/Skipped (119741 => 119742)


--- trunk/LayoutTests/platform/wk2/Skipped	2012-06-07 18:32:52 UTC (rev 119741)
+++ trunk/LayoutTests/platform/wk2/Skipped	2012-06-07 18:37:39 UTC (rev 119742)
@@ -1055,6 +1055,9 @@
 # https://bugs.webkit.org/show_bug.cgi?id=87162
 editing/inserting/typing-space-to-trigger-smart-link.html
 
+# No CORS support for media elements is implemented yet.
+http/tests/security/video-cross-origin-readback.html
+
 ### END OF (2) Classified failures without bug reports (yet)
 ########################################
 

Modified: trunk/Source/WebCore/ChangeLog (119741 => 119742)


--- trunk/Source/WebCore/ChangeLog	2012-06-07 18:32:52 UTC (rev 119741)
+++ trunk/Source/WebCore/ChangeLog	2012-06-07 18:37:39 UTC (rev 119742)
@@ -1,3 +1,29 @@
+2012-06-07  Ami Fischman  <[email protected]>
+
+        Plumb CORS attribute information from HTMLMediaElement to media players so it can be used
+        https://bugs.webkit.org/show_bug.cgi?id=88349
+
+        Reviewed by Adam Barth.
+
+        Test: http/tests/security/video-cross-origin-readback.html
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::mediaPlayerCORSMode):
+        (WebCore):
+        * html/HTMLMediaElement.h:
+        (HTMLMediaElement):
+        * html/canvas/CanvasRenderingContext.cpp:
+        (WebCore::CanvasRenderingContext::wouldTaintOrigin):
+        * platform/graphics/MediaPlayer.cpp:
+        (WebCore::MediaPlayer::didPassCORSAccessCheck):
+        (WebCore):
+        * platform/graphics/MediaPlayer.h:
+        (WebCore::MediaPlayerClient::mediaPlayerCORSMode):
+        (MediaPlayer):
+        * platform/graphics/MediaPlayerPrivate.h:
+        (WebCore::MediaPlayerPrivateInterface::didPassCORSAccessCheck):
+        (MediaPlayerPrivateInterface):
+
 2012-06-07  Mark Hahnenberg  <[email protected]>
 
         Worker tear-down can re-enter JSC during GC finalization

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (119741 => 119742)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2012-06-07 18:32:52 UTC (rev 119741)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2012-06-07 18:37:39 UTC (rev 119742)
@@ -4456,6 +4456,15 @@
 
 }
 
+MediaPlayerClient::CORSMode HTMLMediaElement::mediaPlayerCORSMode() const
+{
+    if (!fastHasAttribute(HTMLNames::crossoriginAttr))
+        return Unspecified;
+    if (equalIgnoringCase(fastGetAttribute(HTMLNames::crossoriginAttr), "use-credentials"))
+        return UseCredentials;
+    return Anonymous;
+}
+
 bool HTMLMediaElement::mediaPlayerNeedsSiteSpecificHacks() const
 {
     Settings* settings = document()->settings();

Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (119741 => 119742)


--- trunk/Source/WebCore/html/HTMLMediaElement.h	2012-06-07 18:32:52 UTC (rev 119741)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h	2012-06-07 18:37:39 UTC (rev 119742)
@@ -427,6 +427,7 @@
 
     virtual String mediaPlayerReferrer() const OVERRIDE;
     virtual String mediaPlayerUserAgent() const OVERRIDE;
+    virtual CORSMode mediaPlayerCORSMode() const OVERRIDE;
 
     virtual bool mediaPlayerNeedsSiteSpecificHacks() const OVERRIDE;
     virtual String mediaPlayerDocumentHost() const OVERRIDE;

Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext.cpp (119741 => 119742)


--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext.cpp	2012-06-07 18:32:52 UTC (rev 119741)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext.cpp	2012-06-07 18:37:39 UTC (rev 119742)
@@ -77,11 +77,12 @@
     if (!video || !canvas()->originClean())
         return false;
 
-    if (wouldTaintOrigin(video->currentSrc()))
+    if (!video->hasSingleSecurityOrigin())
         return true;
 
-    if (!video->hasSingleSecurityOrigin())
+    if (!(video->player() && video->player()->didPassCORSAccessCheck()) && wouldTaintOrigin(video->currentSrc()))
         return true;
+
 #else
     UNUSED_PARAM(video);
 #endif

Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp (119741 => 119742)


--- trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp	2012-06-07 18:32:52 UTC (rev 119741)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp	2012-06-07 18:37:39 UTC (rev 119742)
@@ -834,6 +834,11 @@
     return m_private->hasSingleSecurityOrigin();
 }
 
+bool MediaPlayer::didPassCORSAccessCheck() const
+{
+    return m_private->didPassCORSAccessCheck();
+}
+
 MediaPlayer::MovieLoadType MediaPlayer::movieLoadType() const
 {
     return m_private->movieLoadType();

Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.h (119741 => 119742)


--- trunk/Source/WebCore/platform/graphics/MediaPlayer.h	2012-06-07 18:32:52 UTC (rev 119741)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.h	2012-06-07 18:37:39 UTC (rev 119742)
@@ -101,6 +101,8 @@
 
 class MediaPlayerClient {
 public:
+    enum CORSMode { Unspecified, Anonymous, UseCredentials };
+
     virtual ~MediaPlayerClient() { }
 
     // Get the document which the media player is owned by
@@ -178,6 +180,7 @@
 
     virtual String mediaPlayerReferrer() const { return String(); }
     virtual String mediaPlayerUserAgent() const { return String(); }
+    virtual CORSMode mediaPlayerCORSMode() const { return Unspecified; }
 };
 
 class MediaPlayerSupportsTypeClient {
@@ -354,6 +357,8 @@
 
     bool hasSingleSecurityOrigin() const;
 
+    bool didPassCORSAccessCheck() const;
+
     float mediaTimeForTimeValue(float) const;
 
     double maximumDurationToCacheMediaTime() const;

Modified: trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h (119741 => 119742)


--- trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h	2012-06-07 18:32:52 UTC (rev 119741)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h	2012-06-07 18:37:39 UTC (rev 119742)
@@ -135,6 +135,8 @@
 
     virtual bool hasSingleSecurityOrigin() const { return false; }
 
+    virtual bool didPassCORSAccessCheck() const { return false; }
+
     virtual MediaPlayer::MovieLoadType movieLoadType() const { return MediaPlayer::Unknown; }
 
     virtual void prepareForRendering() { }

Modified: trunk/Source/WebKit/chromium/ChangeLog (119741 => 119742)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-06-07 18:32:52 UTC (rev 119741)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-06-07 18:37:39 UTC (rev 119742)
@@ -1,3 +1,20 @@
+2012-06-07  Ami Fischman  <[email protected]>
+
+        Plumb CORS attribute information from HTMLMediaElement to media players so it can be used
+        https://bugs.webkit.org/show_bug.cgi?id=88349
+
+        Reviewed by Adam Barth.
+
+        * public/WebMediaPlayer.h:
+        (WebMediaPlayer):
+        * src/AssertMatchingEnums.cpp:
+        * src/WebMediaPlayerClientImpl.cpp:
+        (WebKit::WebMediaPlayerClientImpl::loadInternal):
+        (WebKit::WebMediaPlayerClientImpl::didPassCORSAccessCheck):
+        (WebKit):
+        * src/WebMediaPlayerClientImpl.h:
+        (WebMediaPlayerClientImpl):
+
 2012-06-07  Daniel Erat  <[email protected]>
 
         Add setting to enable subpixel-positioned text on Linux.

Modified: trunk/Source/WebKit/chromium/public/WebMediaPlayer.h (119741 => 119742)


--- trunk/Source/WebKit/chromium/public/WebMediaPlayer.h	2012-06-07 18:32:52 UTC (rev 119741)
+++ trunk/Source/WebKit/chromium/public/WebMediaPlayer.h	2012-06-07 18:37:39 UTC (rev 119742)
@@ -108,7 +108,7 @@
 
     virtual ~WebMediaPlayer() {}
 
-    virtual void load(const WebURL&) = 0;
+    virtual void load(const WebURL&, CORSMode) = 0;
     virtual void cancelLoad() = 0;
 
     // Playback controls.
@@ -154,6 +154,7 @@
     virtual unsigned long long totalBytes() const = 0;
 
     virtual bool hasSingleSecurityOrigin() const = 0;
+    virtual bool didPassCORSAccessCheck() const = 0;
     virtual MovieLoadType movieLoadType() const = 0;
 
     virtual float mediaTimeForTimeValue(float timeValue) const = 0;

Modified: trunk/Source/WebKit/chromium/src/AssertMatchingEnums.cpp (119741 => 119742)


--- trunk/Source/WebKit/chromium/src/AssertMatchingEnums.cpp	2012-06-07 18:32:52 UTC (rev 119741)
+++ trunk/Source/WebKit/chromium/src/AssertMatchingEnums.cpp	2012-06-07 18:37:39 UTC (rev 119742)
@@ -581,3 +581,7 @@
 COMPILE_ASSERT_MATCHING_ENUM(WebURLResponse::HTTP_0_9, ResourceResponse::HTTP_0_9);
 COMPILE_ASSERT_MATCHING_ENUM(WebURLResponse::HTTP_1_0, ResourceResponse::HTTP_1_0);
 COMPILE_ASSERT_MATCHING_ENUM(WebURLResponse::HTTP_1_1, ResourceResponse::HTTP_1_1);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::CORSModeUnspecified, MediaPlayerClient::Unspecified);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::CORSModeAnonymous, MediaPlayerClient::Anonymous);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::CORSModeUseCredentials, MediaPlayerClient::UseCredentials);

Modified: trunk/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp (119741 => 119742)


--- trunk/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp	2012-06-07 18:32:52 UTC (rev 119741)
+++ trunk/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp	2012-06-07 18:37:39 UTC (rev 119742)
@@ -318,7 +318,9 @@
         // Make sure if we create/re-create the WebMediaPlayer that we update our wrapper.
         m_audioSourceProvider.wrap(m_webMediaPlayer->audioSourceProvider());
 #endif
-        m_webMediaPlayer->load(KURL(ParsedURLString, m_url));
+        m_webMediaPlayer->load(
+            KURL(ParsedURLString, m_url),
+            static_cast<WebMediaPlayer::CORSMode>(m_mediaPlayer->mediaPlayerClient()->mediaPlayerCORSMode()));
     }
 }
 
@@ -662,6 +664,13 @@
     return false;
 }
 
+bool WebMediaPlayerClientImpl::didPassCORSAccessCheck() const
+{
+    if (m_webMediaPlayer)
+        return m_webMediaPlayer->didPassCORSAccessCheck();
+    return false;
+}
+
 MediaPlayer::MovieLoadType WebMediaPlayerClientImpl::movieLoadType() const
 {
     if (m_webMediaPlayer)

Modified: trunk/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.h (119741 => 119742)


--- trunk/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.h	2012-06-07 18:32:52 UTC (rev 119741)
+++ trunk/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.h	2012-06-07 18:37:39 UTC (rev 119742)
@@ -131,6 +131,7 @@
     virtual void paintCurrentFrameInContext(WebCore::GraphicsContext*, const WebCore::IntRect&);
     virtual void setPreload(WebCore::MediaPlayer::Preload);
     virtual bool hasSingleSecurityOrigin() const;
+    virtual bool didPassCORSAccessCheck() const;
     virtual WebCore::MediaPlayer::MovieLoadType movieLoadType() const;
     virtual float mediaTimeForTimeValue(float timeValue) const;
     virtual unsigned decodedFrameCount() const;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to