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
Add support for ABP filter redirects as mock responses #3419
Merged
+318
−353
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.
Add browsertest for redirect content support
- Loading branch information
| @@ -86,9 +86,10 @@ class AdBlockServiceTest : public ExtensionBrowserTest { | ||
| ASSERT_TRUE(g_brave_browser_process->ad_block_service()->IsInitialized()); | ||
| } | ||
|
|
||
| void UpdateAdBlockInstanceWithRules(const char* rules) { | ||
| void UpdateAdBlockInstanceWithRules(const std::string& rules, | ||
| const std::string& resources = "") { | ||
| g_brave_browser_process->ad_block_service() | ||
| ->ResetForTest(rules); | ||
| ->ResetForTest(rules, resources); | ||
| } | ||
|
|
||
| void AssertTagExists(const std::string& tag, bool expected_exists) const { | ||
| @@ -744,3 +745,34 @@ IN_PROC_BROWSER_TEST_F(AdBlockServiceTest, CancelRequestOptionTest) { | ||
| EXPECT_TRUE(as_expected); | ||
| EXPECT_EQ(browser()->profile()->GetPrefs()->GetUint64(kAdsBlocked), 1ULL); | ||
| } | ||
|
|
||
| // Load a page with a script which uses a redirect. | ||
| IN_PROC_BROWSER_TEST_F(AdBlockServiceTest, | ||
| RedirectRulesAreRespected) { | ||
| UpdateAdBlockInstanceWithRules("js_mock_me.js$redirect=noopjs", | ||
| "[" | ||
|
This conversation was marked as resolved
by bbondy
iefremov
Contributor
|
||
| "{\"name\":\"noop.js\",\"aliases\":[\"noopjs\"]," | ||
| "\"kind\":{\"mime\":\"application/javascript\"}," | ||
| "\"content\":\"KGZ1bmN0aW9uKCkgewogICAgJ3VzZSBzdHJpY3QnOwp9KSgpOwo=\"}" | ||
| "]"); | ||
| EXPECT_EQ(browser()->profile()->GetPrefs()->GetUint64(kAdsBlocked), 0ULL); | ||
|
|
||
| GURL url = embedded_test_server()->GetURL("example.com", kAdBlockTestPage); | ||
|
This conversation was marked as resolved
by bbondy
|
||
| ui_test_utils::NavigateToURL(browser(), url); | ||
| content::WebContents* contents = | ||
| browser()->tab_strip_model()->GetActiveWebContents(); | ||
|
|
||
| std::string noopjs = "(function() {\\n \\'use strict\\';\\n})();\\n"; | ||
| bool as_expected = false; | ||
| GURL resource_url = | ||
| embedded_test_server()->GetURL("example.com", "/js_mock_me.js"); | ||
| ASSERT_TRUE(ExecuteScriptAndExtractBool(contents, | ||
| base::StringPrintf( | ||
| "setExpectations(0, 0, 0, 1, 0, 0);" | ||
| "xhr_expect_content('%s', '%s');", | ||
| resource_url.spec().c_str(), | ||
| noopjs.c_str()), | ||
| &as_expected)); | ||
| EXPECT_TRUE(as_expected); | ||
| EXPECT_EQ(browser()->profile()->GetPrefs()->GetUint64(kAdsBlocked), 1ULL); | ||
| } | ||
| @@ -0,0 +1 @@ | ||
| testing |
ProTip!
Use n and p to navigate between commits in a pull request.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
clang-format