diff --git a/lint.ignore b/lint.ignore
index 767b16646b8805..14e02983f753d4 100644
--- a/lint.ignore
+++ b/lint.ignore
@@ -699,6 +699,17 @@ TESTHARNESS-IN-OTHER-TYPE: svg/svg-in-svg/svg-in-svg-circular-filter-reference-c
# Adding the testharnessreport.js script causes the test to never complete.
MISSING-TESTHARNESSREPORT: accessibility/crashtests/computed-node-checked.html
+# Existing manual tests with references
+REFERENCE-IN-OTHER-TYPE: css/CSS2/backgrounds/background-root-012a.xht
+REFERENCE-IN-OTHER-TYPE: css/CSS2/backgrounds/background-root-013a.xht
+REFERENCE-IN-OTHER-TYPE: css/CSS2/backgrounds/background-root-014a.xht
+REFERENCE-IN-OTHER-TYPE: css/CSS2/cascade/html-precedence-004.xht
+REFERENCE-IN-OTHER-TYPE: css/css-flexbox/css-flexbox-height-animation-stretch.html
+REFERENCE-IN-OTHER-TYPE: css/css-transforms/css-transform-scale-001-manual.html
+
+# Needs control of page size
+REFERENCE-IN-OTHER-TYPE: css/css-multicol/moz-multicol3-column-balancing-break-inside-avoid-1.html
+
PRINT STATEMENT: webdriver/tests/bidi/browsing_context/print/*
PRINT STATEMENT: webdriver/tests/classic/print/*
PRINT STATEMENT: webdriver/tests/support/fixtures_bidi.py
diff --git a/tools/lint/lint.py b/tools/lint/lint.py
index b7d934e7f43da0..32bc7ece7b12f3 100644
--- a/tools/lint/lint.py
+++ b/tools/lint/lint.py
@@ -430,6 +430,10 @@ def check_parsed(repo_root: Text, path: Text, f: IO[bytes]) -> List[rules.Error]
errors.append(rules.NonexistentRef.error(path,
(reference_rel, href)))
+ if source_file.reftest_nodes:
+ if test_type not in ("print-reftest", "reftest"):
+ errors.append(rules.ReferenceInOtherType.error(path, (test_type,)))
+
if len(source_file.timeout_nodes) > 1:
errors.append(rules.MultipleTimeout.error(path))
diff --git a/tools/lint/rules.py b/tools/lint/rules.py
index adddcdbe70c814..8dba7817a9e563 100644
--- a/tools/lint/rules.py
+++ b/tools/lint/rules.py
@@ -329,6 +329,11 @@ class TestharnessInOtherType(Rule):
description = "testharness.js included in a %s test"
+class ReferenceInOtherType(Rule):
+ name = "REFERENCE-IN-OTHER-TYPE"
+ description = "Reference link included in a %s test"
+
+
class DuplicateBasenamePath(Rule):
name = "DUPLICATE-BASENAME-PATH"
description = collapse("""
diff --git a/tools/lint/tests/test_file_lints.py b/tools/lint/tests/test_file_lints.py
index 34d3a0cdb13c0a..e77048b3156688 100644
--- a/tools/lint/tests/test_file_lints.py
+++ b/tools/lint/tests/test_file_lints.py
@@ -707,6 +707,41 @@ def test_late_timeout():
]
+def test_reference_in_non_reference():
+ code = b"""
+
+
+
+
+
+"""
+ error_map = check_with_files(code)
+
+ for (filename, (errors, kind)) in error_map.items():
+ check_errors(errors)
+
+ if kind in ["web-lax", "web-strict"]:
+ assert errors == [
+ (
+ "NON-EXISTENT-REF",
+ "Reference test with a non-existent 'match' relationship reference: "
+ "'test-ref.html'",
+ filename,
+ None,
+ ),
+ (
+ "REFERENCE-IN-OTHER-TYPE",
+ "Reference link included in a testharness test",
+ filename,
+ None,
+ ),
+ ]
+ elif kind == "python":
+ assert errors == [
+ ("PARSE-FAILED", "Unable to parse file", filename, 2),
+ ]
+
+
def test_print_function():
error_map = check_with_files(b"def foo():\n print('function')\n")