Commit Graph

106 Commits

Author SHA1 Message Date
Theodore Abshire 7c5186332b Typo fixes and rewording in comments, part 7
This makes a large number of small typo fixes. It also rewords a
number of comments and JSDoc descriptions, and does some
formatting standardization.

This doesn't fix every single issue, but it fixes a lot. Notably,
there were some formatting issues I declined to standardize due to
ambivalence on what the proper standardization would be; for example,
when and where empty lines should show up in JSDoc.

Change-Id: I225f5c7e54adf4cca8512cddae082ba50ed82e4e
2018-03-21 19:45:15 +00:00
Theodore Abshire d46e8fdf92 Typo fixes and rewording in comments, part 6
This makes a large number of small typo fixes. It also rewords a
number of comments and JSDoc descriptions, and does some
formatting standardization.

This doesn't fix every single issue, but it fixes a lot. Notably,
there were some formatting issues I declined to standardize due to
ambivalence on what the proper standardization would be; for example,
when and where empty lines should show up in JSDoc.

Change-Id: I2bfa4d531a8fcdcf9578e9c181c4534ad7443b7a
2018-03-21 17:59:42 +00:00
Theodore Abshire f58afd21da Typo fixes and rewording in comments, part 5
This makes a large number of small typo fixes. It also rewords a
number of comments and JSDoc descriptions, and does some
formatting standardization.

This doesn't fix every single issue, but it fixes a lot. Notably,
there were some formatting issues I declined to standardize due to
ambivalence on what the proper standardization would be; for example,
when and where empty lines should show up in JSDoc.

Change-Id: Ibcaf21382bd78b91e589122983dd14e001bfdad5
2018-03-21 17:25:13 +00:00
Jacob Trimble bfb42c69c4 Make EME polyfills independent.
Now each EME polyfill can be removed independently; this allows
someone to remove just the IE11 polyfill while still keeping the
others.

This adds a priority ordering to the polyfills so the nop polyfill
will be run last as a fallback if there are no other polyfills.

Issue #1261

Change-Id: I865e1c0d6a73a079dd91505e96572e215e6f6c6a
2018-03-06 21:34:25 +00:00
Jacob Trimble b512db87dd Convert 'var' to 'let'/'const' (8 of 9).
This is part of a change to convert all usages of 'var' with either
'let' or 'const'.  This takes a conservative approach for 'const' where
it will only be used for aliases and storing the "original" values in
tests.

Change-Id: I6a329d28e13a81c9f7136737518c6bb8fa18402e
2018-02-20 11:29:30 -08:00
Joey Parrish 82357486a6 Replace buggy Promise polyfill
A bug in our Promise polyfill caused issues with the recently-added
AbortableOperation class on IE11.  Since external polyfills for this
are smaller, it is easier to remove ours in favor of a third-party
polyfill.  Applications that wish to support IE11 must now load this
additional polyfill.

We are using the "es6-promise-polyfill" module from npm, but any
compliant polyfill should suffice.

One feature our own polyfill offered was the ability to flush all
Promises, which allowed us to write synchronous unit tests that
simulated async processes.  To get this ability back, we are now
using the "promise-mock" module in our tests.

Getting "promise-mock" to load correctly involved switching from
"requirejs" to "cajon", which builds on requirejs and supports
AMD modules more directly.

Closes #1260

Change-Id: I5de48e88a910736ae5c1897a7a509bc5641acb70
2018-01-30 23:10:04 +00:00
Joey Parrish a63352c8f3 [ES6] Enable stricter checks in eslint
This digests and organizes many of the automatic settings in eslint,
and changes several of them to be more strict.  This also fixes the
following errors:
  - array-callback-return
  - no-catch-shadow
  - no-multi-spaces
  - no-new
  - no-throw-literal
  - no-useless-call
  - no-useless-concat
  - no-useless-return

Several checks have been organized into a group of checks we should
use, but need more time to implement and fix.  Some other checks have
been delegated to the Closure compiler, which can more precisely
whitelist exceptions.

Issue #1157

Change-Id: I8fe4966959e08050f8159e6a1fee161e7d71177e
2018-01-17 21:56:41 +00:00
Joey Parrish 4067c20a7c [ES6] Replace gjslint with compiler linter & eslint
The eslint configuration is derived from analyzing the style of our
sources as they are now, plus a few tweaks.

In particular, we have disabled checks for undefined variables and use
of console, both of which the compiler handle with greater precision.
The compiler already knows what is defined in the environment through
our externs, and has specific exceptions for the use of console (demo,
tests).

We have also disabled a few checks that we should use, but will
require many changes to the code: no-unused-vars, no-redeclare,
and comma-dangle.

This commit also fixes several types of eslint errors that were easy:
  - no-useless-escape (unneccessary escape characters in Regexp)
  - no-constant-condition (using true/false/0/1/etc in if/while)
  - no-fallthrough (caught an actual bug in one EME polyfill)
  - no-irregular-whitespace (we had a UTF-8 nbsp in externs)
  - no-cond-assign (using an assignment inside a conditional)

To satisfy stricter provide/require checks in the Closure Compiler
Linter, we will no longer use provide/require at all in tests.  We
will still use provide in test utilities (test/test/util/) since it
sets up the namespace for us.  But we will not use require there
because there is no deps management for test code.

Issue #1157

Change-Id: Icc44f51feeb568ea7d3980e693e92e560d897afd
2018-01-16 17:25:05 +00:00
Joey Parrish 1a2c88745e Upgrade the Closure compiler to v20171203
Change-Id: Id0dd4619db0c3a141d60e9e38757739e0697e6f0
2018-01-03 15:07:02 -08:00
Joey Parrish e2aef50912 Disallow unknown "this"
This change enables an additional conformance check in the compiler
which prevents us from committing code where the compiler fails to
infer what "this" means.

None of these changes constituted actual bugs, just inference failures
in the compiler.

Issue #1130

Change-Id: If9b18203768e197258042a9b4339530f371ed831
2017-11-15 11:35:56 -08:00
Theodore Abshire c6ddf593e5 Polyfill Safari 11 MSE bug in SourceBuffer.remove
SourceBuffer.remove, when told to remove exactly up to a keyframe,
will also remove that keyframe and all of the content till the next
keyframe. This results in far too much content being deleted, and is
breaking our tests on Safari 11.

Patching this by offseting the end of the removal range by 1ms seems
to be a viable workaround.

Closes #1048

Change-Id: I062b2dc2617f1372f885f4ccbc906d77c65412d7
2017-10-05 13:15:25 -07:00
Joey Parrish 859d7d1a8f Reject TS content in Safari
Because Safari's support for TS via MSE is broken, reject all TS
content in Safari.  Transmuxing (#887) will compensate.

https://bugs.webkit.org/show_bug.cgi?id=165342

Closes #743

Change-Id: Iff8a6a7c159e48a4f388d99396915752e649c6ac
2017-10-03 15:31:10 -07:00
Joey Parrish 87b723473b Apply MSE patches to Safari 11
One of the Safari 10 bugs we work around is still present in Safari 11.

Issue #1048

Change-Id: I54e146bcce9770f980a0dabd477a86b482a6c901
2017-10-03 15:31:09 -07:00
Joey Parrish b7b890b908 Add a polyfill for Chromecast isTypeSupported
There are several issues with isTypeSupported on Chromecast that
require workarounds in JavaScript:
  - Dolby Vision strings must be removed from the codecs parameter,
    even though the content is supported by the platform
  - HDR must be guessed at from the codecs parameter and an additional
    parameter must be added to query HDR support
  - Queries must be made through a non-standard interface

Change-Id: I4c8c70e70cf9c26283913783f5f62f7d6470c2f1
2017-08-17 17:35:00 +00:00
Jacob Trimble b974a1d12d Fix field renaming in Safari polyfill.
Closes #974

Change-Id: I407f7d0437383e05c42c0762bad42337bd558f8c
2017-08-15 17:21:38 -07:00
Joey Parrish d1df5dade6 Make it safe to install polyfills twice
Closes #941

Change-Id: I706aadd1bfc2c477d0ac8a0dff13defad74b3bda
2017-07-24 12:25:46 -07:00
Joey Parrish 84a8d1ca18 Polyfill the HTML5 'input' event
The HTML5 'input' event does not work correctly on all input elements
in IE 11.  There are equivalent events that the UI can use on IE.

Instead of remembering this and checking for IE every time the 'input'
event is needed, let the polyfill translate the event type.

Change-Id: I23258a5c6a0bd37e946214380ad07949f3ee7f88
2017-07-12 12:29:14 -07:00
Joey Parrish c69a009960 Do not assume persistent storage support
Two EME polyfills currently assume persistent storage support: one
for old Tizen TVs and other older embedded Chromium devices, and one
for IE11.

This backfires when an application is trying to detect support for
encrypted offline content.

By removing this assumption, we do not convey support for EME features
that are not known to be available on these devices.

Change-Id: If427eeda1cde60341a2b57f76744c2adfdb34beb
2017-07-12 18:46:08 +00:00
Jacob Trimble adb8da4764 Disallow unknown properties (1/5).
This is part of adding a new conformance rule to add additional type
safety.  This will disallow using properties of unknown types or using
unknown properties.

The first parts will be fixing errors caused by the new rule.  These
are backwards compatible, so can be applied before the rule is enabled.
Once all the errors and bugs are fixed, the rule will be enabled.

Change-Id: Iefde089b2f62ddfdf43944cda5badab438577561
2017-06-27 19:43:00 +00:00
Joey Parrish 53220b5acb Polyfill video.play to silence confusing errors
Closes #836

Change-Id: Ie5b42bc707ce7443641e86c04ec116fd732bbbae
2017-06-05 12:34:31 -07:00
iKinnrot f145dffc9e Fix math round when number > 2^52 on IE11 (#832)
Don't use math round on ie11 if number > 2^52.
2017-06-02 14:51:25 -07:00
Joey Parrish 2f5e2dbc5b Fix declaration of unprefixed v0.1b APIs
Change-Id: I0334b08d5e67320f19f6df78fb1271278b9d3078
2017-05-17 16:28:23 +00:00
Joey Parrish afb3a634b6 Update EME polyfills setServerCertificate to spec
The method should return a Promise resolved with false if unsupported.

Change-Id: I304f2566fc2cf6521eb35f963d7c862e3eca1f48
2017-05-08 23:37:08 +00:00
Ross-cz 3831664a22 Fix fullscreen polyfill for MSIE 11 (#777) 2017-05-05 15:35:27 -07:00
Jacob Trimble 67c874c2ca Fix some test contaminations.
There were two instances of tests not cleaning up correctly.  The
Dash Live tests didn't uninstall the Promise polyfill, which breaks
Promise.resolve for tests that don't expect it.  Also, in the
CastReceiver tests, it defines a property on window.  It needs to be
configurable, otherwise it cannot be set twice.  Somehow the resulting
exception is not being caught by jasmine.

Change-Id: I0691a7bcddf14fd455f034d63e12fc8046044750
2017-03-28 12:16:08 -07:00
Theodore Abshire 8ab9188bdb Expanded the fullscreen polyfill.
Now it includes fullscreenEnabled.

Closes #669

Change-Id: I7df3c422ecc72215a48ba72ac57aae2bc9b600d5
2017-02-10 22:05:31 +00:00
Aaron Vaage f0286ae7f8 Fixing DBEngine Failures on Chromecast
The Chromecast reports supporting IndexedDB but whenever an insert
command was performed, the operation would hang indefinitely.

This change introduces a pollyfill for the Chromecast that will
remove the indexed db reference which will have DBEngine's
"is supported" behavior to report no support.

Alone this change would not stop the tests from running, so the
DBEngine tests had to be updated to first check that the DEngine
is supported on the active platform.

Bug: 34927282
Change-Id: I8d4797f0981b014fb42db1c237c85704888bea7f
2017-02-08 00:04:23 +00:00
Jozef Chutka ca299b2822 VTTCue polyfill (#643)
This adds a VTTCue polyfill for IE/Edge (3-arg TextTrackCue) and
Toshiba dTV (6-arg TextTrackCue).

Closes #635
2017-01-17 10:42:54 -08:00
Theodore Abshire 292fd9a0db Fixed a bug with resolve in the promise polyfill.
Now, when you pass a rejected or pending promise into Promise.resolve(),
it won't count as resolved.

Change-Id: Ib2ee6e12625753436bfeb0b418dd824df4bb422a
2017-01-09 21:10:32 +00:00
Jozef Chutka be0d4b56cb Add support for Toshiba dTV (#605)
Toshiba has EME v0.1b, but without the webkit prefix.  This generalizes
the WebKit MediaKeys polyfill to work with or without a prefix.
2016-12-14 09:53:29 -08:00
Joey Parrish 5963e0ddd4 Update MediaSource polyfills for Safari 10
Safari 10 has some new MediaSource implementation bugs that need to
be worked around.  This updates and refactors the polyfills for Safari
10.

Bugs filed:
  https://goo.gl/qCeTZr
  https://goo.gl/rC3CLj

Closes #615

Change-Id: Id694798cd083878f337c0ba6e017fcdaac3c69be
2016-12-05 19:43:10 +00:00
Joey Parrish 09d221de16 Update the Closure Compiler to v20161024
Change-Id: I6642b1e386667028c1adbcce97ab64b21a9104b9
2016-11-11 22:08:43 +00:00
Joey Parrish 894c56d3c9 Remove suppression of "unnecessaryCasts"
This no longer seems to be needed.

Change-Id: I8f9ed03f97b235d4652930745d4416f6c8f77445
2016-11-04 19:40:55 +00:00
Joey Parrish 2ba7427111 Eat exceptions thrown by webkitCancelKeyRequest
The MediaKeys polyfill for EME v0.1b may throw an exception in
webkitCancelKeyRequest.  Reported by LG.

Change-Id: I87edec4868977ddaee5946c64b80724c4ed2f18e
2016-10-25 23:32:00 +00:00
Joey Parrish 8ec7164878 Do not export any part of the Promise polyfill
If we use @export in the Promise polyfill, those methods will end up
attached to the polyfill namespace in the compiled code, and will also
end up in the generated externs (coming soon).

By exporting then() and catch() manually, we avoid this.

Change-Id: Ib12b4d9319452ceed802c8fdc8c47d9c09dd24a5
2016-09-30 16:54:43 +00:00
Joey Parrish ef6a7f9e3a Fill out interfaces in MediaKeys polyfill
The interfaces for these polyfill types were not fully implemented
because we do not use every part of the interface in the library.
A newer version of the compiler is stricter about this.

Change-Id: I5164717159544a62640b14aca1a2c7b2d44a33ba
2016-09-29 16:25:34 -07:00
Joey Parrish 1ba2ebb23e Simplify and speed up fakeEventLoop with polyfill
Forcing the use of the Promise polyfill allows us to remove the hacky
parts of fakeEventLoop and gives a huge boost in speed for the tests
that use it, particularly on Edge where the delays were large.  Many
fakeEventLoop tests can now run synchronously.

Time to run tests in our lab before this change:
  - Edge: 21 minutes
  - Safari: 6 minutes
  - Chrome, Firefox, Opera, IE: 6-7 minutes

Time to run tests in our lab after this change:
  - All browsers: 5-6 minutes

This also reduces the incidence of Safari failures in our lab, but
that issue does not reproduce on other machines.  It looks
increasingly likely that our lab machine is faulty and needs to be
replaced.

Change-Id: I7bdcc6830c8fdf298538ce6538b1ca8e1b92cab2
2016-08-18 19:51:48 +00:00
Jacob Trimble 858499f09f Added unit tests for Promise polyfill.
Closes #212

Change-Id: I33e40269c6cd1aeb051ae69e96fbcaf0d0a02ed7
2016-08-15 09:16:04 -07:00
Joey Parrish 8c7c74e950 Polyfill Safari 9 MediaSource bugs
This adds a polyfill for a Safari 9 MediaSource bug where calling
abort() on SourceBuffer causes the decoder to fail.

The reason we call abort() at all is to reset the decoder and smooth
segment transitions on Chrome, Firefox, and Opera.  Safari does not
seem to have this problem in the first place, so it is fine to
completely stub out abort().

Issue #446

Change-Id: Icbaaa3e9ce5372efdee937ddc4cf94a27dce6a47
2016-07-29 18:42:31 +00:00
Joey Parrish 9576c5b2cb Rename MediaKeys polyfills
Newer closure compilers do not seem to recognize the MediaKeys
polyfill classes namespaces because they don't follow normal
conventions.  This leads to errors about missing requires.

This renames the classes as follows:

  PatchedMediaKeys.nop       => PatchedMediaKeysNop
  PatchedMediaKeys.v01b      => PatchedMediaKeysWebkit
  PatchedMediaKeys.v20140218 => PatchedMediaKeysMs

The new names follow normal conventions and refer to the polyfills by
the prefix of the old API rather than by the version number.

This should help us upgrade to a newer compiler.

Closes #456

Change-Id: I5491ecb9a61e2b456ba8fa81a6adb6c110c96817
2016-07-24 16:27:40 -07:00
Joey Parrish b1141d5693 Swap MediaKeyStatusMap.forEach argument order
The EME spec has updated and clarified forEach such that we need to
swap the argument order again.

Change-Id: Ida18195fcccc79d4b32a0def0ff82dfad8b88856
2016-07-01 17:50:53 +00:00
Andy Hochhaus 87a62d717e Add missing goog.require() dependencies 2016-06-25 15:45:15 -07:00
Joey Parrish b8ccc02320 Fix support test on old browsers
- IE did not get forEach until IE 9, so it can't be used in
   polyfill.installAll().
 - Object.keys, console, and console.log.bind may all be unavailable
   on older browsers, so skip initialization of on-screen logging in
   the demo app if they are missing.  The support test will fail
   anyway.
 - 'catch' is a reserved word on older browsers, so use the two-arg
   version of then() to catch promise failures.

With these fixes, the support test can again be used on old browsers,
and the compiled-mode demo app can report an error back to IE 6.

Change-Id: I3019468f24a510a265ad5b13df4f01cd1bb1f34d
2016-04-07 20:51:24 +00:00
Joey Parrish b214827785 Add partial support for thenables
Fixes test failures on IE11 since test utils now use thenables

Change-Id: I53d81367716839d419ee9ee6d865ce68405a7623
2016-03-29 23:57:01 +00:00
Joey Parrish 428e79a546 Fix DrmEngine integration on IE 11
This fixes DrmEngine integration tests on IE 11 by:
 - fixing key status for persistent policies in the IE 11 polyfill
 - fixing test flow for persistent policies

Key status is still broken on Edge 13

Change-Id: If1a1abf53f24cdb31260569603bb5b2886fade43
2016-03-16 23:14:48 +00:00
Jacob Trimble 19973d63f4 Changed copyright headers from 2015 to 2016.
Change-Id: I429ff27e4794c03b7ea392e38415075077f9bfb1
2016-03-15 16:32:13 -07:00
Jacob Trimble 8daf53e329 Renamed shaka.asserts to goog.asserts.
Using goog.asserts will work with the compiler.  So rather than
simply casting a nullable value when passing to a method, we can use
an assert which will correct the type and print a log if it somehow
is null.

This is not the same goog.asserts found in closure library, this
simply calls console.assert, but it is not required to do anything
for the compiler help.

Change-Id: I2548e39e772f0aa7ec41437cf9f5a2be383e0fbd
2016-03-11 15:29:20 -08:00
Jacob Trimble 846e7beb48 Unified comment spacing.
Before there were two style to indent comments after an annotation,
using 2 and 4 spaces.  Now this only uses 2 spaces.

Change-Id: Id06415d7193cc154a2768fb3932aff7a06b7ed32
2016-03-10 16:27:45 -08:00
Joey Parrish 78e996d090 Fix issues found by the newest Closure compiler
Fixes the following issues:
=====

lib/player.js:106: ERROR - Property id never defined on TextTrack

lib/util/xml_utils.js:42: ERROR - inconsistent return type
found   : (Node|null)
required: (Element|null)

lib/dash/content_protection.js:256: ERROR - Parameter must have JSDoc.
      function(element) {

lib/dash/content_protection.js:284: ERROR - Parameter must have JSDoc.
      function(elem) {

lib/media/drm_engine.js:47: ERROR - Private property configuration_ is never read

lib/polyfill/patchedmediakeys_20140218.js:269: ERROR - Private property keySystem_ is never read

lib/polyfill/patchedmediakeys_20140218.js:389: ERROR - Private property type_ is never read

lib/util/language_utils.js:84: ERROR - The value 0.0 is duplicated in this enum.
  MIN: 0, MAX: 2

lib/util/language_utils.js:84: ERROR - The value 2.0 is duplicated in this enum.
  MIN: 0, MAX: 2

demo/assets.js:171: ERROR - Value assigned to local variable headers is never read

lib/dash/content_protection.js:188: ERROR - Value assigned to local variable repUnknown is never read

lib/dash/dash_parser.js:400: ERROR - Value assigned to local variable suggestedDelay is never read

lib/dash/segment_base.js:41: ERROR - Value assigned to local variable SegmentBase is never read

lib/dash/segment_template.js:291: ERROR - Value assigned to local variable periodStart is never read

lib/media/drm_engine.js:172: ERROR - Value assigned to local variable onEncrypted is never read

test/dash_parser_live_unit.js:358: ERROR - Value assigned to local variable manifest is never read

test/drm_engine_unit.js:383: ERROR - Value assigned to local variable cert1 is never read

test/drm_engine_unit.js:384: ERROR - Value assigned to local variable cert2 is never read

test/media_source_engine_unit.js:24: ERROR - Value assigned to local variable dummyData is never read

test/media_source_engine_unit.js:504: ERROR - Value assigned to local variable p2 is never read

test/media_source_engine_unit.js:505: ERROR - Value assigned to local variable p3 is never read

test/media_source_engine_unit.js:506: ERROR - Value assigned to local variable p4 is never read

test/media_source_engine_unit.js:535: ERROR - Value assigned to local variable p2 is never read

test/media_source_engine_unit.js:601: ERROR - Value assigned to local variable p2 is never read

test/media_source_engine_unit.js:602: ERROR - Value assigned to local variable p3 is never read

test/media_source_engine_unit.js:603: ERROR - Value assigned to local variable p4 is never read

test/media_source_engine_unit.js:632: ERROR - Value assigned to local variable p2 is never read

test/mpd_utils_unit.js:20: ERROR - Value assigned to local variable HUGE_NUMBER_STRING is never read

test/streaming_engine_integration.js:55: ERROR - Value assigned to local variable onSeek is never read

test/streaming_engine_unit.js:1263: ERROR - Value assigned to local variable reportedContentType is never read

test/streaming_engine_unit.js:1264: ERROR - Value assigned to local variable reportedPeriodIndex is never read

test/streaming_engine_unit.js:1540: ERROR - Value assigned to local variable size is never read

test/util/dash_parser_util.js:77: ERROR - Value assigned to local variable retry is never read

test/util/dash_parser_util.js💯 ERROR - Value assigned to local variable retry is never read

test/vtt_text_parser_unit.js:272: ERROR - Value assigned to local variable result is never read

Change-Id: I707700250541e04ccbfe81d7298b3f0c5a82dcdc
2016-03-03 16:04:58 -08:00
Joey Parrish bdb35f5952 Fix IE EME polyfill WRT event dispatch
This broke in 9d70cad0 when we simplified FakeEvent and
FakeEventTarget. Now that FakeEvents are no longer based on real
Events, we cannot dispatch a FakeEvent from a real EventTarget on
IE.

Change-Id: I81635ef40ac627cf757a87c12b3a5a94068a0ad8
2016-03-01 11:25:29 -08:00