Commit cd348b23 authored by dpapad's avatar dpapad Committed by Commit Bot

Enable type checking for chrome/test/base/js2gtest.js.

Bug: 1000989
Change-Id: I4101732133391b0b1aece1763201f2fa837100b8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2117300
Commit-Queue: dpapad <dpapad@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
Cr-Commit-Position: refs/heads/master@{#753809}
parent b73eb2c5
......@@ -6831,8 +6831,8 @@ group("closure_compile") {
testonly = true
deps = [
"base:closure_compile",
"data:closure_compile",
# TODO(crbug/1000989): Add a dep for base/js2gtest.js.
]
}
......
# Copyright 2020 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//third_party/closure_compiler/compile_js.gni")
js_type_check("closure_compile") {
deps = [ ":js2gtest" ]
}
js_library("js2gtest") {
deps = [ "//chrome/test/data:test_api_js" ]
externs_list = [ "d8_externs.js" ]
}
......@@ -7,6 +7,7 @@ per-file testing_profile*=*
per-file javascript_browser_test.*=dtseng@chromium.org
per-file js2gtest.*=dtseng@chromium.org
per-file js2gtest.*=file://ui/webui/PLATFORM_OWNERS
per-file *.js=file://ui/webui/PLATFORM_OWNERS
per-file *javascript*=file://ui/webui/PLATFORM_OWNERS
per-file *web_ui*=file://ui/webui/PLATFORM_OWNERS
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/** @fileoverview
* Externs for d8, v8's shell at v8/src/d8/.
* @externs
*/
/** @param {...string} var_args */
function print(var_args) {}
/** @param {number} code */
function quit(code) {}
/**
* @param {string} path
* @return {string}
*/
function read(path) {}
......@@ -24,7 +24,7 @@ if (arguments.length != 6) {
quit(-1);
}
[_,
const [_,
// Full path to the test input file, relative to the current working
// directory.
fullTestFilePath,
......@@ -94,7 +94,7 @@ let needGenHeader = true;
* Helpful hint pointing back to the source js.
* @type {string}
*/
const argHint = '// ' + arguments.join(' ');
const argHint = '// ' + Array.from(arguments).join(' ');
/**
* @type {Array<string>}
......@@ -117,6 +117,7 @@ function output(opt_string) {
/**
* Generates the header of the cc file to stdout.
* @param {string?} testFixture Name of test fixture.
* @this {!Object}
*/
function maybeGenHeader(testFixture) {
if (!needGenHeader) {
......@@ -181,9 +182,7 @@ ${argHint}
}
/**
* @type {Array<{path: string, base: string>}
*/
/** @type {!Array<string>} */
const pathStack = [];
......@@ -204,6 +203,7 @@ function includeFileToPath(includeFile) {
'Only relative "foo/bar" or source-absolute "//foo/bar" paths are ' +
'supported - not file-system absolute: "/foo/bar"');
quit(-1);
return '';
} else {
// The include-file path is relative to the file that included it.
const currentPath = pathStack[pathStack.length - 1];
......@@ -252,8 +252,8 @@ if (depsFile) {
* Called by the javascript in the deps file to add modules and their
* dependencies.
* @param {string} path Relative path to the file.
* @param Array<string> provides Objects provided by this file.
* @param Array<string> requires Objects required by this file.
* @param {!Array<string>} provides Objects provided by this file.
* @param {!Array<string>} requires Objects required by this file.
*/
goog.addDependency = function(path, provides, requires) {
provides.forEach(function(provide) {
......@@ -373,9 +373,10 @@ function getTestDeclarationLineNumber() {
* will invoke the |testBody| for |testFixture|.|testFunction|.
* @param {string} testFixture The name of this test's fixture.
* @param {string} testFunction The name of this test's function.
* @param {Function} testBody The function body to execute for this test.
* @param {!Function} testBody The function body to execute for this test.
* @param {string=} opt_preamble C++ to be generated before the TEST_F block.
* Useful for including #ifdef blocks. See TEST_F_WITH_PREAMBLE.
* @this {!Object}
*/
function TEST_F(testFixture, testFunction, testBody, opt_preamble) {
maybeGenHeader(testFixture);
......@@ -563,7 +564,7 @@ ${testF}(${testFixture}, ${testFunction}) {
* Useful for including #ifdef blocks.
* @param {string} testFixture The name of this test's fixture.
* @param {string} testFunction The name of this test's function.
* @param {Function} testBody The function body to execute for this test.
* @param {!Function} testBody The function body to execute for this test.
*/
function TEST_F_WITH_PREAMBLE(preamble, testFixture, testFunction, testBody) {
TEST_F(testFixture, testFunction, testBody, preamble);
......
......@@ -109,6 +109,9 @@ Test.prototype = {
*/
browsePreload: null,
/** @type {?string} */
webuiHost: null,
/**
* When set to a string value representing an html page in the test
* directory, generate BrowsePrintPreload call, which will browse to a url
......@@ -133,6 +136,9 @@ Test.prototype = {
*/
testGenPostamble: null,
/** @type {?function()} */
testGenCppIncludes: null,
/**
* When set to a non-null string, auto-generate typedef before generating
* TEST*: {@code typedef typedefCppFixture testFixture}.
......@@ -140,6 +146,19 @@ Test.prototype = {
*/
typedefCppFixture: 'WebUIBrowserTest',
/** @type {?Array<{switchName: string, switchValue: string}>} */
commandLineSwitches: null,
/** @type {?{enabled: !Array<string>, disabled: !Array<string>}} */
featureList: null,
/**
* @type {?Array<!{
* featureName: string,
* parameters: !Array<{name: string, value: string}>}>}
*/
featuresWithParameters: null,
/**
* This should be initialized by the test fixture and can be referenced
* during the test run. It holds any mocked handler methods.
......
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