feat(ads/seo/release): v1.2.0 with live Google Ads, isolated ad profile, ads.txt, and SEO/AEO/GEO optimization
This commit is contained in:
parent
a88aafa1e5
commit
0e568f1f0a
975 changed files with 130593 additions and 16783 deletions
61
tests/Paca.Tests/Browser/DeclarativeNetRequestTrieTests.cs
Normal file
61
tests/Paca.Tests/Browser/DeclarativeNetRequestTrieTests.cs
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Paca.Browser.Extensions;
|
||||
using Xunit;
|
||||
|
||||
namespace Paca.Tests.Browser;
|
||||
|
||||
public class DeclarativeNetRequestTrieTests
|
||||
{
|
||||
[Fact]
|
||||
public void DnrUrlTrie_Prefix_And_Suffix_Matches_Correctly()
|
||||
{
|
||||
var trie = new DnrUrlTrie();
|
||||
trie.InsertPrefix("https://analytics.", 101);
|
||||
trie.InsertSuffix(".ad_tracker.js", 102);
|
||||
trie.InsertDomain("bad-domain.com", 103);
|
||||
|
||||
// 1. Prefix 매칭
|
||||
var matches1 = trie.FindMatches("https://analytics.google.com/collect");
|
||||
Assert.Contains(101, matches1);
|
||||
|
||||
// 2. Suffix 매칭
|
||||
var matches2 = trie.FindMatches("https://cdn.example.org/assets/vendor.ad_tracker.js");
|
||||
Assert.Contains(102, matches2);
|
||||
|
||||
// 3. Domain 앵커 매칭
|
||||
var matches3 = trie.FindMatches("https://sub.bad-domain.com/banner.png");
|
||||
Assert.Contains(103, matches3);
|
||||
|
||||
// 4. 불일치 URL
|
||||
var matches4 = trie.FindMatches("https://clean-site.org/index.html");
|
||||
Assert.Empty(matches4);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DeclarativeNetRequestEngine_Uses_Trie_Index()
|
||||
{
|
||||
var engine = new DeclarativeNetRequestEngine();
|
||||
var rules = new List<DnrRule>
|
||||
{
|
||||
new DnrRule
|
||||
{
|
||||
Id = 1,
|
||||
Priority = 1,
|
||||
Action = new DnrRuleAction { Type = "block" },
|
||||
Condition = new DnrRuleCondition
|
||||
{
|
||||
UrlFilter = "||doubleclick.net^",
|
||||
ResourceTypes = new List<string> { "xmlhttprequest", "sub_frame" }
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
engine.RegisterStaticRules("ext_ublock", rules);
|
||||
var decision = engine.EvaluateRequest("https://ad.doubleclick.net/pixel", method: "GET", resourceType: "xmlhttprequest");
|
||||
|
||||
Assert.NotNull(decision);
|
||||
Assert.Equal(DnrRuleActionType.Block, decision.ActionType);
|
||||
Assert.Equal(1, decision.MatchedRuleId);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue