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") {
default_closure_args + [
"language_in=ECMASCRIPT_2018",
"jscomp_error=lintChecks",
"jscomp_error=strictCheckTypes",
"conformance_configs=" +
rebase_path("externs/conformance_config.textproto", root_build_dir),
"jscomp_error=conformanceViolations",
......
......@@ -328,7 +328,7 @@ export class VideoConstraintsPreferrer extends ConstraintsPreferrer {
const /** !Object<(!Resolution|string), !Array<number>> */ fpsInfo = {};
for (const [resolution, maxFps] of Object.entries(videoMaxFps)) {
fpsInfo[/** @type {string} */ (resolution)] =
constFpses.filter((fps) => fps <= maxFps);
constFpses.filter((fps) => fps <= /** @type {number} */ (maxFps));
}
this.constFpsInfo_[deviceId] = fpsInfo;
});
......
......@@ -92,7 +92,7 @@ export function initMetrics() {
i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function(...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 m = s.getElementsByTagName(o)[0];
a['async'] = 1;
......
......@@ -46,6 +46,12 @@ export class ChromeFileEntry extends ChromeFileSystemEntry {
constructor(entry) {
super(entry);
/**
* @type {!FileEntry}
* @private
*/
this.entry_;
/**
* @type {{
* file: function(): !Promise,
......@@ -119,9 +125,10 @@ export class ChromeFileEntry extends ChromeFileSystemEntry {
/**
* @override
* @return {!FileEntry}
*/
getRawEntry() {
return /** @type {!FileEntry} */ (this.entry_);
return this.entry_;
}
}
......@@ -136,6 +143,12 @@ export class ChromeDirectoryEntry extends ChromeFileSystemEntry {
constructor(entry) {
super(entry);
/**
* @type {!DirectoryEntry}
* @private
*/
this.entry_;
/**
* @type {{
* getFile: function(string, !Object): !Promise,
......@@ -144,9 +157,8 @@ export class ChromeDirectoryEntry extends ChromeFileSystemEntry {
* @private
*/
this.entry_ops_ = {
getFile: promisifyWithError(this.entry_.getFile.bind(this.entry_)),
getDirectory:
promisifyWithError(this.entry_.getDirectory.bind(this.entry_)),
getFile: promisifyWithError(entry.getFile.bind(entry)),
getDirectory: promisifyWithError(entry.getDirectory.bind(entry)),
};
}
......
......@@ -3,6 +3,7 @@
// found in the LICENSE file.
import {browserProxy} from './browser_proxy/browser_proxy.js';
import {assertInstanceof} from './chrome_util.js';
import * as dom from './dom.js';
import {DeviceOperator} from './mojo/device_operator.js';
import * as state from './state.js';
......@@ -35,7 +36,8 @@ export function setup(views) {
// Manage all tabindex usages in for navigation.
dom.getAll('[tabindex]', HTMLElement)
.forEach((element) => util.makeUnfocusableByMouse(element));
document.body.addEventListener('keydown', (e) => {
document.body.addEventListener('keydown', (event) => {
const e = assertInstanceof(event, KeyboardEvent);
if (e.key === 'Tab') {
state.set(state.State.TAB_NAVIGATION, true);
}
......@@ -170,7 +172,7 @@ export function close(name, condition) {
/**
* Handles key pressed event.
* @param {!Event} event Key press event.
* @param {!KeyboardEvent} event Key press event.
*/
export function onKeyPressed(event) {
const key = util.getShortcutIdentifier(event);
......
......@@ -7,14 +7,15 @@ import * as dom from './dom.js';
/**
* Plays a 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) {
// Use a timeout to wait for sound finishing playing instead of end-event
// as it might not be played at all (crbug.com/135780).
// TODO(yuli): Don't play sounds if the speaker settings is muted.
let cancel;
const p = new Promise((resolve, reject) => {
const promise = new Promise((resolve, reject) => {
const element = dom.get(selector, HTMLAudioElement);
const timeout =
setTimeout(resolve, Number(element.dataset['timeout'] || 0));
......@@ -25,6 +26,5 @@ export function play(selector) {
element.currentTime = 0;
element.play();
});
p.cancel = cancel;
return p;
return {promise, cancel};
}
......@@ -49,7 +49,7 @@ export function hide() {
/**
* 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) {
hide();
......
......@@ -237,7 +237,7 @@ export function animateOnce(element, callback) {
/**
* Returns a shortcut string, such as Ctrl-Alt-A.
* @param {!Event} event Keyboard event.
* @param {!KeyboardEvent} event Keyboard event.
* @return {string} Shortcut identifier.
*/
export function getShortcutIdentifier(event) {
......
......@@ -28,7 +28,6 @@ async function cropSquare(blob) {
const croppedBlob = await new Promise((resolve) => {
canvas.toBlob(resolve, 'image/jpeg');
});
croppedBlob.resolution = blob.resolution;
return croppedBlob;
}
......
......@@ -135,7 +135,7 @@ export class Video extends ModeBase {
/**
* Promise for play start sound delay.
* @type {?Promise}
* @type {?{promise: !Promise, cancel: function()}}
* @private
*/
this.startSound_ = null;
......@@ -249,7 +249,7 @@ export class Video extends ModeBase {
this.startSound_ = sound.play('#sound-rec-start');
this.everPaused_ = false;
try {
await this.startSound_;
await this.startSound_.promise;
} finally {
this.startSound_ = null;
}
......@@ -302,7 +302,7 @@ export class Video extends ModeBase {
* @override
*/
stop_() {
if (this.startSound_ && this.startSound_.cancel) {
if (this.startSound_ !== null) {
this.startSound_.cancel();
}
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