Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prevent default action for simple html5 media events. fixes #573, fixes #620 (duplicate bug) #630

Closed
wants to merge 5 commits into from
Closed

prevent default action for simple html5 media events. fixes #573, fixes #620 (duplicate bug) #630

wants to merge 5 commits into from

Conversation

cameront
Copy link

Looking for advice/input on whether this is a problem for flash, too.

// Mediafaker doesn't support play/pause, so dispatch an event manually.
var event = document.createEvent('CustomEvent');
event.initCustomEvent('play', false /*bubbles*/, true /*cancelable*/, null);
tech.el_.dispatchEvent(event);
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for writing a test!

There's a PlayerTest.makePlayer() function that could make this simpler. https://github.com/videojs/video.js/blob/master/test/unit/test-helpers.js#L8

createEvent is apparently deprecated.
https://developer.mozilla.org/en-US/docs/Web/API/document.createEvent
Also not supported in ie8, but I guess that's not really an issue in the HTML5 tests. Probably better to use a constructor like MDN says.

It seems like at the core of this you're just testing that preventDefault works, does that sound right?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay - I've incorporated PlayerTest.makePlayer().

I should have mentioned this before submitting, but I did try to use event constructors and ran into an issue in phantomjs - ariya/phantomjs#11289. Okay to keep createElement for now?

And yeah - the point is just a regression test to verify that events bubbled from the html5 tech have preventDefault called on them before trigger is called.

@heff
Copy link
Member

heff commented Jul 23, 2013

Thinking about it more, I agree with your thought that it should support event.bubbles, and that might be the thing to focus on. I think we could handle this updating this line: https://github.com/videojs/video.js/blob/v4.1.0/src/js/events.js#L281

To:

if (parent && !event.isPropagationStopped() && event.bubbles !== false) {

@cameront
Copy link
Author

Sure - I can make that change to events.js. My only concern was that my observations were biased towards chrome, and wasn't sure if all browsers turned off bubbling for media events, since I'm unable to find that rule in the spec.

Though there seems to be pretty consistent language from other browsers:
http://developer.mozilla.org/en-US/docs/Web/Reference/Events/play
http://dev.opera.com/articles/view/consistent-event-firing-with-html5-video/

Would you rather me scrap this pull request and make that change to events.js?

@heff
Copy link
Member

heff commented Jul 24, 2013

Yeah, you can use this PR or a new one, but the bubble part should be enough. AFAIK, certain events bubble so you can disambiguate where they happened, e.g. clicks. It's pretty clear where media events happen, so I at least don't see a benefit in bubbling them.


Steve Heffernan (mobile)

On Jul 23, 2013, at 4:05 PM, cameron notifications@github.com wrote:

Sure - I can make that change to events.js. My only concern was that my observations were biased towards chrome, and wasn't sure if all browsers turned off bubbling for media events, since I'm unable to find that rule in the spec.

Though there seems to be pretty consistent language from other browsers:
http://developer.mozilla.org/en-US/docs/Web/Reference/Events/play
http://dev.opera.com/articles/view/consistent-event-firing-with-html5-video/

Would you rather me scrap this pull request and make that change to events.js?


Reply to this email directly or view it on GitHub.

@cameront
Copy link
Author

All done with the suggested changes.

@heff
Copy link
Member

heff commented Jul 30, 2013

Thanks! And very nice test.

@heff heff closed this in 15544c3 Jul 30, 2013
heff added a commit that referenced this pull request Jul 30, 2013
Close GH-630: prevent default action for simple html5 media events. fixe...
heff added a commit that referenced this pull request Jul 30, 2013
…vents. fixes #573, fixes #620 (duplicate bug)."

This reverts commit 15544c3.
@heff
Copy link
Member

heff commented Jul 30, 2013

FYI, didn't realize this was against the stable branch. Most new changes should go into master. I merged into master and reverted stable, so if you're currently working from stable you won't see your changes until the next release.

Thanks again.

@cameront
Copy link
Author

Gotcha. I tried to use contribflow to see how that process worked, so it might have automatically branched from stable? Or I might not have understood what I was doing -- but thanks for the heads up either way.

@heff
Copy link
Member

heff commented Jul 30, 2013

Oh cool. Yeah, we're still polishing up contribflow, but hopefully it was a good experience. Let me know if you have any feedback. We also had some updates to the CONTRIBUTING.md in the last month which talk about contribflow if that helps at all.

heff added a commit that referenced this pull request Sep 4, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants