Skip to content

Commit 930eebc

Browse files
author
tvinzz
committed
refactored addLoadContext
1 parent 5a1c799 commit 930eebc

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

Sources/ContentBlockerConverter/Compiler/BlockerEntryFactory.swift

+6-10
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ class BlockerEntryFactory {
269269
types.add("document");
270270
}
271271
if rule.hasContentType(contentType: NetworkRule.ContentType.SUBDOCUMENT) {
272-
// `child-frame` resource type is supported since Safari 15
273272
if !SafariService.current.version.isSafari15() {
274273
types.add("document");
275274
}
@@ -306,17 +305,14 @@ class BlockerEntryFactory {
306305

307306
private func addLoadContext(rule: NetworkRule, trigger: inout BlockerEntry.Trigger) -> Void {
308307
var context = [String]();
309-
if rule.hasContentType(contentType: NetworkRule.ContentType.SUBDOCUMENT) {
310-
// `child-frame` resource type is supported since Safari 15
311-
if SafariService.current.version.isSafari15() {
308+
// `child-frame` and `top-frame` contexts are supported since Safari 15
309+
if SafariService.current.version.isSafari15() {
310+
if rule.hasContentType(contentType: NetworkRule.ContentType.SUBDOCUMENT) {
312311
context.append("child-frame");
313-
}
314-
}
315-
if rule.hasRestrictedContentType(contentType: NetworkRule.ContentType.SUBDOCUMENT) {
316-
// `top-frame` resource type is supported since Safari 15
317-
if SafariService.current.version.isSafari15() {
312+
}
313+
if rule.hasRestrictedContentType(contentType: NetworkRule.ContentType.SUBDOCUMENT) {
318314
context.append("top-frame");
319-
}
315+
}
320316
}
321317
if context.count > 0 {
322318
trigger.loadContext = context;

0 commit comments

Comments
 (0)