-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Load without errors in IE 9 #110
Changes from 12 commits
b1baaaf
ec623c6
2ed3478
b0a8017
56df639
411c738
c10a63d
4e14ff8
7260839
d5b4499
6a235a1
5abe5b5
2c7196c
0f914cf
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 |
---|---|---|
|
@@ -43,8 +43,25 @@ shaka.asserts.notImplemented = function() {}; | |
shaka.asserts.unreachable = function() {}; | ||
|
||
|
||
/** @private @type {function()} */ | ||
shaka.asserts.patchAssert_ = function() { | ||
var assert = console.assert; | ||
|
||
if (!assert) { | ||
console.assert = function() {}; | ||
} else if (!assert.bind) { | ||
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. A comment here about what platforms/browsers do not have console.assert.bind would be helpful. 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. Ping! Please add a comment here about who does not have console.assert.bind and why. 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. There is one here; I added it inside the if, but I can try to fit it on the end of the line, if that's more in-line with your style. |
||
// IE 9 does not provide a .bind for the built-in console functions. | ||
console.assert = function() { | ||
assert.apply(console, arguments); | ||
}; | ||
} | ||
}; | ||
|
||
|
||
// Install assert functions. | ||
if (shaka.asserts.ENABLE_ASSERTS) { | ||
shaka.asserts.patchAssert_(); | ||
|
||
shaka.asserts.assert = | ||
console.assert.bind(console); | ||
|
||
|
@@ -54,4 +71,3 @@ if (shaka.asserts.ENABLE_ASSERTS) { | |
shaka.asserts.unreachable = | ||
console.assert.bind(console, 0 == 1, 'Unreachable reached.'); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,6 +70,30 @@ shaka.log.v1 = function() {}; | |
shaka.log.v2 = function() {}; | ||
|
||
|
||
/** | ||
* @private | ||
* @param {string} logName | ||
*/ | ||
shaka.log.patchConsole_ = function(logName) { | ||
var nop = function() {}; | ||
var logFunction = console[logName]; | ||
|
||
if (!logFunction) { | ||
console[logName] = nop; | ||
} else if (!logFunction.bind) { | ||
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. Same here, a comment about why/where bind might be missing would be useful. 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. Ping! A comment about why/where bind is missing, please. 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. Same here; should I move it up? 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. Nope, looks good. |
||
// IE 9 does not provide a .bind for the built-in logging functions. | ||
console[logName] = function() { | ||
logFunction.apply(console, arguments); | ||
}; | ||
} | ||
}; | ||
|
||
shaka.log.patchConsole_('error'); | ||
shaka.log.patchConsole_('warn'); | ||
shaka.log.patchConsole_('info'); | ||
shaka.log.patchConsole_('log'); | ||
shaka.log.patchConsole_('debug'); | ||
|
||
if (!COMPILED) { | ||
/** | ||
* Change the log level. Useful for debugging in uncompiled mode. | ||
|
@@ -118,4 +142,3 @@ if (shaka.log.MAX_LOG_LEVEL >= shaka.log.Level.V1) { | |
if (shaka.log.MAX_LOG_LEVEL >= shaka.log.Level.V2) { | ||
shaka.log.v2 = console.debug.bind(console); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,34 +15,34 @@ | |
*/ | ||
|
||
// Status values for the report entries. | ||
const kGood = 0; | ||
const kInfo = 1; | ||
const kBad = 2; | ||
|
||
const vp8Type = 'video/webm; codecs="vp8"'; | ||
const vp9Type = 'video/webm; codecs="vp9"'; | ||
const mp4Type = 'video/mp4; codecs="avc1.42E01E"'; | ||
const tsType = 'video/mp2t; codecs="avc1.42E01E"'; | ||
|
||
const clearKeyId = 'org.w3.clearkey'; | ||
const widevineId = 'com.widevine.alpha'; | ||
const playReadyId = 'com.microsoft.playready'; | ||
const adobeAccessId = 'com.adobe.access'; | ||
const fairPlayId = 'com.apple.fairplay'; | ||
|
||
const classPrefixes = [ | ||
var kGood = 0; | ||
var kInfo = 1; | ||
var kBad = 2; | ||
|
||
var vp8Type = 'video/webm; codecs="vp8"'; | ||
var vp9Type = 'video/webm; codecs="vp9"'; | ||
var mp4Type = 'video/mp4; codecs="avc1.42E01E"'; | ||
var tsType = 'video/mp2t; codecs="avc1.42E01E"'; | ||
|
||
var clearKeyId = 'org.w3.clearkey'; | ||
var widevineId = 'com.widevine.alpha'; | ||
var playReadyId = 'com.microsoft.playready'; | ||
var adobeAccessId = 'com.adobe.access'; | ||
var fairPlayId = 'com.apple.fairplay'; | ||
|
||
var classPrefixes = [ | ||
'WebKit', | ||
'MS', | ||
'Moz' | ||
]; | ||
|
||
const propertyPrefixes = [ | ||
var propertyPrefixes = [ | ||
'webkit', | ||
'ms', | ||
'moz' | ||
]; | ||
|
||
const keySystemPrefixes = [ | ||
var keySystemPrefixes = [ | ||
'webkit-' | ||
]; | ||
|
||
|
@@ -230,6 +230,7 @@ function testForKeySystem(ks, required) { | |
testForClass(window, 'HTMLMediaElement', true); | ||
testForClass(window, 'MediaSource', true); | ||
testForClass(window, 'Promise', true); | ||
testForClass(window, 'Uint8Array', true); | ||
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. Would you also add Uint8Array to shaka.player.Player.isBrowserSupported()? Ideally, that and this should agree. 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. Sure thing. |
||
|
||
// Optional: | ||
testForClass(window, 'VTTCue', false); | ||
|
@@ -303,8 +304,12 @@ if (async.length) { | |
} | ||
|
||
function onLoaded(fn) { | ||
if (document.readyState == "loading") { | ||
document.addEventListener('DOMContentLoaded', fn); | ||
// IE 9 fires DOMContentLoaded, and enters the "interactive" | ||
// readyState, before document.body has been initialized, so wait | ||
// for window.load | ||
if (document.readyState == 'loading' || | ||
document.readyState == 'interactive') { | ||
window.addEventListener('load', fn); | ||
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'm guessing IE9 doesn't have DOMContentLoaded either? A comment would be nice to remind me not to change it back when I stumble across this later. 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. It does, but it fires when the document enters the 'interactive' state, at which point I think this isn't ideal on a real page, since it waits for images, etc, to load, but since it's just the support page (and has no external resources) it seems best to keep it simple. |
||
} else { | ||
fn(); | ||
} | ||
|
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 can drop the "type" annotation here.