-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Restore video tag attributes on tech change #1369
Changes from all commits
4af8af0
c4aa9fa
2537c98
0e78c9e
aeefefe
dae47c6
998183f
a443d21
72bbabd
ca8313b
b54f5e2
1c5f928
0604746
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,10 +113,10 @@ test('should read tag attributes from elements, including HTML5 in all browsers' | |
|
||
document.getElementById('qunit-fixture').innerHTML += tags; | ||
|
||
var vid1Vals = vjs.getAttributeValues(document.getElementById('vid1')); | ||
var vid2Vals = vjs.getAttributeValues(document.getElementById('vid2')); | ||
var sourceVals = vjs.getAttributeValues(document.getElementById('source')); | ||
var trackVals = vjs.getAttributeValues(document.getElementById('track')); | ||
var vid1Vals = vjs.getElementAttributes(document.getElementById('vid1')); | ||
var vid2Vals = vjs.getElementAttributes(document.getElementById('vid2')); | ||
var sourceVals = vjs.getElementAttributes(document.getElementById('source')); | ||
var trackVals = vjs.getElementAttributes(document.getElementById('track')); | ||
|
||
// was using deepEqual, but ie8 would send all properties as attributes | ||
|
||
|
@@ -152,6 +152,22 @@ test('should read tag attributes from elements, including HTML5 in all browsers' | |
equal(trackVals['title'], 'test'); | ||
}); | ||
|
||
|
||
test('should set tag attributes from object', function(){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for writing tests! |
||
|
||
var tags = '<video id="vid1" controls data-test="ok"></video>'; | ||
|
||
document.getElementById('qunit-fixture').innerHTML += tags; | ||
var el = document.getElementById('vid1'); | ||
vjs.setElementAttributes(el, {controls: false,'data-test': 'asdf'}); | ||
|
||
var vid1Vals = vjs.getElementAttributes(document.getElementById('vid1')); | ||
|
||
equal(vid1Vals['controls'], undefined); | ||
equal(vid1Vals['id'], 'vid1'); | ||
equal(vid1Vals['data-test'], 'asdf'); | ||
}); | ||
|
||
test('should get the right style values for an element', function(){ | ||
var el = document.createElement('div'); | ||
var container = document.createElement('div'); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,7 +73,7 @@ test('should accept options from multiple sources and override in correct order' | |
}); | ||
|
||
test('should get tag, source, and track settings', function(){ | ||
// Partially tested in lib->getAttributeValues | ||
// Partially tested in lib->getElementAttributes | ||
|
||
var fixture = document.getElementById('qunit-fixture'); | ||
|
||
|
@@ -482,3 +482,32 @@ test('player should handle different error types', function(){ | |
vjs.log.error.restore(); | ||
}); | ||
|
||
test('should restore all video tags attribute after a tech switch', function(){ | ||
var fixture = document.getElementById('qunit-fixture'); | ||
var html = '<video id="example_1" class="vjs-tech" preload="" webkit-playsinline="" autoplay=""></video>'; | ||
fixture.innerHTML += html; | ||
|
||
var tag = document.getElementById('example_1'); | ||
var player = new videojs.Player(tag, {techOrder:['html5']}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have you tried running this in ie8? I think this is going to throw errors. We may need to find a smaller unit of code to test here instead of requiring the full html5 stack to run. I think you could just write a test for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I prefer to die than using ie8. What make you think it's gone to fail ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ha, yeah ie8 is no fun, but that just means I end up doing IE8 testing for everyone. :) It could possibly get past IE8 if we have enough checks for missing properties, but I'm still cautious about the long term stability of executing the html5 code in a browser that isn't mean to support it. In issues like this I try to break it into smaller units to test, and then that makes it easier to stub certain functionality. If you think the switching tech method is an issue, we should make sure we have other tests for that specifically. So one test for vjs.Html5.prototype.createEl and another to make sure switching works as expected. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I develop backends or exotic devices, I will tell you if videojs work on chromecast, embed ios, android, xbox one, wii-u, amazon-fire-tv, samsung tv, … and you tell me if it work on ie8 please ? I can't spend hours to setup a ie8… For the createEl I still don't get it, I agree but my knowledge of videojs is too limited for that. We can't test createEl if we don't have a Html5 tech object and we can't create one without the player object, can you drive to the right direction ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For better or worse, videojs supports IE8, which means that any code we accept into the project needs to support IE8. var newEl = vjs.Html5.prototype.createEl.call({
player: {
tag: document.createElement('div')
}
}); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sadly this will test nothing because the element will not be created if it already exist. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was just a quick example, didn't mean to imply it is exactly what you need to be able to test just |
||
var techOptions = vjs.obj.merge({ 'source': '', 'parentEl': player.el_ }, player.options_['html5']); | ||
vjs.Html5.disposeMediaElement(player.tag); | ||
player.tag = null; | ||
player.tech = new vjs.Html5(player, techOptions); | ||
|
||
PlayerTest.htmlEqualWithSort(player.tech.el_.outerHTML, html.replace('example_1','example_1_html5_api')); | ||
}); | ||
|
||
test('should restore all video tags attribute after a tech switch and keep options', function(){ | ||
var fixture = document.getElementById('qunit-fixture'); | ||
var html = '<video id="example_1" class="vjs-tech" preload="none" autoplay=""></video>'; | ||
fixture.innerHTML += html; | ||
|
||
var tag = document.getElementById('example_1'); | ||
var player = new videojs.Player(tag, {techOrder:['html5'], autoplay:false}); | ||
var techOptions = vjs.obj.merge({ 'source': '', 'parentEl': player.el_ }, player.options_['html5']); | ||
vjs.Html5.disposeMediaElement(player.tag); | ||
player.tag = null; | ||
player.tech = new vjs.Html5(player, techOptions); | ||
|
||
PlayerTest.htmlEqualWithSort(player.tech.el_.outerHTML, html.replace('example_1','example_1_html5_api').replace(' autoplay=""','')); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're already checking for undefined in
setElementAttributes
, so could we simplify this?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, this is for an overwrite of the tag initial values
we don't want to remove the autoplay if there is no autoplay defined on the player options I think. Please confirm.