Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a scoped class for the host resolver in CNAME uncloaking tests #15619

Open
antonok-edm opened this issue May 4, 2021 · 0 comments
Open
Assignees

Comments

@antonok-edm
Copy link
Contributor

Followup as per brave/brave-core#8601 (comment):

  network::HostResolver resolver(inner_resolver.get(), net::NetLog::Get());

  brave::SetAdblockCnameHostResolverForTesting(&resolver);

you also need to unset it somehow, so future tests would not get affected, see for example ScopedBrowserLocale or something like that

good point! I've updated the test to reset it to `nullptr again at the end, as well as some comments emphasizing that it's necessary. In the long-term some scoped solution would be ideal so I'll file a followup for that.

The CNAME tests in browser/brave_shields/ad_block_service_browsertest.cc use brave::SetAdblockCnameHostResolverForTesting, which needs to be manually reset to a nullptr after each test that uses it. This is an extra level of cognitive overhead when writing test code, so it'd be better to use a similar "scoped" class that will automatically reset when its destructor is called.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant