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

12351: Fix flaky adblocker test. #7115

Merged
merged 1 commit into from
Nov 11, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions browser/brave_shields/ad_block_service_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -497,8 +497,7 @@ IN_PROC_BROWSER_TEST_F(AdBlockServiceTest, NewTabContinuesToBlock) {
}

// XHRs and ads in a cross-site iframe are blocked as well.
// Enable when https://github.com/brave/brave-browser/issues/12351 is fixed
IN_PROC_BROWSER_TEST_F(AdBlockServiceTest, DISABLED_SubFrame) {
IN_PROC_BROWSER_TEST_F(AdBlockServiceTest, SubFrame) {
SetDefaultComponentIdAndBase64PublicKeyForTest(
kDefaultAdBlockComponentTestId,
kDefaultAdBlockComponentTestBase64PublicKey);
Expand All @@ -517,10 +516,16 @@ IN_PROC_BROWSER_TEST_F(AdBlockServiceTest, DISABLED_SubFrame) {

// Check also an explicit request for a script since it is a common real-world
// scenario.
ASSERT_TRUE(ExecuteScript(contents->GetAllFrames()[1],
"var s = document.createElement('script');"
"s.setAttribute('src', 'adbanner.js?2');"
"document.head.appendChild(s);"));
ASSERT_EQ(true, EvalJs(contents->GetAllFrames()[1],
R"(
new Promise(function (resolve, reject) {
var s = document.createElement('script');
s.onload = reject;
s.onerror = () => resolve(true);
s.src = 'adbanner.js?2';
document.head.appendChild(s);
})
)"));
content::RunAllTasksUntilIdle();
EXPECT_EQ(browser()->profile()->GetPrefs()->GetUint64(kAdsBlocked), 2ULL);
}
Expand Down