Skip to content

Commit ec4bc1d

Browse files
authored
test: Fix Chromecast testing in lab (#6643)
These changes are necessary for compatibility with Chromecast WebDriver Server v2. - Fix a bug in Karma's flat environment support (joeyparrish/karma@9875e98) - Add a test boot file to load CAF on Chromecast devices; required by Chromecast WebDriver Server v2's redirect mode (flat environment at that level) - Also load this cast-boot file in support.html - Rename/reorganize Cast-related externs, which were messy even before the addition of CAF - Remove proxy-cast-platform.js; no longer needed as we move to flatten the test environment - Ignore error events with "null" error; these appear on Linux Chromecasts, only since including CAF - Ignore error events that are actually strings; these appear on Linux Chromecasts, only since including CAF - Disable Fuchsia in the lab until autoplay issues can be resolved
1 parent 0a68e93 commit ec4bc1d

15 files changed

+134
-164
lines changed

build/build.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import logging
4646
import os
4747
import re
48+
import shutil
4849

4950
import compiler
5051
import generateLocalizations
@@ -302,11 +303,12 @@ def build_library(self, name, langout, locales, force, is_debug):
302303
if not closure.compile(closure_opts, force):
303304
return False
304305

306+
source_base = shakaBuildHelpers.get_source_base()
307+
305308
# Don't pass local node modules to the extern generator. But don't simply
306309
# exclude the string 'node_modules', either, since Shaka Player could be
307310
# rebuilt after installing it as a node module.
308-
node_modules_path = os.path.join(
309-
shakaBuildHelpers.get_source_base(), 'node_modules')
311+
node_modules_path = os.path.join(source_base, 'node_modules')
310312
local_include = set([f for f in self.include if node_modules_path not in f])
311313
extern_generator = compiler.ExternGenerator(local_include, build_name)
312314

@@ -323,6 +325,11 @@ def build_library(self, name, langout, locales, force, is_debug):
323325
if not ts_def_generator.generate(force):
324326
return False
325327

328+
# Copy this file to dist/ where support.html can use it
329+
shutil.copy(
330+
os.path.join(source_base, 'test', 'test', 'cast-boot.js'),
331+
os.path.join(source_base, 'dist', 'cast-boot.js'))
332+
326333
return True
327334

328335

build/check.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,6 @@ def check_tests(args):
283283
[closure_base_js]))
284284
files.add(os.path.join(base, 'demo', 'common', 'asset.js'))
285285
files.add(os.path.join(base, 'demo', 'common', 'assets.js'))
286-
files.add(os.path.join(base, 'proxy-cast-platform.js'))
287286

288287
localizations = compiler.GenerateLocalizations(None)
289288
localizations.generate(args.force)

build/conformance.textproto

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ requirement {
7373
whitelist_regexp: "demo/"
7474
whitelist_regexp: "test/"
7575
whitelist_regexp: "node_modules/"
76-
whitelist_regexp: "proxy-cast-platform.js"
7776
7877
# This global variable is generated by Google-internal tooling, and should be
7978
# allowed. It will not end up in the compiled code, only at an intermediate
@@ -287,7 +286,6 @@ requirement: {
287286
"shaka.util.Timer instead."
288287
whitelist_regexp: "demo/"
289288
whitelist_regexp: "test/"
290-
whitelist_regexp: "proxy-cast-platform.js"
291289
}
292290

293291
# Disallow eval, except when testing for modern JS syntax in demo

build/shaka-lab.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ ChromecastGTV:
241241
ChromecastHub:
242242
browser: chromecast
243243
version: hub
244+
# Disabled by default until we resolve issues with autoplay on Fuchsia.
245+
disabled: true
244246

245247
ChromecastSpeaker:
246248
# This is a headless device, and our tests are not yet known to work here.

externs/cast-namespace.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*! @license
2+
* Shaka Player
3+
* Copyright 2024 Google LLC
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/**
8+
* @fileoverview Google Cast namespace definitions, shared by other externs
9+
* files.
10+
* @externs
11+
*/
12+
13+
/** @const */
14+
var cast = {};
Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@
1515
var __onGCastApiAvailable;
1616

1717

18-
/** @const */
19-
var cast = {};
20-
21-
2218
/** @const */
2319
cast.receiver = {};
2420

externs/cast-sdk-v3.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*! @license
2+
* Shaka Player
3+
* Copyright 2024 Google LLC
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/**
8+
* @fileoverview Externs for the limited subset of the Cast Application
9+
* Framework (Receiver SDK v3) that we use in our test infrastructure.
10+
*
11+
* @externs
12+
*/
13+
14+
/** @const */
15+
cast.framework = {};
16+
17+
/**
18+
* @typedef {{
19+
* statusText: string,
20+
* disableIdleTimeout: boolean,
21+
* skipPlayersLoad: boolean
22+
* }}
23+
*/
24+
cast.framework.CastReceiverOptions;
25+
26+
cast.framework.CastReceiverContext = class {
27+
/** @return {!cast.framework.CastReceiverContext} */
28+
static getInstance() {}
29+
30+
/**
31+
* @param {!cast.framework.CastReceiverOptions} options
32+
* @return {!cast.framework.CastReceiverContext}
33+
*/
34+
start(options) {}
35+
};

externs/mediatailor.js

100755100644
File mode changed.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
*/
66

77
/**
8-
* @fileoverview Externs for HTMLMediaElement related to casting which were
9-
* missing in the Closure compiler.
8+
* @fileoverview Externs for HTMLMediaElement related to remote playback which
9+
* were missing in the Closure compiler.
1010
*
1111
* @externs
1212
*/

karma.conf.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,13 @@ module.exports = (config) => {
197197

198198
// list of files / patterns to load in the browser
199199
files: [
200-
// Polyfills first, primarily for IE 11 and older TVs:
200+
// The Cast boot file must come first, to start the SDK and respond as
201+
// quickly as possible to the Cast platform. Without this up front, we
202+
// tend to see the Chromecast time out and shut down the receiver that
203+
// hosts our tests.
204+
'test/test/cast-boot.js',
205+
206+
// Polyfills before anything else, primarily for older TVs:
201207
// Promise polyfill, required since we test uncompiled code on IE11
202208
'node_modules/es6-promise-polyfill/promise.js',
203209
// Babel polyfill, required for async/await
@@ -230,9 +236,6 @@ module.exports = (config) => {
230236
// test utilities next, which fill in that namespace
231237
'test/test/util/*.js',
232238

233-
// Proxy cast.__platform__ methods across frames, necessary in testing
234-
'proxy-cast-platform.js',
235-
236239
// bootstrapping for the test suite last; this will load the actual tests
237240
'test/test/boot.js',
238241

@@ -389,7 +392,6 @@ module.exports = (config) => {
389392
'ui/**/*.js': ['babel', 'sourcemap'],
390393
'test/**/*.js': ['babel', 'sourcemap'],
391394
'third_party/**/*.js': ['babel', 'sourcemap'],
392-
'proxy-cast-platform.js': ['babel', 'sourcemap'],
393395
},
394396

395397
babelPreprocessor: {

0 commit comments

Comments
 (0)