Skip to content

Commit

Permalink
Fix test failures on IE 11 and Tizen
Browse files Browse the repository at this point in the history
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
  • Loading branch information
joeyparrish committed May 3, 2019
1 parent 6a1cbc5 commit 9d18615
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 37 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ module.exports = {
},
"files": [
// Closure requires using var in externs.
"ui/externs/*.js",
"externs/**/*.js",
"test/test/externs/*.js",
// Use var in load.js so it works in old browsers. We'll use
Expand Down
59 changes: 29 additions & 30 deletions demo/common/asset.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,40 +344,39 @@ const ShakaDemoAssetInfo = class {
isStored() {
return this.storedContent != null;
}
};


/** @return {!ShakaDemoAssetInfo} */
ShakaDemoAssetInfo.makeBlankAsset = function() {
return new ShakaDemoAssetInfo(
/* name= */ '',
/* iconUri= */ '',
/* manifestUri= */ '',
/* source= */ shakaAssets.Source.CUSTOM);
};
/** @return {!ShakaDemoAssetInfo} */
static makeBlankAsset() {
return new ShakaDemoAssetInfo(
/* name= */ '',
/* iconUri= */ '',
/* manifestUri= */ '',
/* source= */ shakaAssets.Source.CUSTOM);
}

/**
* @param {!Object} raw
* @return {!ShakaDemoAssetInfo}
*/
ShakaDemoAssetInfo.fromJSON = function(raw) {
// This handles the special case for Maps in toJSON.
const parsed = {};
for (let key in raw) {
const value = raw[key];
if (value && typeof value == 'object' && value['__type__'] == 'map') {
const replacement = new Map();
for (let key in value) {
if (key != '__type__') {
replacement.set(key, value[key]);
/**
* @param {!Object} raw
* @return {!ShakaDemoAssetInfo}
*/
static fromJSON(raw) {
// This handles the special case for Maps in toJSON.
const parsed = {};
for (let key in raw) {
const value = raw[key];
if (value && typeof value == 'object' && value['__type__'] == 'map') {
const replacement = new Map();
for (let key in value) {
if (key != '__type__') {
replacement.set(key, value[key]);
}
}
parsed[key] = replacement;
} else {
parsed[key] = value;
}
parsed[key] = replacement;
} else {
parsed[key] = value;
}
const asset = ShakaDemoAssetInfo.makeBlankAsset();
Object.assign(asset, parsed);
return asset;
}
const asset = ShakaDemoAssetInfo.makeBlankAsset();
Object.assign(asset, parsed);
return asset;
};
6 changes: 1 addition & 5 deletions demo/common/assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,9 @@ goog.require('ShakaDemoAssetInfo');
// Types and enums {{{
/**
* A container for demo assets.
*
* Note: due to an issue with testing on Tizen 2017, we must use "var" at this
* scope instead of "let".
*
* @class
*/
var shakaAssets = {}; // eslint-disable-line no-var
const shakaAssets = {};


/** @enum {string} */
Expand Down
3 changes: 2 additions & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ module.exports = function(config) {
// Compute coverage over UI, too
'ui/*.js': ['coverage'],

// Convert ES6 to ES5 so we can still run tests on IE11.
// Convert ES6 to ES5 so we can still run tests on IE11 and Tizen.
'demo/common/*.js': ['babel'],
'lib/**/*.js': ['babel'],
'ui/**/*.js': ['babel'],
'test/**/*.js': ['babel'],
Expand Down
2 changes: 1 addition & 1 deletion ui/externs/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/

/** @namespace */
var shaka = {}; // eslint-disable-line no-var
var shaka = {};

/** @namespace */
shaka.extern = {};
Expand Down

0 comments on commit 9d18615

Please sign in to comment.