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
In many places, we check error codes on shaka.util.Error. But the
compiler doesn't know that what is caught in "catch" is that type, so
we add type assertions.
In some cases, we know that other types may also be thrown, so there
are also some runtime checks. Some of these had to be refactored to
allow the compiler to correctly infer types.
Change-Id: I053bd7e96213c689aae3889315052dd402124690
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
According to RFC 3986, URL schemes should be case-insensitive. Our
scheme plugin map is registered with exclusively-lowercase scheme
names, so we should convert the input scheme to lowercase before
looking up the plugin.
Closes#2173
Change-Id: I78218c18d3df154aabd101a9ef5fd3156d0c57a8
This ensures that we get the expected types and that type coercion
doesn't convert between types. This also ensures we are consistent
in how we check for equality of primitives in tests.
Change-Id: I9f3aacdf25ab1afe5e8d6e4b895b5299ee687d54
- Reduce times for "short delays".
- Remove backoff delay from networking tests.
- Avoid hard-coding delays in the library.
- Move Storage tests to integration tests since they use indexedDB (and
take over 200ms each to run).
This reduces the time it takes to run unit tests (with --quick) from
50 seconds to about 6 seconds. Now all but one unit test finish <100ms.
Change-Id: I88461472a87c4cf750a36d07d07422818e069a4d
Code in karma-jasmine's adapter will malform test failures when the
expectation message contains a stack trace, losing the failure message
and mixing up the stack trace of the failure. To avoid this, we
modify shaka.util.Error not to create a stack trace. This trace is
not available in production, and there is never any need for it in the
tests.
One test expectation had to be updated. The previous version of
jasmineError would use the original error by reference. Now that it's
capturing a few fields explicitly, the severity value doesn't update
when NetworkingEngine modifies the original.
Change-Id: If7af93a1a0357df9763dbf6a4afc45db2c8317df
This makes progress callbacks into a required parameter on all network
scheme plugins. This does not mean that every plugin must make use of
the callback, but every caller must supply the callback.
In production, NetworkingEngine already supplies this callback
universally, so our HTTP plugins make use of it whenever progress data
is available.
Our tests, however, did not always supply this callback, leading to
test failures. These failures were more likely to show up in Jasmine
3 than Jasmine 2 for some reason, which caused us to downgrade back to
Jasmine 2 recently.
By making the callback required, we can clean up this inconsistency
between test and production and give the HTTP plugins what they expect
in all cases.
Issue #1949
Change-Id: I8a6e1904e73cf7ca6ae8f3964261c339f404854d
This adds more to the logs for the error in HTTP plugin tests. This
test has been failing randomly recently and this will help us see why.
Change-Id: I6e4bfafd559d52527f7af3f21d6c9f836568c932
This is a fully automated change. The linter will fail because the
extra indentation caused line-length errors. These won't be fixed
automatically. They are fixed in a follow-up to make this one fully
automated.
Change-Id: I4d8cf9c998985add2bcd24a81c8d65495668c4f3
With the new style rule, we cannot have two statements on the same line.
So we can no longer have an "if" on a single line and we cannot have
an arrow function with a body on the same line as when it is used.
This is mostly a manual change.
Change-Id: I2285202dd5ecbad764308bc725e6d317ff2ee7f0
This is an automated change to convert use of "function" functions
to arrow functions. This doesn't change all uses of bind() that
could be converted. This also doesn't remove all "function" functions.
Change-Id: I40ac7d086bcef947a1be083359c8fd1d4499a9c3
A coming update to the Google eslint config will require using "const"
over "let". This makes that one change to isolate the big changes.
Change-Id: I7d0974c3ae15c53cc45a6b07bf9f6586e2d34aca
Range headers should not be sent when requesting the entire resource.
This fixes compatibility with Microsoft IIS web server.
Introduced in work on issue #1788
Change-Id: I151a2f15d4f5e95531e16d5372ee9a051135f12f
This CL limits the use of |setTimeout| by wrapping it in our own timer
class. The timer class makes it easier to track and cancel time-based
events.
To ensure that|setTimeout| is not used outside of our timer classes, the
conformance rules have been updated to only allow |setTimeout| to be
used by our timer classes.
Since |setTimeout| is very similar to |setInterval|, the conformance
rules for |setInternal| rules were updates to reflect more of the logic
behind why we don't want to use |setTimeout| and |setInterval| directly.
Change-Id: Iff5da32a61b515dd2016837fa74a34c04b6c5fd2
In a recent CL, the Http Fetch plugin was modified to make use of
ReadableStream. However, ReadableStream isn't available on every
platform. This change modifies the Fetch plugin to not be used if
ReadableStream isn't defined.
This also adds a basic mock ReadableStream for tests.
Change-Id: I7554298779040ce0cef1b8ad55c3ee113f932954
This is part 1 of conditionally aborting requests when network
downgrading.
1. Add progress event handler for Http XHR Plugin, to get more frequent
updates for network bandwidth estimate and suggest streams based on
that.
2. When the plugin doesn't support progress event, call
onProgressUpdated function after every segment is downloaded.
3. Replace onSegmentDownloaded with onProgressUpdated function in
player.js and network_engine.js.
4. Since XHR Plugin supports progress event while Fetch doesn't, change
the config to prefer XHR over Fetch API.
Issue #1051.
Change-Id: Icf6775dd3520fb2e359b13d29e3b39d3792fe865
This makes NetworkingEngine a FakeEventTarget, and gives it a 'retry'
event which is fired when there is a recoverable error that results in
a retry.
Closes#1529
Change-Id: I0c15ed20f4d6abf971d280263c6d62841daf440e
In "test/net/http_plugin_unit.js" we had a constructor that did not conform to proper standards causing some ESLint issues with some configurations (but not the project's current config).
Since the project style guide says that constructors/classes should start with a capital letter, this will be accepted regardless of the config not failing.
Closes#1506
Catch BAD_HTTP_STATUS error thrown by makeResponse in xhr.onload
Also wrap mock XHR event handlers in try-catch blocks in
http_plugin_unit to avoid regression.
Resolves#1302
This is an automated fix to be inline with Google style guides, this
was created with eslint's --fix option.
Change-Id: I860eecbc8152603e730aa17a1393f16d26b3b6fc
Google style guide requires adding curly braces to all block statements
even if it is only has one line. This fixes it by using eslint's
--fix flag followed by running clang-format to reformat the change.
Change-Id: Idc086c2aa8c02df5ef8b2140a11bfb9128eeb4bd
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: I475eba0a477d13cd9201c88ad44899d521ad8991
Fetch requests with a method of GET or HEADER cannot have a body, or
else the request will fail. Normally we had no problems with this, but
it turns out that Edge counts a body of 'null' as being defined.
This changes the Fetch scheme plugin so that it will replace null with
undefined for the body in the init data.
This also makes it so that HTTP_ERROR errors emitted by the http
plugin will include the original error, to aid in debugging future
issues.
Change-Id: I0531656dada25f97ef610d4285c225d57d7ef262
This plugin is preferred over the XHR plugin, if available.
This plugin requires AbortController, which is only present on
Firefox 57 and Edge 16, so this will not be active on every platform.
This also adds a simple mock for the Fetch API for use with Jasmine.
Closes#829
Change-Id: Ifb79d29334fbfcfd175afe0706da5a3d5e452e2f
When changing networking engine to use AbortableOperation, we had an
accidental regression. Now, when it runs out of retries, it rejects
with an error of "undefined" instead of with the actual error that was
causing it to retry.
This changes networking engine to save the last error and return with
that. It also modifies the unit tests to catch this problem.
Closes#1278
Change-Id: I8af9a81d7a8ad58d195a8e9f1af622ddbc3592f2
This uses AbortableOperation in all networking, from the scheme
plugins all the way to the request interface.
This also updates all default scheme plugins, docs, and sample code.
Backward compatibility is provided for scheme plugins and the
request API in NetworkingEngine. This compatibility will be
removed in v2.5.
Two cancelation-related tests have been disabled in
player_integration until the new abort interface has been adopted
in the manifest parsers.
Issue #829
Change-Id: I91c8e6efe97798d111e8ddca5655cddc1f6bcbf3
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
Since IE/Edge returns the header with a leading new line('\n'), we need
to remove it from the response.
Closes#1172.
Change-Id: I133f9cfbada6486edc438f3dcbc37c7c78dbf36c
This adds the ability to supply an isCanceled() callback when making a
backoff object. If the callback is provided, the backoff will break the
timeout into a series of 200 MS timeouts, and check isCanceled() between
every segment.
This changes makes it so that, when canceling a load, you can quickly end
the current backoff. This will making canceling a load significantly faster,
especially if the player is on a late retry.
This still does not quite fix issue #1084 to my satisfaction; if the
manifest is currently downloading, the cancel will need to wait on that.
Canceling an in-progress manifest download will be yet another followup CL.
Issue #1084
Change-Id: I0a53310a9b521de375f2e128f63eaa133547c340
If the parser is failing to load a manifest, perhaps due to being offline,
and the player is destroyed mid-load, it will wait for all of the retries to
run out before canceling. This causes a significant wait time on destroy.
This change adds an optional isCanceled callback to the request method in
NetworkingEngine, allowing requests to be made that can be canceled via a
provided callback. This is then used to quickly skip past all of the
retries, when destroying the parser.
This doesn't stop any backoff in progress, so there still might be a delay of
a second or two (depending on networking settings, of course) if you destroy
during a backoff period. That will be changed in a followup CL.
Issue #1084
Change-Id: I0b99616ed4d5be078161122532ea271e84613170
This modified the networking engine to store every plugin it is given
for a scheme, and adds a priority system to pick which of the plugins
to use.
Issue #829
Change-Id: I21a8a534383f2be898160d609d77efecfc2b684b
This extracts the delay, backoff, and fuzzing code from
NetworkingEngine in a way that can be used by other classes that need
this same backoff/retry behavior.
Issue #976
Change-Id: I2a370fc996e6f8f507768559c44cf7855e16abe1
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: I48335fc6659d3c33a6d55b00d087b59410c79cf7
The old definition using a union with a Function causes problems. The
compiler tends to treat this as an unknown type, so we loose type
safety. The new types ensure full type safety, at the cost of needing
to "convert" the spy when it is used as a function.
Change-Id: I98ebd9dffd9cb865d0cf5d03db0fb5d6ea001ed3
The callback parameter should have a different name from the input
parameter for the comparison between requests to make sense.
Change-Id: I7157bc083d7b4a94fe59db0e5d3547db718af9f6