Commit 7c987e87 authored by Kuo Jen Wei's avatar Kuo Jen Wei Committed by Commit Bot

CCA: Turn on strict closure compiler check

Turn on strict closure compiler check and fix all related errors.

Bug: 1122444
Test: tast run <DUT> "camera.CCAUI*"
Change-Id: I8411d21a7a84b2e0172108ad71275a0c6c93b1d3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2383592
Commit-Queue: Shik Chen <shik@chromium.org>
Auto-Submit: Inker Kuo <inker@chromium.org>
Reviewed-by: default avatarShik Chen <shik@chromium.org>
Cr-Commit-Position: refs/heads/master@{#804005}
parent ac33aca1
...@@ -9,6 +9,7 @@ js_type_check("closure_compile") { ...@@ -9,6 +9,7 @@ js_type_check("closure_compile") {
default_closure_args + [ default_closure_args + [
"language_in=ECMASCRIPT_2018", "language_in=ECMASCRIPT_2018",
"jscomp_error=lintChecks", "jscomp_error=lintChecks",
"jscomp_error=strictCheckTypes",
"conformance_configs=" + "conformance_configs=" +
rebase_path("externs/conformance_config.textproto", root_build_dir), rebase_path("externs/conformance_config.textproto", root_build_dir),
"jscomp_error=conformanceViolations", "jscomp_error=conformanceViolations",
......
...@@ -328,7 +328,7 @@ export class VideoConstraintsPreferrer extends ConstraintsPreferrer { ...@@ -328,7 +328,7 @@ export class VideoConstraintsPreferrer extends ConstraintsPreferrer {
const /** !Object<(!Resolution|string), !Array<number>> */ fpsInfo = {}; const /** !Object<(!Resolution|string), !Array<number>> */ fpsInfo = {};
for (const [resolution, maxFps] of Object.entries(videoMaxFps)) { for (const [resolution, maxFps] of Object.entries(videoMaxFps)) {
fpsInfo[/** @type {string} */ (resolution)] = fpsInfo[/** @type {string} */ (resolution)] =
constFpses.filter((fps) => fps <= maxFps); constFpses.filter((fps) => fps <= /** @type {number} */ (maxFps));
} }
this.constFpsInfo_[deviceId] = fpsInfo; this.constFpsInfo_[deviceId] = fpsInfo;
}); });
......
...@@ -92,7 +92,7 @@ export function initMetrics() { ...@@ -92,7 +92,7 @@ export function initMetrics() {
i['GoogleAnalyticsObject'] = r; i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function(...args) { i[r] = i[r] || function(...args) {
(i[r].q = i[r].q || []).push(args); (i[r].q = i[r].q || []).push(args);
}, i[r].l = 1 * new Date(); }, i[r].l = new Date().getTime();
const a = s.createElement(o); const a = s.createElement(o);
const m = s.getElementsByTagName(o)[0]; const m = s.getElementsByTagName(o)[0];
a['async'] = 1; a['async'] = 1;
......
...@@ -46,6 +46,12 @@ export class ChromeFileEntry extends ChromeFileSystemEntry { ...@@ -46,6 +46,12 @@ export class ChromeFileEntry extends ChromeFileSystemEntry {
constructor(entry) { constructor(entry) {
super(entry); super(entry);
/**
* @type {!FileEntry}
* @private
*/
this.entry_;
/** /**
* @type {{ * @type {{
* file: function(): !Promise, * file: function(): !Promise,
...@@ -119,9 +125,10 @@ export class ChromeFileEntry extends ChromeFileSystemEntry { ...@@ -119,9 +125,10 @@ export class ChromeFileEntry extends ChromeFileSystemEntry {
/** /**
* @override * @override
* @return {!FileEntry}
*/ */
getRawEntry() { getRawEntry() {
return /** @type {!FileEntry} */ (this.entry_); return this.entry_;
} }
} }
...@@ -136,6 +143,12 @@ export class ChromeDirectoryEntry extends ChromeFileSystemEntry { ...@@ -136,6 +143,12 @@ export class ChromeDirectoryEntry extends ChromeFileSystemEntry {
constructor(entry) { constructor(entry) {
super(entry); super(entry);
/**
* @type {!DirectoryEntry}
* @private
*/
this.entry_;
/** /**
* @type {{ * @type {{
* getFile: function(string, !Object): !Promise, * getFile: function(string, !Object): !Promise,
...@@ -144,9 +157,8 @@ export class ChromeDirectoryEntry extends ChromeFileSystemEntry { ...@@ -144,9 +157,8 @@ export class ChromeDirectoryEntry extends ChromeFileSystemEntry {
* @private * @private
*/ */
this.entry_ops_ = { this.entry_ops_ = {
getFile: promisifyWithError(this.entry_.getFile.bind(this.entry_)), getFile: promisifyWithError(entry.getFile.bind(entry)),
getDirectory: getDirectory: promisifyWithError(entry.getDirectory.bind(entry)),
promisifyWithError(this.entry_.getDirectory.bind(this.entry_)),
}; };
} }
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
import {browserProxy} from './browser_proxy/browser_proxy.js'; import {browserProxy} from './browser_proxy/browser_proxy.js';
import {assertInstanceof} from './chrome_util.js';
import * as dom from './dom.js'; import * as dom from './dom.js';
import {DeviceOperator} from './mojo/device_operator.js'; import {DeviceOperator} from './mojo/device_operator.js';
import * as state from './state.js'; import * as state from './state.js';
...@@ -35,7 +36,8 @@ export function setup(views) { ...@@ -35,7 +36,8 @@ export function setup(views) {
// Manage all tabindex usages in for navigation. // Manage all tabindex usages in for navigation.
dom.getAll('[tabindex]', HTMLElement) dom.getAll('[tabindex]', HTMLElement)
.forEach((element) => util.makeUnfocusableByMouse(element)); .forEach((element) => util.makeUnfocusableByMouse(element));
document.body.addEventListener('keydown', (e) => { document.body.addEventListener('keydown', (event) => {
const e = assertInstanceof(event, KeyboardEvent);
if (e.key === 'Tab') { if (e.key === 'Tab') {
state.set(state.State.TAB_NAVIGATION, true); state.set(state.State.TAB_NAVIGATION, true);
} }
...@@ -170,7 +172,7 @@ export function close(name, condition) { ...@@ -170,7 +172,7 @@ export function close(name, condition) {
/** /**
* Handles key pressed event. * Handles key pressed event.
* @param {!Event} event Key press event. * @param {!KeyboardEvent} event Key press event.
*/ */
export function onKeyPressed(event) { export function onKeyPressed(event) {
const key = util.getShortcutIdentifier(event); const key = util.getShortcutIdentifier(event);
......
...@@ -7,14 +7,15 @@ import * as dom from './dom.js'; ...@@ -7,14 +7,15 @@ import * as dom from './dom.js';
/** /**
* Plays a sound. * Plays a sound.
* @param {string} selector Selector of the sound. * @param {string} selector Selector of the sound.
* @return {!Promise} Promise for waiting finishing playing or canceling wait. * @return {{promise: !Promise, cancel: function()}} Promise for waiting
* finishing playing and function for canceling wait.
*/ */
export function play(selector) { export function play(selector) {
// Use a timeout to wait for sound finishing playing instead of end-event // Use a timeout to wait for sound finishing playing instead of end-event
// as it might not be played at all (crbug.com/135780). // as it might not be played at all (crbug.com/135780).
// TODO(yuli): Don't play sounds if the speaker settings is muted. // TODO(yuli): Don't play sounds if the speaker settings is muted.
let cancel; let cancel;
const p = new Promise((resolve, reject) => { const promise = new Promise((resolve, reject) => {
const element = dom.get(selector, HTMLAudioElement); const element = dom.get(selector, HTMLAudioElement);
const timeout = const timeout =
setTimeout(resolve, Number(element.dataset['timeout'] || 0)); setTimeout(resolve, Number(element.dataset['timeout'] || 0));
...@@ -25,6 +26,5 @@ export function play(selector) { ...@@ -25,6 +26,5 @@ export function play(selector) {
element.currentTime = 0; element.currentTime = 0;
element.play(); element.play();
}); });
p.cancel = cancel; return {promise, cancel};
return p;
} }
...@@ -49,7 +49,7 @@ export function hide() { ...@@ -49,7 +49,7 @@ export function hide() {
/** /**
* Shows a tooltip over the hovered element. * Shows a tooltip over the hovered element.
* @param {!HTMLElement} element Hovered element whose tooltip to be shown. * @param {!HTMLInputElement} element Hovered element whose tooltip to be shown.
*/ */
function show(element) { function show(element) {
hide(); hide();
......
...@@ -237,7 +237,7 @@ export function animateOnce(element, callback) { ...@@ -237,7 +237,7 @@ export function animateOnce(element, callback) {
/** /**
* Returns a shortcut string, such as Ctrl-Alt-A. * Returns a shortcut string, such as Ctrl-Alt-A.
* @param {!Event} event Keyboard event. * @param {!KeyboardEvent} event Keyboard event.
* @return {string} Shortcut identifier. * @return {string} Shortcut identifier.
*/ */
export function getShortcutIdentifier(event) { export function getShortcutIdentifier(event) {
......
...@@ -28,7 +28,6 @@ async function cropSquare(blob) { ...@@ -28,7 +28,6 @@ async function cropSquare(blob) {
const croppedBlob = await new Promise((resolve) => { const croppedBlob = await new Promise((resolve) => {
canvas.toBlob(resolve, 'image/jpeg'); canvas.toBlob(resolve, 'image/jpeg');
}); });
croppedBlob.resolution = blob.resolution;
return croppedBlob; return croppedBlob;
} }
......
...@@ -135,7 +135,7 @@ export class Video extends ModeBase { ...@@ -135,7 +135,7 @@ export class Video extends ModeBase {
/** /**
* Promise for play start sound delay. * Promise for play start sound delay.
* @type {?Promise} * @type {?{promise: !Promise, cancel: function()}}
* @private * @private
*/ */
this.startSound_ = null; this.startSound_ = null;
...@@ -249,7 +249,7 @@ export class Video extends ModeBase { ...@@ -249,7 +249,7 @@ export class Video extends ModeBase {
this.startSound_ = sound.play('#sound-rec-start'); this.startSound_ = sound.play('#sound-rec-start');
this.everPaused_ = false; this.everPaused_ = false;
try { try {
await this.startSound_; await this.startSound_.promise;
} finally { } finally {
this.startSound_ = null; this.startSound_ = null;
} }
...@@ -302,7 +302,7 @@ export class Video extends ModeBase { ...@@ -302,7 +302,7 @@ export class Video extends ModeBase {
* @override * @override
*/ */
stop_() { stop_() {
if (this.startSound_ && this.startSound_.cancel) { if (this.startSound_ !== null) {
this.startSound_.cancel(); this.startSound_.cancel();
} }
if (this.mediaRecorder_ && if (this.mediaRecorder_ &&
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment