Commit Graph

178 Commits

Author SHA1 Message Date
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
Joey Parrish 09bb56164a Do not export individual polyfill docs
Also corrects duplicate Promise entry.

Change-Id: I7d675b0e8bbcbcb1dc1508f3c08e0a3811149d63
2016-03-01 17:51:14 +00:00
Joey Parrish 9d70cad0ea Simplify FakeEvent and FakeEventTarget
We now avoid tricky things like CustomEvent and setting properties on
native Events.  This gives us better cross-browser compatibility and
less complexity.

Change-Id: Idc9fcc69c33257e4540d956bcbc949de6d992cf0
2016-02-29 17:58:55 +00:00
Joey Parrish d0701d525c DrmEngine integration tests and associated fixes
- Update MediaKeyStatusMap definitions
 - Remove MediaKeyStatusMap iterators (not present in Edge)
 - Work around MediaKeyStatusMap interop issues
 - Update MSMediaKeys definitions (stricter on Edge 12 than IE 11)
 - Add onKeyStatus callback from DrmEngine and associated unit tests
 - Unpack PlayReady license requests
 - Byte-swap Edge 13 key IDs
 - Fix nullability of types in NetworkingEngine
 - Skip all DrmEngine integration tests unless either Widevine or
   PlayReady are available.

Change-Id: I49cbcdb5f82afa9a70a127601b195cf0794e1181
2016-02-22 16:23:33 -08:00
Jacob Trimble 49b238b3c9 Fix support for UTF-8 encoded data.
Before, we simply converted each byte from an ArrayBuffer into a
character; however, this is only valid for ASCII characters.  This
changes it to fully support UTF-8 encoded network responses.

Change-Id: I9c49f29b09960501d345b98aa7af1bb711972abf
2016-02-23 00:12:43 +00:00
Joey Parrish 813b746160 DrmEngine and associated tests
This is mostly complete, but needs additional integration with an
as-yet-unwritten AbrManager.

Change-Id: I3836040c6891fb774be800b53679f49e365c7e1c
2016-02-12 16:06:31 -08:00
Joey Parrish 069e5eda3b Sync Promise polyfill with master branch
Several fixes were made recently for v1.6.3

Change-Id: I20ffc0f647973962839d8b5322bfbf331880aa34
2016-02-12 22:02:49 +00:00
Jacob Trimble 47a99253b0 Polyfills now register as plugins.
Change-Id: I498bda84d92f2c733f120e1b1c5a0ccae305ba15
2016-02-02 12:11:49 -08:00
Joey Parrish 18678f2492 Fix IE11 test failures
This fixes small incompatibilities for IE11:
 - XML parser sometimes fails by throwing rather than returning null
 - bug in Promise polyfill prevented use of Promise.all([null, p])
 - IE11 does not have ArrayBuffer.prototype.slice, used by integration
   tests to clone a buffer in StreamGenerator

Change-Id: I9ace6bd17cd60272f85ce388342ca456f14d04c9
2016-01-29 09:18:07 -08:00
Joey Parrish 3bb8f06b7d Require assertion messages
This will enforce messages on assertions, which should make console
logs more useful.

Change-Id: I2cff9e20f630d1d4d46192e2ee317b1942cc7188
2016-01-08 13:29:56 -08:00
Joey Parrish e798f060dc Add property docs to internal typedefs
We will be transitioning toward a new way of documenting record
typedefs.  Each record will be annotated with 'property' for each
field in the record.  This results in better output from jsdoc.

This covers all internal record types.  External records will be
handled in a separate CL.

Change-Id: I2ab93015bfc9db01b4b6d474b608709c99fd70cd
2016-01-04 12:36:44 -08:00
Joey Parrish 6876ee08cc Use navigator instead of Navigator.prototype
This fixes support checks on Chrome 26, 27, and 28,
and Opera 15.

Change-Id: Ib33ca28754153679bda41fc3c2f6a37a93ed2c99
2015-12-15 17:37:29 +00:00
Joey Parrish 1d1a0fcb46 Enable all compiler errors
This also cleans up compiler errors for:
  - Things required but not used
  - Things used but not required
  - Write-only local variables

We are suppressing the 'unnecessaryCasts' error in specific places
where it is, in fact, necessary to convert between unrelated types
for polyfills and work-alikes.

Change-Id: I155c746116f95383ea0a9caf9239fadccd8601af
2015-12-11 13:30:44 -08:00
Joey Parrish 3e7014db2b Fix library load and polyfill for old browsers
This will allow support-testing to work on older browsers so that
application developers can still load the library and query for
support to show an appropriate error message.

To accomplish this, we avoid load-time uses of Function.bind, avoid
certain polyfills if modern types are not available, and compile down
to ES3 to avoid errors caused by use of the reserved word "catch" on
Promises.

This has been tested back to IE6, Safari 5.1, iOS 6.0, Firefox 6,
Chrome 15, and Opera 16.

Change-Id: I9deed106a7736758e04452ef85bae40f37c6fe62
2015-12-10 10:49:45 -08:00
Joey Parrish a4b947c9a4 Add @struct to @constructors
Change-Id: I0c4f0468cc0f7632c71ec15e458c9a1d84a2c2af
2015-12-07 18:04:55 +00:00
Joey Parrish 316e4c291f Fix compiled Promise polyfill
Installation of the Promise polyfill was incomplete in compiled mode,
since static methods were not attached to the constructor by the
compiler.

Cherry-picked from v1.6.1.

Change-Id: I304662dfdb88d2fb76fc8c06a23fc6fae2f5b1f1
2015-12-06 22:45:56 +00:00
Joey Parrish fff5dd7ee7 Audit exports
This changes namespace exports to the more targetted exportDoc,
adds exports where they are needed and removes them where they are
not.  Exporting of Uint8Array and String utils should be re-evaluated
later.

Change-Id: I9298e73a0a5ef026b6f2b1854488d2c359be10c1
2015-12-01 13:56:37 -08:00
Joey Parrish a24b8e849a Fix annotation mistakes
These mistakes were all uncovered by a forthcoming release of the
Closure compiler.

Change-Id: I84a742cd8fae36cc013f86ff7ae06e7f76501b56
2015-11-18 14:08:47 -08:00
Jacob Trimble 7c79ec5a70 Promise polyfill callback can now throw.
The callback given to the Promise constructor can throw.  If it
does, it should reject the promise.

Change-Id: I5e21e408830271e3648bf401fdac73c44ef3cc38
2015-11-10 13:06:15 -08:00
Joey Parrish 6263e1f668 Add support for YT PlayReady test content
Closes #223

Change-Id: I337fe651f50cae86b34be5829948bc1fb25ddf05
2015-11-05 18:24:27 +00:00
Jono Ward 6db78bad60 Implement suggested changes from PR review; improving clean-up of event handlers, removing some redundant code and some code-style tweaks 2015-11-02 12:26:21 +00:00
Jono Ward c9892f9180 Implementing review comments; code cleanup, mainly code style tweaks and annotation improvements 2015-11-02 12:26:21 +00:00
Jono Ward de36492f5d Add support for IE/Edge/PlayReady 2015-11-02 12:26:20 +00:00
Joey Parrish 89d8b7e94a Add support for raw values in Promise.all and Promise.race
Change-Id: Ifce7a22bc8f17f026c85bd90de2feced7f549b83
2015-10-26 11:39:05 -07:00
Joey Parrish c55978cc79 Add a Promise polyfill
This will help with porting to IE11.  Chrome, Firefox, Safari, and
Edge all have native Promises.

This polyfill does not support thenables because Shaka does not use
them.  Other than tests related to thenables, this polyfill passes
the A+ test suite.

It is also worth noting that this polyfill is incompatible with
native Promises, so it should not be used to replace a native
implementation or mixed with browser APIs that may use a native
implementation internally.

To safely test in Chrome, force prefixed EME (to avoid native
Promises), set window.Promise to null, then load some content in
the test app.  If using a verison of Chrome after prefixed EME
was dropped, use unencrypted content.

To run the A+ test suite, compile the library, install nodejs and the
module 'promises-aplus-tests', then run ./test_promise_polyfill.js.

Inspired by pull #176

Change-Id: I0d25049f162ff7f3b57bbc795403fcdedf927262
2015-10-21 11:12:18 -07:00
Joey Parrish ff1dcc2820 Refine MediaKeys polyfill error type
Inspired by code in pull #176

Change-Id: I2e29310c8a3583ed208d7bd1ae2e747a92ddf480
2015-10-20 12:42:58 -07:00
Joey Parrish 4cc4e96dbd Overhaul license comments and file annotations
* Updates all Copyright years to 2015.
* Adds licenses annotations to all JS.
* Makes all licenses identical to avoid repeated appearance in the
  compiled output.
* Drops fileoverview annotations, which do not affect docs output.
* The linter still requires fileoverview on externs.

This patch required a newer closure compiler, since the previous
version we used had a bug regarding license annotations that caused
the license comment block to appear in the output once per file
regardless of uniqueness.

Change-Id: I2e9272db680cba7ecc4613d97f1d3a94ac2244cc
2015-09-08 12:02:34 -07:00
Joey Parrish 4d9177240a Revert "Adding license annotation to js files."
This reverts commit 8cb24652cb, due to
the fact that the new annotations caused our binary size to jump
by 52%.

The compiler preserves all 'unique' licenses, which causes trouble
since the comment blocks with the license annotations are not unique
and contain file overview comments as well.

We can re-examine this once we have restructured the license headers.

Change-Id: I418e407a0e0253630633697f30cf496a7fc2ddfc
2015-09-04 18:36:39 -07:00
Yohann Connell 8cb24652cb Adding license annotation to js files.
Change-Id: Id10592ccaf35608ac4f01844cae2fec4a2030d65
2015-09-04 00:05:17 +00:00