Commit Graph

102 Commits

Author SHA1 Message Date
Joey Parrish 7e6a0f38ff fix: Correct license headers in misc. files
This corrects/normalizes license headers in misc. files, such as
config files, docs, build tools, tests, and externs.  This does not
affect the compiled output, and is only done for consistency.

Issue #2638

Change-Id: I9d8da2de55243b08d7df2b743aac73c6f15e858a
2020-06-09 16:13:56 -07:00
Joey Parrish b839340220 Add screenshot-based layout tests for subtitles
This adds our first screenshot-based layout tests and the
infrastructure to use WebDriver for screenshots through Karma.
This new kind of test will be skipped in any non-WebDriver context.

There are many pieces to this system.

First, we update the Karma WebDriver launcher to a newly-released
version that lets us access the client spec object from the launcher.

Second, we build a Karma middleware plugin to respond to HTTP requests
from the tests.  We handle /screenshot/isSupported and return a bool
so tests can be skipped on non-WebDriver launchers.  We also handle
/screenshot/diff to take the screenshot and compare it to a known-good
version.

The screenshot is a full-page screenshot, since element screenshots
don't work consistently across all the browsers in our test lab.  The
screenshot is then cropped to a rectangle specified in the request.
This rectangle is measured to match a specific element, so in
practice, we are screenshotting just one element.

Browsers use sub-pixel rendering, effectively rendering at a scale
larger than the "pixels" seen by JS.  The screenshot comes in at this
scale, so the requested cropping rectangle is scaled to match, then
the cropped screenshot is scaled down to the JS-measured size.

Because of sub-pixel rendering, element offsets can be non-integer
numbers.  Normally, Karma puts the tests in a iframe, above which is a
variable-height banner showing which devices are connected to Karma
and what state they are in.  So this variation and the lack of integer
offsets means we can run into stability issues due to rounding errors.
To make offsets consistent and improve stability of the screenshots,
this banner is now disabled in our Karma config.

The cropping, scaling, and diffing of images is handled Karma-side by
a node module called Jimp.

Before we start the layout tests for UITextDisplayer, we use a node
module in the browser called fontfaceonload to wait for our web fonts
to be fully loaded.  This module is a polyfill that polls on IE and
uses a standard API in modern browsers to wait for our font to load.
This is all wrapped into a new test util called waitForFont.

Screenshots are stored in test/test/assets/screenshots/ and are
organized into folders by platform and browser and named according to
an identifier specified by each test case.  The new screenshot is
written to disk with the suffix "-new", and a diff image is written
with the suffix "-diff".  When a test fails, we can review the changes
in a browser with test/test/assets/screenshots/review.html.  The
known-good screenshots can be updated with the new tool
build/updateScreenshots.py.

Change-Id: Ib477fd3c459de466c6dc91e9a60d3e2579164b12
2020-05-26 22:38:04 +00:00
Joey Parrish 1076b78465 Unfork Closure base and update the compiler
The Closure Library's base.js, the Closure Compiler, and the Closure
deps-writer are all now loaded via NPM instead of commiting them
directly to the repo.  This also updates both the library and compiler
to the latest version: 20200406.

We still have a fork of the Closure Library's URI parser.  The latest
upstream version of that has too many dependencies on the rest of the
library to import directly from NPM.

Some internals of the build system have been refactored, and the
"complete" set of files in the build system now includes third_party.

Our forked URI parser does not pass lint checks yet, so the linter
does not run over third_party yet.

A couple of overly-severe sets of compiler checks have been disabled,
since even the latest Closure Library's base.js doesn't pass them.

The script-loader in load.js had to be updated for compatibility with
the new Closure Library.  If you don't return "true" now, Closure's
base.js will stop loading subsequent source files.

Some local externs that we had written are now available from the
compiler, so our local copies have been deleted.

A few type-related changes have been made as well, removing casts that
were necessary with the old compiler, but not necessary with the new
one.

Finally, this corrects some type issues in the tests using the new
"typeof" annotation from the compiler.  This allows us to type a
variable as a class defined elsewhere.  For example, after loading the
compiled library, we can reference compiledShaka.Player, which has the
type "typeof shaka.Player".  The compiler can then type-check all uses
of it in the tests.

Closes #2528 (bad polyfill code generated by the old compiler)

Change-Id: I62ec61e82d4edf342b2c576c2d4f89f11562ee65
2020-04-30 19:32:30 -07:00
Joey Parrish 18208f8560 Add a test to catch missing demo messages
PR #2330 introduced a new message without a definition for it.  This
test would have caught the mistake in advance.

Change-Id: I1a7b0fa2483b791b6b16405e55af84a49d100c83
2020-01-08 14:39:46 -08:00
Joey Parrish 0ad9aa3fd9 Fix EME polyfill issues
This fixes several inter-related issues:
 1. Catch errors in polyfill installation so that test setup isn't
    interrupted half-way through
 2. Use the compiled polyfill in tests, fixing polyfill installation
    error during tests on IE
 3. Require at least version 1.0.2 of the polyfill, since 1.0.0 had
    bugs in the module export and 1.0.1 had an infinite recursion bug

Change-Id: I38c973152409d9b3168e70e82f20579566663208
2019-12-02 12:28:28 -08:00
Joey Parrish 64896d70b0 Use shorter license header
This reflects changes in Google's policy on JavaScript license
headers, which should be smaller to avoid increasing the size of the
binary unnecessarily.

This also updates the company name from "Google, Inc" to "Google LLC".

Change-Id: I3f8b9ed3700b6351f43173d50c94d35c333e82b4
2019-11-22 18:18:36 +00:00
Joey Parrish b9b4118938 Add a polyfill for EME encryption scheme queries
Note that the encryptionScheme field isn't being used by Shaka Player
yet, but that this will enable us to experiment with it ahead of the
full launch of the feature in browsers.

See also:
 - https://wicg.github.io/encrypted-media-encryption-scheme/
 - https://github.com/WICG/encrypted-media-encryption-scheme/issues/13
 - https://github.com/w3c/encrypted-media/pull/457

Change-Id: I9e8c2b6ce4ce3f4fe634fa4164669c69959e7fde
2019-11-22 18:18:36 +00:00
Theodore Abshire 4c6325de08 Added localization system to demo.
No localizations exist currently, but this adds the framework for them.

Change-Id: I81a8cab128884753c765a192181d5d88f0ed13f1
2019-11-18 19:41:58 +00:00
Jacob Trimble 8973a26a83 Don't load the service worker in tests.
Change-Id: I24585d81e6be3a86c4c265ab945b03e38f7ec8ed
Fixes: 140927860
2019-09-12 14:24:20 -07:00
Theodore Abshire 83ed3559c1 Moved the config field checks into actual tests.
Also added a cleanup procedure for the demo, for use in tests.

Change-Id: Ic26a8c7b012e66cdd88c09eb8d478ceeb6743ab4
2019-09-11 22:11:09 +00:00
Jacob Trimble 4fdf8f7a1c Allow running tests without Babel.
This greatly speeds up startup time when running tests on a modern
browser.  This change also fixes a bug in one of the tests that only
worked with Babel running.

Change-Id: I1493ef30388c5043dcdf8350bec7817ab5d28d55
2019-08-20 20:10:02 +00:00
Jacob Trimble 7226ca933a Add command-line arg to change the test timeout.
The default test timeout is 120 seconds, which makes debugging test
timeouts take a long time.  This allows changing the timeout on the
command-line.

Change-Id: Ibb27e35b9ae4b71f192841ecc6ccd90ab652b0cf
2019-07-09 17:12:13 +00:00
Jacob Trimble 3da809019b Enable additional ES6 linter rules.
Change-Id: I6861541b27153ba034364a5972a9b086de581cef
2019-06-11 18:35:09 +00:00
Joey Parrish 2cf09d6301 Fix source map support in tests
This fixes incompatibilites between Karma and Babel with regard to
source maps.

Babel rewrites our code on-the-fly in the testing environment so that
we can run ES6 code and tests on older platforms.  When Babel does
this, it creates inline source maps which map the modified code back
to the original code.

Previously, the karma-source-map-support Karma framework was using
these inline source maps to map stack traces back to the original
code.  This framework, however, uses a V8-specific hook to modify
Error objects, so this only works on Chrome and Opera.

But it turns out that Karma itself already supports source maps for
formatting errors.  For some reason, though, a third-party module is
necessary to connect the dots and make Karma aware of Babel's inline
source maps.  For this, we are now using the karma-sourcemap-loader
Karma preprocessor.

We now have meaningful stack traces on all platforms.

Change-Id: If6033334bb1afb35020f17ae443d6e2192ea5d08
2019-05-22 07:43:48 -07:00
Joey Parrish f6fdec48b9 Fix coverage reports
This changes from using Karma's "coverage" preprocessor to using a
Babel plugin called "istanbul" which adds the coverage instrumentation
to the code.  Because it happens in Babel, all the code
transformations happen in one place, with consistent source maps.
Backtraces in error messages will show the original line numbers, and
code coverage reports will refer to the original line numbers, as
well.

Closes #1693

Change-Id: I706cf21c109f3ec7fa30c6899ca9872c0f8be9d1
2019-05-21 21:37:24 +00:00
Joey Parrish 908ab5a974 Drop unused CSS reference from karma.conf.js
Change-Id: I8847dcc92cb31a06ac6eff924849f8c2131254c8
2019-05-16 19:57:41 +00:00
Joey Parrish d412792e0b Update karma config for ES6
Issue #1157

Change-Id: I37630c762c760c4a0ef349b4aa32282c23b28eed
2019-05-15 20:27:18 +00:00
Joey Parrish d66d6c4255 Upgrade mux.js and use minified version
The new mux.js release fixes support for a minified build, so we
should use that from now on.

videojs/mux.js#173

Change-Id: I08cff8d33a520fe753c5490a4719cba3bb27f19e
2019-05-13 14:24:41 -07:00
Joey Parrish 9d1861599d Fix test failures on IE 11 and Tizen
In these two environments, we must convert ES6 code to ES5.  Rather
than work around specific cases, we should let babel convert all test
code into ES5.

This fixes new problems on IE and Tizen introduced with the new demo,
and reverses some work-arounds that were used before.

Change-Id: I6be5ed2cd271e88bc7ebc1e878acbec6bbc21a2e
2019-05-03 17:11:40 +00:00
Theodore Abshire efc2ed3df1 Added new demo page.
This is a complete replacement for the old demo page, made to be more
modern-looking and easier to maintain. It contains new features such as
remembering the URIs you provide for custom assets, and searching through
the default assets by feature.
This demo page is not quite ready for release yet, but it's getting close.

Change-Id: Iad01d1fc02c3cd238d73b9b9e02dbb4301cb6f2a
2019-05-01 19:58:18 +00:00
Aaron Vaage 39179c7836 Define Player Api src= Tests
Define an initial set of tests to ensure that the public player api
behaves correctly when the player has loaded content with src=.

Issue #816
Issue #997

Change-Id: Ie40bc926d1e56d37318f0ba7711903cdf8e6aa3e
2019-04-11 15:50:19 +00:00
Joey Parrish 00442a9a7c Split up localization data for lazy loading
This changes the format of the localization data to enable apps to
trivially lazy-load translations.  It also adds --locales to the build
scripts to allow app developers to choose the compiled-in locales.
The generated output now goes into dist/ and is not checked into
revision control.  Finally, it adds "description" and "meaning" fields
to the source messages to allow us to more easily integrate with a
context-aware human translation service.  The "description" field
provides application context for the translator, while the "meaning"
field provides linguistic disambiguation for words with multiple
meanings or parts of speech in the original English.

Because the translation service wants to collapse messages with
identical text, we had to merge several messages together.  To this
end, we have removed the prefixes "ARIA_LABEL_" and "LABEL_" from the
messages themselves and collapsed what remained.

Issue #1688

Change-Id: I24c17e71c73f6663cf123cfdba118c486fa80ecc
2019-04-09 16:06:14 -07:00
Joey Parrish 7d014fd195 Fix ES6-to-ES5 translation of language mapping
Tests on IE and Tizen were broken in 4d41b7b9
when the language mapping was added to the test
environment without Babel config to translate it.

This went unnoticed because of a lab failure.

Change-Id: Ib6517d30c82376e4f828d2ceb7e63de1cb7bcc95
2019-02-27 00:48:11 +00:00
Sandra Lokshina 4d41b7b90c Refactor the overflow menu to use components design.
Closes #1673.

Change-Id: I030745def928796a6abc813a91fb163cb2d76175
2019-02-21 13:14:28 -08:00
Sandra Lokshina 6b1ca2d229 Initial release of Shaka Player UI
Other contributors:
 - @joeyparrish
 - @michellezhuogg
 - @TheModMaker
 - @theodab
 - @vaage

Change-Id: If6df33d9ab5035d1ead4402004f7de37ee8470f4
2018-11-16 14:40:37 -08:00
Joey Parrish 7ac5e4692b Isolate custom asset test
Now, unit tests will not be served when running a custom asset test.
This makes the results saner, showing only the one custom asset test
instead of showing 1300+ skipped tests.

Custom asset test flags will also implicitly cause the relevant test
files to be served, rather than requiring --external as well.

Change-Id: I117c3fa90ab16bd059530ab716a17d2462906419
2018-09-16 19:44:41 -07:00
Joey Parrish 7091275cbf Replace indexOf with includes, startsWith
This replaces almost every instance of indexOf on both String and
Array.  There are very few places where we really wanted an index.
Mostly, indexOf was used to check for inclusion.

Change-Id: I08e299768b6ffdb4bfc30b39b5d82a058c6d1b56
2018-09-14 19:10:56 +00:00
Joey Parrish 7a3b352023 An external Promise polyfill is no longer required
At some point, a compiler upgrade introduced a built-in polyfill for
Promise.  A third-party polyfill for Promises on IE11 is no longer
required.

Change-Id: Ie5a649232d949b0bba0c6c68ea54ceed6fb30891
2018-09-13 22:12:04 +00:00
Joey Parrish 09af04b0c2 Don't count external asset tests as skipped
By splitting out external asset tests into a separate file, we can
instruct karma to load them only when they will be run.  This reduces
the number of "skipped" tests that show up in our test runs.

Ultimately, this can help us identify tests that are being skipped on
accident, so that we can fix our nightly test infrastructure.

Change-Id: Iac27ec07ff7e814824158b3e1821111a3f5a136d
2018-07-31 19:09:56 +00:00
Joey Parrish 13313b7449 Command-line to test custom assets
This will make it easier for encoder/packager vendors and other groups
to verify compatibility between Shaka Player and their custom streams.

Change-Id: I601fe4d071cef4d0bcf01b89352a61b9b9d767f0
2018-07-23 21:36:14 +00:00
Joey Parrish 5e36618cf3 Increase launcher shutdown timeout
Some of the Karma launchers in our test lab take a bit more than the
default 2s to shut down the browser.  Increase the timeout to 5s.

Bug: 88805319

Change-Id: I8515458b0c27204881732faca7b46440a64fd224
2018-06-13 22:34:13 +00:00
Joey Parrish b27ea82e7f Allow Player to attach/detach from video
This adds attach/detach methods to replace the media element in the
Player constructor.  Now applications can take back control of the
media element or provide a reference later in the Player's life cycle.

This also allows applications to decide whether or not to set up
MediaSource in advance, through an optional argument on attach and
unload.  The default will be to set up MediaSource in advance, which
maintains current behavior.  This advanced setup of MediaSource can
improve load latency later.

This change also introduces async/await for the first time in the
project, which required changes to eslint config, Closure build
arguments, Babel & Babel-polyfill setup, and the esprima parser used
by our extern generator.

The use of async/await will improve readability in many places, and
these infrastructure changes to enable async/await should also unblock
issues #1336 and #1337.

Closes #1087

Change-Id: I0d6b4e0e2af27a6520a3d070fa92b7139b2cb8b0
2018-03-06 22:19:53 +00:00
Joey Parrish f48f7fd9c4 Clean up uncaught Promise rejections
- Translate uncaught Promise rejections into test failures
   (Chrome only until the event is more widely implemented)

 - Clean up uncaught Promise rejection caused by exceptions thrown
   after destroy() in:
   - CastProxy
   - CastReceiver
   - NetworkingEngine
   - StreamingEngine

 - Clean up uncaught Promise rejection caused by test cases in:
   - CancelableChain unit tests
   - DrmEngine unit tests
   - StreamingEngine unit and integration tests
   - Player unit and integration tests

 - Speed up rejection in NetworkingEngine when we should not retry

 - Add --delay-tests to test.py, to aid in debugging uncaught
   Promise rejections and other types of async test pollution

Closes #1323

Change-Id: I5a8f5702a22430929babeb071bf6650c52c5ad17
2018-02-28 22:56:12 +00: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 374653abba [ES6] Use babel to preprocess tests
Once we start moving to ES6, uncompiled mode stops working on non-ES6
browsers (IE11 is the only one we test on).  We can disable uncompiled
mode in the demo, but we still want our tests to be uncompiled.  With
uncompiled library & tests, we can test units that are not exported
and even access private members that would otherwise be renamed.

For production/demo, Babel plays no role.  The Closure Compiler will
take in ES6 and spit out ES3 syntax (even older than ES5, so we can
at least run & fail a support check).

Babel will be used by Karma to preprocess all test and library code
before serving it from Karma.  This will allow us to use ES6 in both
the library and the tests, and still run uncompiled tests and test the
uncompiled library on ES5 browsers such as IE 11.

Issue #1157

Change-Id: Idd185d0e231d16b6df52babda777111e85890012
2018-01-05 20:10:42 +00:00
Michelle Zhuo e516a64487 Transmux from Transport Stream to MP4
Supporting Transport Stream by transmuxing it to MP4, with mux.js
library.

Issue #887

Change-Id: I70361bb364721fc5e72cba7d0fabc311ce0ba8b5
2017-10-20 18:14:02 +00:00
Joey Parrish fdfa27083d Update which module to simplify browser list
Now that npm/node-which#51 is closed and the fix has been released in
which v1.3.0, we can simplify away the try/catch when we check for
available browsers.

Change-Id: If849299f75e5e4927756a1692ebe017dd5d80f34
2017-08-01 10:52:43 -07:00
Joey Parrish 83b0652c95 Remove unnecessary framework plugins
We were constructing a framework plugin to load sprintf-js into the
tests.  It turns out that this was always completely unnecessary, and
that there is a much simpler solution.

Change-Id: I256178c6020d8fcde228c1e49360b6cf9adedf60
2017-07-31 20:52:00 +00:00
Joey Parrish 6b46d49d2a Add "build/test.py --browsers help" to list all
Now we can snoop in the karma config and find a list of all usable
browser launchers.  This allows us to provide hints for what browsers
could be used.

Change-Id: I7116eb72957c7f8b924380c26c4c66cdca50c0bc
2017-07-31 19:19:15 +00:00
Aaron Vaage 203f729c78 Disable Logging When Logging is Set to None
Even when logging was set to 'none' the console output was still
being capture. This change makes sure that the console output is
not captured when logging is set to 'none'.

Change-Id: Ieca237b9c99583072dc5a03183bb6cb42a9c7644
2017-07-26 10:56:23 -07:00
Aaron Vaage fe5706c74e Made build/test.py arguments consistent
Have you heard? The build/test.py arguments have been driving people
crazy, yes, CRAZY. To help cure the out-of-control insanity that is
sweeping the nation, I have taken our build/test.py and karam.conf.js
scripts and changed how they process command line arguments.

For build/test.py we are now using argparse (standard python library)
to parse the command line arguments. From there we build a JSON
object that is passed to Karma. This allows all command line parsing
to be done in Python and then our Karma conf only needs to read
the settings out of an object.

Fixes: 34107973
Change-Id: Iad631ca18778a031c7ce8bb613c52449069868e3
2017-07-26 17:16:54 +00:00
Aaron Vaage 6bc354a75a Revert "Made build/test.py arguments consistent"
This reverts commit c950647fdf.

Reason for revert: Reverting this for now as it breaks cross_browser.

Change-Id: I8a2b6bfa007e37674bc2c435fe2fa863ae77a824
2017-07-18 19:55:45 +00:00
Aaron Vaage c950647fdf Made build/test.py arguments consistent
Have you heard? The build/test.py arguments have been driving people
crazy, yes, CRAZY. To help cure the out-of-control insanity that is
sweeping the nation, I have taken our build/test.py and karam.conf.js
scripts and changed how they process command line arguments.

For build/test.py we are now using argparse (standard python library)
to parse the command line arguments. From there we build a JSON
object that is passed to Karma. This allows all command line parsing
to be done in Python and then our Karma conf only needs to read
the settings out of an object.

Bug: 34107973
Change-Id: I22f35a4f9bc89cda0d4a07ff030efa6e22467ba3
2017-07-18 17:55:01 +00:00
Joey Parrish 160dd1d7db [PWA] Move cast receiver code
This makes it easier to compile the demo and receiver apps, which will
make the PWA transition easier.

Issue #876

Change-Id: Iffd335df35c17c7895f763ccf180011dd1d8c14d
2017-06-22 22:51:37 +00:00
Chad Assareh 1e53ebf882 Remove unnecessary config already set by default.
Change-Id: Iba676eb436c021c8efc6cc4651ccbe84c2ca0a64
2017-03-30 19:21:27 +00:00
Joey Parrish 0c4f6258b3 Treat DRM license tests separately
These tests will no longer be lumped into the same group as "external"
asset tests.  This will allow us more control over test coverage in
different scenarios in our lab.

Change-Id: I0b0f2ae5ed6e74fdf87ad4ecf94ce41d94763537
2017-03-20 23:38:03 +00:00
Joey Parrish 303142ab98 Fix Player integration test failures on Chromecast
Our Chromecast setup requires an indirect connection between the
device and Karma.  This causes problems with Karma's proxies config.
To make this work, don't use proxies.  Player integration tests are
now passing on Chromecast.

Change-Id: I88a5831ab98d862e4ea5ec456de1a64338ddc4f5
2017-01-11 13:47:51 -08:00
Chad Assareh 0e82fa92f5 Move customLaunchers out of the Karma conf.
Change-Id: Ib6bc56ba931908a91e48a5be335388dba9c584bf
2016-12-21 23:25:25 +00:00
Chad Assareh 2b13ea7d26 Add a --specFilter command line option for filtering tests.
Change-Id: I2dc8243afcc7c4009c8c142a94ae31701248becd
2016-12-15 17:04:33 +00:00
Chad Assareh 72f026df1c Set --seed automaticaly if --random is set and the seed is not already specified.
Change-Id: I0392f42ef3cf470cb9aa1c5b06b57306bacc19a2
2016-12-15 17:02:51 +00:00