Skip to content

Commit

Permalink
test: Fix Chromecast testing in lab (shaka-project#6643)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
joeyparrish committed May 20, 2024
1 parent 0a68e93 commit ec4bc1d
Show file tree
Hide file tree
Showing 15 changed files with 134 additions and 164 deletions.
11 changes: 9 additions & 2 deletions build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import logging
import os
import re
import shutil

import compiler
import generateLocalizations
Expand Down Expand Up @@ -302,11 +303,12 @@ def build_library(self, name, langout, locales, force, is_debug):
if not closure.compile(closure_opts, force):
return False

source_base = shakaBuildHelpers.get_source_base()

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

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

# Copy this file to dist/ where support.html can use it
shutil.copy(
os.path.join(source_base, 'test', 'test', 'cast-boot.js'),
os.path.join(source_base, 'dist', 'cast-boot.js'))

return True


Expand Down
1 change: 0 additions & 1 deletion build/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,6 @@ def check_tests(args):
[closure_base_js]))
files.add(os.path.join(base, 'demo', 'common', 'asset.js'))
files.add(os.path.join(base, 'demo', 'common', 'assets.js'))
files.add(os.path.join(base, 'proxy-cast-platform.js'))

localizations = compiler.GenerateLocalizations(None)
localizations.generate(args.force)
Expand Down
2 changes: 0 additions & 2 deletions build/conformance.textproto
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ requirement {
whitelist_regexp: "demo/"
whitelist_regexp: "test/"
whitelist_regexp: "node_modules/"
whitelist_regexp: "proxy-cast-platform.js"
# This global variable is generated by Google-internal tooling, and should be
# allowed. It will not end up in the compiled code, only at an intermediate
Expand Down Expand Up @@ -287,7 +286,6 @@ requirement: {
"shaka.util.Timer instead."
whitelist_regexp: "demo/"
whitelist_regexp: "test/"
whitelist_regexp: "proxy-cast-platform.js"
}

# Disallow eval, except when testing for modern JS syntax in demo
Expand Down
2 changes: 2 additions & 0 deletions build/shaka-lab.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ ChromecastGTV:
ChromecastHub:
browser: chromecast
version: hub
# Disabled by default until we resolve issues with autoplay on Fuchsia.
disabled: true

ChromecastSpeaker:
# This is a headless device, and our tests are not yet known to work here.
Expand Down
14 changes: 14 additions & 0 deletions externs/cast-namespace.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*! @license
* Shaka Player
* Copyright 2024 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/

/**
* @fileoverview Google Cast namespace definitions, shared by other externs
* files.
* @externs
*/

/** @const */
var cast = {};
4 changes: 0 additions & 4 deletions externs/chromecast.js → externs/cast-sdk-v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
var __onGCastApiAvailable;


/** @const */
var cast = {};


/** @const */
cast.receiver = {};

Expand Down
35 changes: 35 additions & 0 deletions externs/cast-sdk-v3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*! @license
* Shaka Player
* Copyright 2024 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/

/**
* @fileoverview Externs for the limited subset of the Cast Application
* Framework (Receiver SDK v3) that we use in our test infrastructure.
*
* @externs
*/

/** @const */
cast.framework = {};

/**
* @typedef {{
* statusText: string,
* disableIdleTimeout: boolean,
* skipPlayersLoad: boolean
* }}
*/
cast.framework.CastReceiverOptions;

cast.framework.CastReceiverContext = class {
/** @return {!cast.framework.CastReceiverContext} */
static getInstance() {}

/**
* @param {!cast.framework.CastReceiverOptions} options
* @return {!cast.framework.CastReceiverContext}
*/
start(options) {}
};
Empty file modified externs/mediatailor.js
100755 → 100644
Empty file.
4 changes: 2 additions & 2 deletions externs/cast.js → externs/remote-playback.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
*/

/**
* @fileoverview Externs for HTMLMediaElement related to casting which were
* missing in the Closure compiler.
* @fileoverview Externs for HTMLMediaElement related to remote playback which
* were missing in the Closure compiler.
*
* @externs
*/
Expand Down
12 changes: 7 additions & 5 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,13 @@ module.exports = (config) => {

// list of files / patterns to load in the browser
files: [
// Polyfills first, primarily for IE 11 and older TVs:
// The Cast boot file must come first, to start the SDK and respond as
// quickly as possible to the Cast platform. Without this up front, we
// tend to see the Chromecast time out and shut down the receiver that
// hosts our tests.
'test/test/cast-boot.js',

// Polyfills before anything else, primarily for older TVs:
// Promise polyfill, required since we test uncompiled code on IE11
'node_modules/es6-promise-polyfill/promise.js',
// Babel polyfill, required for async/await
Expand Down Expand Up @@ -230,9 +236,6 @@ module.exports = (config) => {
// test utilities next, which fill in that namespace
'test/test/util/*.js',

// Proxy cast.__platform__ methods across frames, necessary in testing
'proxy-cast-platform.js',

// bootstrapping for the test suite last; this will load the actual tests
'test/test/boot.js',

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

babelPreprocessor: {
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

138 changes: 0 additions & 138 deletions proxy-cast-platform.js

This file was deleted.

4 changes: 2 additions & 2 deletions support.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@
}

</style>
<script src="dist/cast-boot.js"></script>
<script src="dist/shaka-player.compiled.js"></script>
<script src="proxy-cast-platform.js"></script>
<script>

function whenLoaded(fn) {
// IE 9 fires DOMContentLoaded, and enters the "interactive"
// readyState, before document.body has been initialized, so wait
Expand Down Expand Up @@ -74,7 +75,6 @@
}

function doTest() {
proxyCastCanDisplayType();
shaka.polyfill.installAll();

if (shaka.Player.isBrowserSupported()) {
Expand Down
Loading

0 comments on commit ec4bc1d

Please sign in to comment.