Skip to content

Commit

Permalink
refactor: Remove IE 11 support
Browse files Browse the repository at this point in the history
Issue shaka-project#2339

Change-Id: I80ffa7b04f7afd943aa0f881d2a494dd35def732
  • Loading branch information
michellezhuogg committed Apr 29, 2021
1 parent ec9a38f commit 95ba28b
Show file tree
Hide file tree
Showing 45 changed files with 40 additions and 145 deletions.
69 changes: 2 additions & 67 deletions build/conformance.textproto
Original file line number Diff line number Diff line change
Expand Up @@ -204,21 +204,13 @@ requirement: {
}


# Disallow Input.valueAsNumber.
requirement: {
type: BANNED_PROPERTY
value: 'HTMLInputElement.prototype.valueAsNumber'
error_message: '"Input.valueAsNumber" is not supported on IE11'
}


# Disallow DOMRect.x and y.
requirement: {
type: BANNED_PROPERTY
value: 'DOMRect.prototype.x'
value: 'DOMRect.prototype.y'
error_message: 'DOMRect "x" and "y" are not supported on IE11 and legacy '
'Edge; use "left" and "top" instead.'
error_message: 'DOMRect "x" and "y" are not supported on legacy Edge; '
'use "left" and "top" instead.'
# The built-in set and map polyfills trigger this ban somehow.
whitelist_regexp: 'synthetic:es6/'
}
Expand All @@ -241,14 +233,6 @@ requirement: {
}


# Disallow classList toggle.
requirement: {
type: BANNED_PROPERTY_CALL
value: 'DOMTokenList.prototype.toggle'
error_message: 'classList toggle is not supported in IE11'
}


# Disallow setInterval.
requirement: {
type: BANNED_NAME
Expand Down Expand Up @@ -312,62 +296,13 @@ requirement: {
}


# Disallow the Event constructor, since Event is not constructable on IE.
requirement: {
type: BANNED_CODE_PATTERN
value: '/** @param {*} name */ '
'function template(name) { new Event(name); }'
error_message: 'Event is not constructable on IE. Instead, use '
'document.createEvent(\'CustomEvent\') to create an event and '
'event.initCustomEvent(\'my-event-type\') to initialize it.'
whitelist_regexp: 'lib/polyfill/patchedmediakeys_apple.js'
whitelist_regexp: 'lib/polyfill/pip_webkit.js'
}


# Disallow ES6 methods.
requirement: {
type: BANNED_PROPERTY
value: 'ArrayBuffer.prototype.slice'
error_message: 'ArrayBuffer.slice is not allowed because it '
'is not supported on Tizen 2016'
}
requirement: {
type: BANNED_PROPERTY
value: 'TypedArray.prototype.slice'
error_message: 'TypedArray.slice is not allowed because it '
'is not supported on IE11'
whitelist_regexp: 'lib/polyfill/patchedmediakeys_apple.js'
}
requirement: {
type: BANNED_NAME
value: 'ArrayBuffer.isView'
error_message: 'ES6 ArrayBuffer methods are not allowed '
'because they are not supported in IE11'
}
requirement: {
type: BANNED_NAME
value: 'Int8Array.of'
value: 'Int8Array.from'
value: 'Uint8Array.of'
value: 'Uint8Array.from'
value: 'Uint8ClampedArray.of'
value: 'Uint8ClampedArray.from'
value: 'Int16Array.of'
value: 'Int16Array.from'
value: 'Uint16Array.of'
value: 'Uint16Array.from'
value: 'Int32Array.of'
value: 'Int32Array.from'
value: 'Uint32Array.of'
value: 'Uint32Array.from'
value: 'Float32Array.of'
value: 'Float32Array.from'
value: 'Float64Array.of'
value: 'Float64Array.from'
error_message: 'ES6 TypedArray methods are not allowed '
'because they are not supported in IE11'
}

# Disallow the general use of fetch, which is not available on all supported
# platforms.
Expand Down
8 changes: 3 additions & 5 deletions demo/asset_card.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,9 @@ shakaDemo.AssetCard = class {
this.progressCircleSvg_.appendChild(this.progressCircleBack_);
this.progressCircleSvg_.appendChild(this.progressCircleBar_);
this.progressCircle_.appendChild(this.progressCircleSvg_);
// You can't use access the classList of an svg on IE, so set the class
// attribute instead.
this.progressCircleSvg_.setAttribute('class', 'progress-circle-svg');
this.progressCircleBack_.setAttribute('class', 'progress-circle-back');
this.progressCircleBar_.setAttribute('class', 'progress-circle-bar');
this.progressCircleSvg_.classList.add('progress-circle-svg');
this.progressCircleBack_.classList.add('progress-circle-back');
this.progressCircleBar_.classList.add('progress-circle-bar');

parentDiv.appendChild(this.card_);
// Remake buttons AFTER appending to parent div, so that any tooltips can
Expand Down
7 changes: 7 additions & 0 deletions docs/tutorials/faq.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Frequently Asked Questions

**Q:** Does Shaka Player support IE11?

**A:** Shaka Player no longer supports IE11 beyond v3.1. If you need Shaka
Player with IE support, checkout v3.0.x and previous versions.

<hr>

**Q:** My live stream is buffering forever or doesn't play.

**A:** Check your time-sync. In v1 we would adjust automatically to account for
Expand Down
4 changes: 0 additions & 4 deletions lib/media/media_source_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -587,10 +587,6 @@ shaka.media.MediaSourceEngine = class {
* @return {!Promise}
*/
async remove(contentType, startTime, endTime) {
// On IE11, this operation would be permitted, but would have no effect!
// See https://github.com/google/shaka-player/issues/251
goog.asserts.assert(endTime < Number.MAX_VALUE,
'remove() with MAX_VALUE or Infinity is not IE-compatible!');
const ContentType = shaka.util.ManifestParserUtils.ContentType;
if (contentType == ContentType.TEXT) {
await this.textEngine_.remove(startTime, endTime);
Expand Down
6 changes: 3 additions & 3 deletions lib/media/video_wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ shaka.media.VideoWrapper = class {
};

/**
* A class used to move the playhead away from its current time. Sometimes, IE
* and Edge ignore re-seeks. After changing the current time, check every 100ms,
* A class used to move the playhead away from its current time. Sometimes,
* Edge ignores re-seeks. After changing the current time, check every 100ms,
* retrying if the change was not accepted.
*
* Delay stats over 100 runs of a re-seeking integration test:
Expand All @@ -181,7 +181,7 @@ shaka.media.VideoWrapper = class {
* Edge - 400ms - 2%
* Chrome - 0ms - 100%
*
* TODO: File a bug on IE/Edge about this.
* TODO: File a bug on Edge about this.
*
* @implements {shaka.util.IReleasable}
* @final
Expand Down
2 changes: 1 addition & 1 deletion lib/net/http_fetch_plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ shaka.net.HttpFetchPlugin = class {
/** @type {Headers} */
const responseHeaders = response.headers;
responseHeaders.forEach((value, key) => {
// Since IE/Edge incorrectly return the header with a leading new line
// Since Edge incorrectly return the header with a leading new line
// character ('\n'), we trim the header here.
headers[key.trim()] = value;
});
Expand Down
15 changes: 4 additions & 11 deletions lib/polyfill/patchedmediakeys_ms.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,7 @@ shaka.polyfill.PatchedMediaKeysMs = class {
return;
}

// NOTE: Because "this" is a real EventTarget, on IE, the event we dispatch
// here must also be a real Event.
const event2 =
/** @type {!CustomEvent} */(document.createEvent('CustomEvent'));
event2.initCustomEvent('encrypted', false, false, null);

const event2 = new CustomEvent('encrypted');
const encryptedEvent =
/** @type {!MediaEncryptedEvent} */(/** @type {?} */(event2));
encryptedEvent.initDataType = 'cenc';
Expand Down Expand Up @@ -343,7 +338,7 @@ shaka.polyfill.PatchedMediaKeysMs.MediaKeys = class {

// Wrap native HTMLMediaElement.msSetMediaKeys with a Promise.
try {
// IE11/Edge requires that readyState >=1 before mediaKeys can be set,
// Edge requires that readyState >=1 before mediaKeys can be set,
// so check this and wait for loadedmetadata if we are not in the
// correct state
shaka.util.MediaReadyState.waitForReadyState(media,
Expand Down Expand Up @@ -418,8 +413,7 @@ class extends shaka.util.FakeEventTarget {
// This EME spec version requires a MIME content type as the 1st param to
// createSession, but doesn't seem to matter what the value is.

// NOTE: IE11 takes either Uint8Array or ArrayBuffer, but Edge 12 only
// accepts Uint8Array.
// NOTE: Edge 12 only accepts Uint8Array.
this.nativeMediaKeySession_ = this.nativeMediaKeys_.createSession(
'video/mp4', shaka.util.BufferUtils.toUint8(initData), null);

Expand Down Expand Up @@ -457,8 +451,7 @@ class extends shaka.util.FakeEventTarget {

try {
// Pass through to the native session.
// NOTE: IE11 takes either Uint8Array or ArrayBuffer, but Edge 12 only
// accepts Uint8Array.
// NOTE: Edge 12 only accepts Uint8Array.
this.nativeMediaKeySession_.update(
shaka.util.BufferUtils.toUint8(response));
} catch (exception) {
Expand Down
5 changes: 1 addition & 4 deletions lib/polyfill/patchedmediakeys_webkit.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,10 +423,7 @@ shaka.polyfill.PatchedMediaKeysWebkit.MediaKeys = class {
shaka.log.debug('PatchedMediaKeysWebkit.onWebkitNeedKey_', event);
goog.asserts.assert(this.media_, 'media_ not set in onWebkitNeedKey_');

const event2 =
/** @type {!CustomEvent} */ (document.createEvent('CustomEvent'));
event2.initCustomEvent('encrypted', false, false, null);

const event2 = new CustomEvent('encrypted');
const encryptedEvent =
/** @type {!MediaEncryptedEvent} */(/** @type {?} */(event2));
// initDataType is not used by v0.1b EME, so any valid value is fine here.
Expand Down
4 changes: 2 additions & 2 deletions lib/text/simple_text_displayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ shaka.text.SimpleTextDisplayer = class {

// Sort the cues based on start/end times. Make a copy of the array so
// we can get the index in the original ordering. Out of order cues are
// rejected by IE/Edge. See https://bit.ly/2K9VX3s
// rejected by Edge. See https://bit.ly/2K9VX3s
const sortedCues = textTrackCues.slice().sort((a, b) => {
if (a.startTime != b.startTime) {
return a.startTime - b.startTime;
Expand Down Expand Up @@ -240,7 +240,7 @@ shaka.text.SimpleTextDisplayer = class {
*/
static convertToTextTrackCue_(shakaCue) {
if (shakaCue.startTime >= shakaCue.endTime) {
// IE/Edge will throw in this case.
// Edge will throw in this case.
// See issue #501
shaka.log.warning('Invalid cue times: ' + shakaCue.startTime +
' - ' + shakaCue.endTime);
Expand Down
2 changes: 1 addition & 1 deletion lib/util/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ shaka.util.Error.Code = {
/**
* The video element reported an error.
* <br> error.data[0] is a MediaError code from the video element.
* <br> On Edge & IE, error.data[1] is a Microsoft extended error code in hex.
* <br> On Edge, error.data[1] is a Microsoft extended error code in hex.
* <br> On Chrome, error.data[2] is a string with details on the error.
* <br> See top of file for links to browser error codes.
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/util/player_configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ shaka.util.PlayerConfiguration = class {
preferNativeHls: false,
};

// Some browsers will stop earlier than others before a gap (e.g. IE/Edge
// Some browsers will stop earlier than others before a gap (e.g., Edge
// stops 0.5 seconds before a gap). So for some browsers we need to use a
// larger threshold. See: https://bit.ly/2K5xmJO
if (shaka.util.Platform.isLegacyEdge() ||
Expand Down
5 changes: 1 addition & 4 deletions test/cast/cast_utils_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,7 @@ describe('CastUtils', () => {
});

it('transfers real Events', () => {
// new Event() is not usable on IE11:
const event =
/** @type {!CustomEvent} */ (document.createEvent('CustomEvent'));
event.initCustomEvent('myEventType', false, false, null);
const event = new CustomEvent('myEventType');

// Properties that can definitely be transferred.
const nativeProperties = [
Expand Down
4 changes: 2 additions & 2 deletions test/media/streaming_engine_integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,8 @@ describe('StreamingEngine', () => {
await waiter.timeoutAfter(10).waitForMovement(video);
video.playbackRate = 10;

// Something weird happens on some platforms (variously Chromecast, IE,
// legacy Edge, and Safari) where the playhead can go past duration.
// Something weird happens on some platforms (variously Chromecast, legacy
// Edge, and Safari) where the playhead can go past duration.
// To cope with this, don't fail on timeout. If the video never got
// flagged as "ended", check for the playhead to be near or past the end.
await waiter.timeoutAfter(30).failOnTimeout(false).waitForEnd(video);
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 0 additions & 1 deletion test/test/assets/screenshots/review.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
'safari-Mac',
'msedge-Windows',
'xboxone',
'internet explorer-Windows',
];

const screenshots = [
Expand Down
10 changes: 1 addition & 9 deletions test/test/util/ui_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,7 @@ shaka.test.UiUtils = class {
* @param {string} name
*/
static simulateEvent(target, name) {
const type = {
'click': 'MouseEvent',
'dblclick': 'MouseEvent',
}[name] || 'CustomEvent';

// Note we can't use the MouseEvent constructor since it isn't supported on
// IE11.
const event = document.createEvent(type);
event.initEvent(name, true, true);
const event = new MouseEvent(name, {'bubbles': true, 'cancelable': true});
target.dispatchEvent(event);
}

Expand Down
4 changes: 2 additions & 2 deletions test/text/simple_text_displayer_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ describe('SimpleTextDisplayer', () => {
]);

// Next we test the behavior with a VTTCue which is seen as a cheap
// polyfill (in which prototype.line does not exist). This simulates IE
// and legacy Edge.
// polyfill (in which prototype.line does not exist). This simulates
// legacy Edge.
// eslint-disable-next-line no-restricted-syntax
delete window.VTTCue.prototype['line'];
displayer.remove(0, Infinity); // Clear the cues from above.
Expand Down
4 changes: 2 additions & 2 deletions test/ui/text_displayer_layout_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ filterDescribe('TextDisplayer layout', supportsScreenshots, () => {
// element itself.
videoContainer = video;

// On Firefox, Safari, IE11, and legacy Edge, the video must be played a
// little _after_ appending cues in order to consistently show subtitles
// On Firefox, Safari, and legacy Edge, the video must be played a little
// _after_ appending cues in order to consistently show subtitles
// natively on the video element.
beforeScreenshot = async (time) => {
// Seek to the beginning so that we can reasonably wait for movement
Expand Down
8 changes: 2 additions & 6 deletions test/util/event_manager_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,8 @@ describe('EventManager', () => {
eventManager = new shaka.util.EventManager();
target1 = document.createElement('div');
target2 = document.createElement('div');

// new Event() is current, but document.createEvent() works back to IE11.
event1 = /** @type {!Event} */ (document.createEvent('Event'));
event1.initEvent('eventtype1', false, false);
event2 = /** @type {!Event} */ (document.createEvent('Event'));
event2.initEvent('eventtype2', false, false);
event1 = new Event('eventtype1');
event2 = new Event('eventtype2');
});

afterEach(() => {
Expand Down
7 changes: 3 additions & 4 deletions ui/controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -745,8 +745,7 @@ shaka.ui.Controls = class extends shaka.util.FakeEventTarget {

const svg =
/** @type {!HTMLElement} */(document.createElementNS(xmlns, 'svg'));
// NOTE: SVG elements do not have a classList on IE, so use setAttribute.
svg.setAttribute('class', 'shaka-spinner-svg');
svg.classList.add('shaka-spinner-svg');
svg.setAttribute('viewBox', '0 0 30 30');
spinner.appendChild(svg);

Expand All @@ -755,7 +754,7 @@ shaka.ui.Controls = class extends shaka.util.FakeEventTarget {
// "Scalable." The radius of 14.5 is so that the edges of the 1-px-wide
// stroke will touch the edges of the viewBox.
const spinnerCircle = document.createElementNS(xmlns, 'circle');
spinnerCircle.setAttribute('class', 'shaka-spinner-path');
spinnerCircle.classList.add('shaka-spinner-path');
spinnerCircle.setAttribute('cx', '15');
spinnerCircle.setAttribute('cy', '15');
spinnerCircle.setAttribute('r', '14.5');
Expand Down Expand Up @@ -1061,7 +1060,7 @@ shaka.ui.Controls = class extends shaka.util.FakeEventTarget {
* @private
*/
onMouseStill_() {
// Hide the cursor. (NOTE: not supported on IE)
// Hide the cursor.
this.videoContainer_.style.cursor = 'none';
this.recentMouseMovement_ = false;
this.computeOpacity();
Expand Down
6 changes: 1 addition & 5 deletions ui/language_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,9 @@ shaka.ui.LanguageUtils = class {
currentSelectionElement, localization, trackLabelFormat) {
// TODO: Do the benefits of having this common code in a method still
// outweigh the complexity of the parameter list?

// Using array.filter(f)[0] as an alternative to array.find(f) which is
// not supported in IE11.
const activeTracks = tracks.filter((track) => {
const selectedTrack = tracks.find((track) => {
return track.active == true;
});
const selectedTrack = activeTracks[0];

// Remove old tracks
// 1. Save the back to menu button
Expand Down

0 comments on commit 95ba28b

Please sign in to comment.