Commit 946f459e authored by Eriko Kurimoto's avatar Eriko Kurimoto Committed by Commit Bot

Allow network::mojom::Foo in PRESUBMIT

This CL allows network::mojom::Foo type in PRESUBMIT.
network::mojom is planned to be used as non-blink mojom types.
(discussed here: https://groups.google.com/a/chromium.org/g/platform-architecture-dev/c/ntSzerId4gw)
Showing warnings when developers add network::mojom type is confusing.

This doesn't change the behavior for other ::mojom::Foo types.
FYI: https://chromium-review.googlesource.com/c/chromium/src/+/2010448/3#message-ebc5ce48bcda75d920adc0a3486c233bd802113b

Bug: 1043557
Change-Id: I362b2a0cec53bf39393d203689fbe0a98c34ca11
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2028879
Commit-Queue: Eriko Kurimoto <elkurin@google.com>
Reviewed-by: default avatarMakoto Shimazu <shimazu@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748503}
parent 91dd5b0b
......@@ -452,7 +452,8 @@ _CONFIG = [
'Use WTF containers like WTF::Deque, WTF::HashMap, WTF::HashSet or WTF::Vector instead of the banned std containers. '
'However, it is fine to use std containers at the boundary layer between Blink and Chromium. '
'If you are in this case, you can use --bypass-hooks option to avoid the presubmit check when uploading your CL.'),
('([a-zA-Z]*::)?mojom::(?!blink).+',
# network::mojom::Foo is allowed to use as non-blink mojom type.
('(|::)(?!network::)(\w+::)?mojom::(?!blink).+',
'Using non-blink mojom types, consider using "::mojom::blink::Foo" instead of "::mojom::Foo" unless you have clear reasons not to do so',
'Warning'),
],
......@@ -497,10 +498,9 @@ _CONFIG = [
],
},
{
'paths': [
'third_party/blink/renderer/core/animation_frame', 'third_party/blink/renderer/core/offscreencanvas',
'third_party/blink/renderer/core/html/canvas'
],
'paths': ['third_party/blink/renderer/core/animation_frame',
'third_party/blink/renderer/core/offscreencanvas',
'third_party/blink/renderer/core/html/canvas'],
'allowed': [
'viz::BeginFrameArgs',
],
......
......@@ -27,6 +27,24 @@ class TestAuditNonBlinkUsageTest(unittest.TestCase):
self.assertIsInstance(match, self._REGEXP_CLASS)
self.assertIsInstance(advice, str)
def test_for_special_cases(self):
for entry in audit_non_blink_usage._COMPILED_CONFIG:
if entry['paths'] == ['third_party/blink/renderer/']:
check_list = [
{'type': 'url::mojom::Origin', 'allowed': False},
{'type': '::media::mojom::InterfaceFactory', 'allowed': False},
{'type': 'Hogenetwork::mojom::URLLoaderFactory', 'allowed': False},
{'type': 'url::mojom::blink::Origin', 'allowed': True},
{'type': '::media::mojom::blink::InterfaceFactory', 'allowed': True},
{'type': 'network::mojom::URLLoaderFactory', 'allowed': True},
{'type': '::network::mojom::URLLoaderFactory', 'allowed': True},
]
for item in check_list:
if item['allowed']:
self.assertIsNone(re.match(entry['disallowed'], item['type']))
elif not item['allowed']:
self.assertIsNotNone(re.match(entry['disallowed'], item['type']))
if __name__ == '__main__':
unittest.main()
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