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
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
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
PR #2330 introduced a new message without a definition for it. This
test would have caught the mistake in advance.
Change-Id: I1a7b0fa2483b791b6b16405e55af84a49d100c83
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
- 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
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
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
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
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
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
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
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
This reverts commit c950647fdf.
Reason for revert: Reverting this for now as it breaks cross_browser.
Change-Id: I8a2b6bfa007e37674bc2c435fe2fa863ae77a824
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
This makes it easier to compile the demo and receiver apps, which will
make the PWA transition easier.
Issue #876
Change-Id: Iffd335df35c17c7895f763ccf180011dd1d8c14d
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
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