[lint] Disallow *.mojom.js in WPT (#24980)

We now have established a formal way to do this (more documentation will
be available in Chromium, as this is Chrome-only) and should no longer
accept these auto-generated files in WPT.

Related to #16455.
diff --git a/lint.ignore b/lint.ignore
index 6b79e8a..a17a094 100644
--- a/lint.ignore
+++ b/lint.ignore
@@ -726,6 +726,12 @@
 MISSING DEPENDENCY: webusb/resources/usb-helpers.js
 MISSING DEPENDENCY: webxr/resources/webxr_util.js
 
+# TODO(Hexcles): delete these files once we include them in mojojs.zip.
+MOJOM-JS: resources/chromium/image_capture.mojom.js
+MOJOM-JS: resources/chromium/sensor_provider.mojom.js
+MOJOM-JS: resources/chromium/mojo_web_test_helper_test.mojom.js
+MOJOM-JS: resources/chromium/sensor.mojom.js
+
 # Tests that are false positives for using Ahem as a system font
 AHEM SYSTEM FONT: acid/acid3/test.html
 AHEM SYSTEM FONT: resource-timing/resources/all_resource_types.htm
diff --git a/tools/lint/lint.py b/tools/lint/lint.py
index 8a1149c..7bec438 100644
--- a/tools/lint/lint.py
+++ b/tools/lint/lint.py
@@ -198,6 +198,13 @@
     return [rules.GitIgnoreFile.error(path)]
 
 
+def check_mojom_js(repo_root, path):
+    # type: (Text, Text) -> List[rules.Error]
+    if path.endswith(".mojom.js"):
+        return [rules.MojomJSFile.error(path)]
+    return []
+
+
 def check_ahem_copy(repo_root, path):
     # type: (Text, Text) -> List[rules.Error]
     lpath = path.lower()
@@ -997,8 +1004,9 @@
                 logger.info(line)
     return sum(itervalues(error_count))
 
+
 path_lints = [check_file_type, check_path_length, check_worker_collision, check_ahem_copy,
-              check_tentative_directories, check_gitignore_file]
+              check_mojom_js, check_tentative_directories, check_gitignore_file]
 all_paths_lints = [check_css_globally_unique, check_unique_testharness_basenames]
 file_lints = [check_regexp_line, check_parsed, check_python_ast, check_script_metadata,
               check_ahem_system_font]
diff --git a/tools/lint/rules.py b/tools/lint/rules.py
index 1bf78b7..f6e23ae 100644
--- a/tools/lint/rules.py
+++ b/tools/lint/rules.py
@@ -81,6 +81,18 @@
     description = ".gitignore found outside the root"
 
 
+class MojomJSFile(Rule):
+    name = "MOJOM-JS"
+    description = "Don't check *.mojom.js files into WPT"
+    to_fix = """
+        Check if the file is already included in mojojs.zip:
+        https://source.chromium.org/chromium/chromium/src/+/master:chrome/tools/build/linux/FILES.cfg
+        If yes, use `loadMojoResources` from `resources/test-only-api.js` to load
+        it; if not, contact ecosystem-infra@chromium.org for adding new files
+        to mojojs.zip.
+    """
+
+
 class AhemCopy(Rule):
     name = "AHEM COPY"
     description = "Don't add extra copies of Ahem, use /fonts/Ahem.ttf"
diff --git a/tools/lint/tests/test_path_lints.py b/tools/lint/tests/test_path_lints.py
index 7368216..9fefb7a 100644
--- a/tools/lint/tests/test_path_lints.py
+++ b/tools/lint/tests/test_path_lints.py
@@ -7,6 +7,7 @@
 from .base import check_errors
 import pytest
 
+
 def test_allowed_path_length():
     basename = 29 * "test/"
 
@@ -29,6 +30,7 @@
         check_errors(errors)
         assert errors == [("PATH LENGTH", message, filename, None)]
 
+
 @pytest.mark.parametrize("path_ending,generated", [(".worker.html", ".worker.js"),
                                                    (".any.worker.html", ".any.js"),
                                                    (".any.html", ".any.js")])
@@ -70,6 +72,7 @@
 
     assert errors == [expected_error]
 
+
 @pytest.mark.parametrize("path", ["ahem.woff",
                                   "ahem.ttff",
                                   "support/ahem.woff",
@@ -79,6 +82,16 @@
 
     assert errors == []
 
+
+def test_mojom_js_file():
+    path = "resources/fake_device.mojom.js"
+    errors = check_path("/foo/", path)
+    assert errors == [("MOJOM-JS",
+                       "Don't check *.mojom.js files into WPT",
+                       path,
+                       None)]
+
+
 @pytest.mark.parametrize("path", ["css/foo.tentative/bar.html",
                                   "css/.tentative/bar.html",
                                   "css/tentative.bar/baz.html",
@@ -94,6 +107,7 @@
 
     assert errors == [expected_error]
 
+
 @pytest.mark.parametrize("path", ["css/bar.html",
                                   "css/tentative/baz.html"])
 def test_tentative_directories_negative(path):
@@ -102,6 +116,7 @@
 
     assert errors == []
 
+
 @pytest.mark.parametrize("path", ["elsewhere/.gitignore",
                                   "else/where/.gitignore"
                                   "elsewhere/tools/.gitignore",
@@ -120,6 +135,7 @@
 
     assert errors == [expected_error]
 
+
 @pytest.mark.parametrize("path", [".gitignore",
                                   "elsewhere/.gitignores",
                                   "elsewhere/name.gitignore",