|
200 | 200 |
|
201 | 201 | async fetchChildPolicy({url, contextUrl}, sender) { |
202 | 202 | await ns.initializing; |
203 | | - return ns.computeChildPolicy(...arguments); |
| 203 | + return await ns.computeChildPolicy(...arguments); |
204 | 204 | }, |
205 | 205 |
|
206 | 206 | async openStandalonePopup(tab) { |
|
305 | 305 | return !this.isEnforced(request.tabId) || this.policy.can(request.url, capability, this.policyContext(request)); |
306 | 306 | }, |
307 | 307 |
|
308 | | - computeChildPolicy({url, contextUrl}, sender) { |
| 308 | + async computeChildPolicy({url, contextUrl}, sender) { |
309 | 309 | let {tab} = sender; |
310 | 310 | let policy = ns.policy; |
311 | 311 | const {isTorBrowser} = ns.local; |
|
322 | 322 |
|
323 | 323 | const tabId = tab ? tab.id : -1; |
324 | 324 | let topUrl; |
325 | | - if (sender.frameId === 0) { |
| 325 | + const isTop = sender.frameId === 0; |
| 326 | + if (isTop) { |
326 | 327 | topUrl = url; |
327 | 328 | } else if (tab) { |
328 | 329 | if (!tab.url) tab = TabCache.get(tabId); |
|
338 | 339 | let permissions, unrestricted, cascaded; |
339 | 340 | if (policy) { |
340 | 341 | let perms = policy.get(url, contextUrl).perms; |
341 | | - cascaded = topUrl && ns.sync.cascadeRestrictions; |
342 | | - if (cascaded) { |
343 | | - perms = policy.cascadeRestrictions(perms, topUrl); |
| 342 | + if (isTop) { |
| 343 | + if (policy.autoAllowTop && perms === policy.DEFAULT) { |
| 344 | + policy.set(Sites.optimalKey(url), perms = policy.TRUSTED.tempTwin); |
| 345 | + await RequestGuard.DNRPolicy?.update(); |
| 346 | + } |
| 347 | + } else { |
| 348 | + cascaded = topUrl && ns.sync.cascadeRestrictions; |
| 349 | + if (cascaded) { |
| 350 | + perms = policy.cascadeRestrictions(perms, topUrl); |
| 351 | + } |
344 | 352 | } |
345 | 353 | permissions = perms.dry(); |
346 | 354 | } else { |
|
0 commit comments