Looks like we're on the right track, please see comments. The new module needs
an OWNER, I guess that's you :)
https://codereview.chromium.org/1815033003/diff/360001/third_party/WebKit/LayoutTests/media/video-srcobject-mediastream-src-file.htmlFile
third_party/WebKit/LayoutTests/media/video-srcobject-mediastream-src-file.html
(right):
https://codereview.chromium.org/1815033003/diff/360001/third_party/WebKit/LayoutTests/media/video-srcobject-mediastream-src-file.html#newcode5third_party/WebKit/LayoutTests/media/video-srcobject-mediastream-src-file.html:5:
<div id="log"></div>
You typically don't need to include this, it'll be inserted
automatically.
https://codereview.chromium.org/1815033003/diff/360001/third_party/WebKit/LayoutTests/media/video-srcobject-mediastream-src-file.html#newcode14third_party/WebKit/LayoutTests/media/video-srcobject-mediastream-src-file.html:14:
var video = document.getElementById("testVideo");
You can skip the id and just use document.querySelector("video"). As
little markup and code as possible in tests is nice, gets right to the
important bits :)
https://codereview.chromium.org/1815033003/diff/360001/third_party/WebKit/LayoutTests/media/video-srcobject-mediastream-src-file.html#newcode15third_party/WebKit/LayoutTests/media/video-srcobject-mediastream-src-file.html:15:
var trackevent = "playing";
Just inline "playing" everywhere?
https://codereview.chromium.org/1815033003/diff/360001/third_party/WebKit/LayoutTests/media/video-srcobject-mediastream-src-file.html#newcode21third_party/WebKit/LayoutTests/media/video-srcobject-mediastream-src-file.html:21:
video.src = getVideoURI("test");
It'd be more clear if you set src and srcObject at the same time I
think. If you're trying to test something about the timing by doing at
separate points, being more explicit about that would be good, but I
don't think that's the case.
https://codereview.chromium.org/1815033003/diff/360001/third_party/WebKit/LayoutTests/media/video-srcobject-mediastream.htmlFile
third_party/WebKit/LayoutTests/media/video-srcobject-mediastream.html
(right):
https://codereview.chromium.org/1815033003/diff/360001/third_party/WebKit/LayoutTests/media/video-srcobject-mediastream.html#newcode4third_party/WebKit/LayoutTests/media/video-srcobject-mediastream.html:4:
<video id="testVideo" autoplay="autoplay"></video>
Nit: The autoplay attribute doesn't need any specific value, the empty
string is fine, which you'll get by just <video autoplay>.
https://codereview.chromium.org/1815033003/diff/360001/third_party/WebKit/LayoutTests/media/video-srcobject-mediastream.html#newcode6third_party/WebKit/LayoutTests/media/video-srcobject-mediastream.html:6:
<p>Test assigment of a mediastream via the srcObject attribute.</p>
Can you put this inside <title> at the top? This way, when there's only
a single test, that test gets the document.title as its title by
default. Also capitalize MediaStream.
https://codereview.chromium.org/1815033003/diff/360001/third_party/WebKit/LayoutTests/media/video-srcobject-mediastream.html#newcode9third_party/WebKit/LayoutTests/media/video-srcobject-mediastream.html:9:
<script src="./w3c-media-utils.js"></script>
Doesn't look like you're using anything from w3c-media-utils.js.
https://codereview.chromium.org/1815033003/diff/360001/third_party/WebKit/LayoutTests/media/video-srcobject-mediastream.html#newcode16third_party/WebKit/LayoutTests/media/video-srcobject-mediastream.html:16:
test.step(() => assert_idl_attribute(video, "srcObject"));
You shouldn't need to wrap any individual steps like this. Just make
sure that each of these functions is appropriately wrapped in
test.step_func(). This way if exceptions are thrown where you're not
anticipating them, like say if navigator.webkitGetUserMedia is removed,
it'll still fail the test properly.
You can avoid the startTest() method entirely by just doing
async_test(test => { /* the steps that start at this line */ }, /* no
title if you have a <title> above */).
https://codereview.chromium.org/1815033003/diff/360001/third_party/WebKit/LayoutTests/media/video-srcobject-mediastream.html#newcode17third_party/WebKit/LayoutTests/media/video-srcobject-mediastream.html:17:
video.addEventListener("playing", playingSrcObject);
Here you'll need test.step_func(playingSrcObject). Similarly elsewhere.
https://codereview.chromium.org/1815033003/diff/360001/third_party/WebKit/LayoutTests/media/video-srcobject-mediastream.html#newcode22third_party/WebKit/LayoutTests/media/video-srcobject-mediastream.html:22:
stream => video.srcObject = stream,
The sequence of events could be a bit clearer if you added the playing
event listener in this callback, because I guess it's setting the
srcObject which will eventually cause the play to happen? An explicit
call to play() and removing autoplay would also be clearer, IMHO.
https://codereview.chromium.org/1815033003/diff/360001/third_party/WebKit/LayoutTests/media/video-srcobject-mediastream.html#newcode23third_party/WebKit/LayoutTests/media/video-srcobject-mediastream.html:23:
_ => test.step(() => assert_unreached("Did not get mediastream")));
This can be test.unreached_func("Did not get MediaStream");
https://codereview.chromium.org/1815033003/diff/360001/third_party/WebKit/LayoutTests/media/video-srcobject-mediastream.html#newcode28third_party/WebKit/LayoutTests/media/video-srcobject-mediastream.html:28:
video.removeEventListener("playing", playingSrcObject)
Is this needed? If it is, then using the onplaying attribute and setting
it to null here could be cleaner than saving the
test.step_func(playingSrcObject) value that you'd otherwise have to do.
https://codereview.chromium.org/1815033003/diff/360001/third_party/WebKit/LayoutTests/media/video-srcobject-mediastream.html#newcode29third_party/WebKit/LayoutTests/media/video-srcobject-mediastream.html:29:
video.addEventListener("emptied", playingNothing)
This is an oddly named callback. If you don't enjoy coming up with names
for callbacks, you can of course just nest everything. Go down to two
spaces indent and it may still be readable enough.
https://codereview.chromium.org/1815033003/diff/360001/third_party/WebKit/LayoutTests/media/video-srcobject-mediastream.html#newcode33third_party/WebKit/LayoutTests/media/video-srcobject-mediastream.html:33:
video.srcObject=null;
Needs more whitespace.
https://codereview.chromium.org/1815033003/diff/360001/third_party/WebKit/LayoutTests/media/video-srcobject-mediastream.html#newcode40third_party/WebKit/LayoutTests/media/video-srcobject-mediastream.html:40:
test.done();
When this is wrapped instead, you can use test.step_func_done() and omit
the step.done().
https://codereview.chromium.org/1815033003/diff/360001/third_party/WebKit/Source/core/html/HTMLMediaElement.cppFile third_party/WebKit/Source/core/html/HTMLMediaElement.cpp (right):
https://codereview.chromium.org/1815033003/diff/360001/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp#newcode627third_party/WebKit/Source/core/html/HTMLMediaElement.cpp:627: if
(m_networkState == NETWORK_EMPTY && (!getAttribute(srcAttr).isEmpty() ||
m_source.isMediaProviderObject())) {
Hmm, why this change? This block of code isn't per spec, did something
break if you didn't extend it to srcObject?
https://codereview.chromium.org/1815033003/diff/360001/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp#newcode727third_party/WebKit/Source/core/html/HTMLMediaElement.cpp:727: m_source =
srcObject;
Looking at this I'm thinking that it'd be cleaner if this is called just
m_srcObject and that before setting it you
ASSERT(srcObject.isMediaProviderObject()).
https://codereview.chromium.org/1815033003/diff/360001/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp#newcode999third_party/WebKit/Source/core/html/HTMLMediaElement.cpp:999: m_source =
WebMediaElementSource(WebURL(mediaURL));
Here, rather than setting m_source/m_srcObject, can you add back
loadResource's first argument and just pass it in here? I guess it can
be const WebMediaPlayerSource& and the WebMediaPlayer doesn't get any
ownership, so it has to extract the wrapped source from it before
returning.
This should force the code into being more like the spec, it won't be
possible to keep some extra state in m_source/m_srcObject, which could
be tempting even if you haven't done it here.
https://codereview.chromium.org/1815033003/diff/360001/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp#newcode1016third_party/WebKit/Source/core/html/HTMLMediaElement.cpp:1016: m_source
= WebMediaElementSource(WebURL(mediaURL));
Ditto.
https://codereview.chromium.org/1815033003/diff/360001/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp#newcode1065third_party/WebKit/Source/core/html/HTMLMediaElement.cpp:1065: bool
isBlobProtocol = m_source.isMediaProviderObject() ||
url.protocolIs(mediaSourceBlobProtocol);
I guess isObjectOrBlobURL or something would be more accurate?
https://codereview.chromium.org/1815033003/diff/360001/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp#newcode1110third_party/WebKit/Source/core/html/HTMLMediaElement.cpp:1110: if
(m_source.isURL()) {
This will have to change with my proposed changes to m_srcObject. Will
you be able to use m_mode?
https://codereview.chromium.org/1815033003/diff/360001/third_party/WebKit/Source/modules/srcobject/HTMLMediaElementSrcObject.cppFile
third_party/WebKit/Source/modules/srcobject/HTMLMediaElementSrcObject.cpp
(right):
https://codereview.chromium.org/1815033003/diff/360001/third_party/WebKit/Source/modules/srcobject/HTMLMediaElementSrcObject.cpp#newcode21third_party/WebKit/Source/modules/srcobject/HTMLMediaElementSrcObject.cpp:21:
MediaStream* stream = static_cast<MediaStream*>(descriptor->client());
Can you introduce a free function toMediaStream(MediaStreamDescriptor*)
or a MediaStreamDescriptor::getAsMediaStream() instead so that the
static_cast is together with the code that makes it obviously safe?
https://codereview.chromium.org/1815033003/diff/360001/third_party/WebKit/public/platform/WebMediaElementSource.hFile third_party/WebKit/public/platform/WebMediaElementSource.h (right):
https://codereview.chromium.org/1815033003/diff/360001/third_party/WebKit/public/platform/WebMediaElementSource.h#newcode14third_party/WebKit/public/platform/WebMediaElementSource.h:14: class
BLINK_PLATFORM_EXPORT WebMediaElementSource {
How about WebMediaPlayerSource as the name? It goes together with
WebMediaPlayer, and it's nice to contain the notion of a media element
(HTMLMediaElement) to inside Blink as much as possible.
https://codereview.chromium.org/1815033003/