Commit 46874663 authored by bashi@chromium.org's avatar bashi@chromium.org

TrackEvent.track should be (VideoTrack or AudioTrack or TextTrack)?

Track attribute uses object type, but we should use
(VideoTrack or AudioTrack or TextTrak)? as the spec says[1].

[1] https://html.spec.whatwg.org/multipage/embedded-content.html#the-trackevent-interface

BUG=430337

Review URL: https://codereview.chromium.org/690923004

git-svn-id: svn://svn.chromium.org/blink/trunk@185104 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 9462f66e
......@@ -15,15 +15,15 @@ PASS new TrackEvent('TrackEvent', { bubbles: true, cancelable: true }).cancelabl
PASS new TrackEvent('TrackEvent', { bubbles: true, cancelable: true }).track is null
*** Bubbles and cancelable true, invalid track ***
PASS new TrackEvent('TrackEvent', { bubbles: true, cancelable: true, track: HTMLTrackElement }).bubbles threw exception TypeError: Failed to construct 'TrackEvent': The 'track' property does not have a object type..
PASS new TrackEvent('TrackEvent', { bubbles: true, cancelable: true, track: HTMLTrackElement }).cancelable threw exception TypeError: Failed to construct 'TrackEvent': The 'track' property does not have a object type..
PASS new TrackEvent('TrackEvent', { bubbles: true, cancelable: true, track: HTMLTrackElement }).track threw exception TypeError: Failed to construct 'TrackEvent': The 'track' property does not have a object type..
PASS new TrackEvent('TrackEvent', { bubbles: true, cancelable: true, track: HTMLTrackElement }).bubbles threw exception TypeError: Failed to construct 'TrackEvent': The 'track' property does not have a VideoTrackOrAudioTrackOrTextTrack type..
PASS new TrackEvent('TrackEvent', { bubbles: true, cancelable: true, track: HTMLTrackElement }).cancelable threw exception TypeError: Failed to construct 'TrackEvent': The 'track' property does not have a VideoTrackOrAudioTrackOrTextTrack type..
PASS new TrackEvent('TrackEvent', { bubbles: true, cancelable: true, track: HTMLTrackElement }).track threw exception TypeError: Failed to construct 'TrackEvent': The 'track' property does not have a VideoTrackOrAudioTrackOrTextTrack type..
*** Initialize 'track' with a invalid values ***
PASS new TrackEvent('TrackEvent', { track: 10 }).track threw exception TypeError: Failed to construct 'TrackEvent': The 'track' property does not have a object type..
PASS new TrackEvent('TrackEvent', { track: 'string' }).track threw exception TypeError: Failed to construct 'TrackEvent': The 'track' property does not have a object type..
PASS new TrackEvent('TrackEvent', { track: emptyObject }).track threw exception TypeError: Failed to construct 'TrackEvent': The 'track' property does not have a object type..
PASS new TrackEvent('TrackEvent', { track: document }).track threw exception TypeError: Failed to construct 'TrackEvent': The 'track' property does not have a object type..
PASS new TrackEvent('TrackEvent', { track: 10 }).track threw exception TypeError: Failed to construct 'TrackEvent': The 'track' property does not have a VideoTrackOrAudioTrackOrTextTrack type..
PASS new TrackEvent('TrackEvent', { track: 'string' }).track threw exception TypeError: Failed to construct 'TrackEvent': The 'track' property does not have a VideoTrackOrAudioTrackOrTextTrack type..
PASS new TrackEvent('TrackEvent', { track: emptyObject }).track threw exception TypeError: Failed to construct 'TrackEvent': The 'track' property does not have a VideoTrackOrAudioTrackOrTextTrack type..
PASS new TrackEvent('TrackEvent', { track: document }).track threw exception TypeError: Failed to construct 'TrackEvent': The 'track' property does not have a VideoTrackOrAudioTrackOrTextTrack type..
*** Bubbles and cancelable true, valid track ***
PASS new TrackEvent('TrackEvent', { bubbles: true, cancelable: true, track: trackElement.track }).bubbles is true
......
/*
* Copyright (C) 2011 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "bindings/core/v8/V8TrackEvent.h"
#include "bindings/core/v8/V8AudioTrack.h"
#include "bindings/core/v8/V8TextTrack.h"
#include "bindings/core/v8/V8VideoTrack.h"
#include "core/html/track/TrackBase.h"
#include "core/html/track/TrackEvent.h"
namespace blink {
void V8TrackEvent::trackAttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Value>& info)
{
TrackEvent* trackEvent = V8TrackEvent::toImpl(info.Holder());
TrackBase* track = trackEvent->track();
if (!track) {
v8SetReturnValueNull(info);
return;
}
switch (track->type()) {
case TrackBase::TextTrack:
v8SetReturnValueFast(info, toTextTrack(track), trackEvent);
return;
case TrackBase::AudioTrack:
v8SetReturnValueFast(info, toAudioTrack(track), trackEvent);
return;
case TrackBase::VideoTrack:
v8SetReturnValueFast(info, toVideoTrack(track), trackEvent);
return;
}
v8SetReturnValueNull(info);
}
} // namespace blink
......@@ -39,7 +39,6 @@
'V8MessagePortCustom.cpp',
'V8MutationObserverCustom.cpp',
'V8PopStateEventCustom.cpp',
'V8TrackEventCustom.cpp',
'V8WebGLRenderingContextCustom.cpp',
'V8WindowCustom.cpp',
'V8WorkerCustom.cpp',
......
......@@ -24,9 +24,13 @@
*/
#include "config.h"
#include "core/html/track/TrackEvent.h"
#include "bindings/core/v8/UnionTypesCore.h"
#include "core/html/track/AudioTrack.h"
#include "core/html/track/TextTrack.h"
#include "core/html/track/VideoTrack.h"
namespace blink {
TrackEventInit::TrackEventInit()
......@@ -53,6 +57,26 @@ const AtomicString& TrackEvent::interfaceName() const
return EventNames::TrackEvent;
}
void TrackEvent::track(VideoTrackOrAudioTrackOrTextTrack& returnValue)
{
if (!m_track)
return;
switch (m_track->type()) {
case TrackBase::TextTrack:
returnValue.setTextTrack(toTextTrack(m_track.get()));
break;
case TrackBase::AudioTrack:
returnValue.setAudioTrack(toAudioTrack(m_track.get()));
break;
case TrackBase::VideoTrack:
returnValue.setVideoTrack(toVideoTrack(m_track.get()));
break;
default:
ASSERT_NOT_REACHED();
}
}
void TrackEvent::trace(Visitor* visitor)
{
visitor->trace(m_track);
......
......@@ -31,6 +31,8 @@
namespace blink {
class VideoTrackOrAudioTrackOrTextTrack;
struct TrackEventInit : public EventInit {
TrackEventInit();
......@@ -54,7 +56,7 @@ public:
virtual const AtomicString& interfaceName() const override;
TrackBase* track() const { return m_track.get(); }
void track(VideoTrackOrAudioTrackOrTextTrack&);
virtual void trace(Visitor*) override;
......
......@@ -23,8 +23,10 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// https://html.spec.whatwg.org/multipage/embedded-content.html#the-trackevent-interface
[
EventConstructor,
] interface TrackEvent : Event {
[InitializedByEventConstructor, Custom=Getter] readonly attribute object track;
};
\ No newline at end of file
[InitializedByEventConstructor] readonly attribute (VideoTrack or AudioTrack or TextTrack)? track;
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment