|
495 | 495 | }, |
496 | 496 |
|
497 | 497 | async reportTo(originalRequest, allowed, policyType) { |
498 | | - const { requestId, tabId, frameId, type, url, documentUrl, originUrl } = |
| 498 | + const { requestId, tabId, type, url, documentUrl, originUrl } = |
499 | 499 | originalRequest; |
| 500 | + |
500 | 501 | const pending = pendingRequests.get(requestId); // null if from a CSP report |
501 | 502 |
|
502 | 503 | const request = { |
|
554 | 555 | return; |
555 | 556 | } |
556 | 557 | if (pending) request.initialUrl = pending.initialUrl; |
557 | | - if (type !== "sub_frame") { |
| 558 | + let { frameId, parentFrameId } = originalRequest; |
| 559 | + if (type == "sub_frame") { |
558 | 560 | // we couldn't deliver it to frameId, since it's generally not loaded yet |
559 | | - try { |
560 | | - await Messages.send( |
561 | | - "seen", |
562 | | - { request, allowed, policyType, ownFrame: true }, |
563 | | - { tabId, frameId } |
564 | | - ); |
565 | | - } catch (e) { |
566 | | - debug( |
567 | | - `Couldn't deliver "seen" message for ${type}@${url} ${ |
568 | | - allowed ? "A" : "F" |
569 | | - } to document ${documentUrl} (${frameId}/${tabId})`, |
570 | | - e |
571 | | - ); |
572 | | - } |
| 561 | + frameId = parentFrameId; |
573 | 562 | } |
574 | | - if (frameId === 0) return; |
| 563 | + try { |
| 564 | + await Messages.send( |
| 565 | + "seen", |
| 566 | + { request, allowed, policyType, ownFrame: true }, |
| 567 | + { tabId, frameId } |
| 568 | + ); |
| 569 | + } catch (e) { |
| 570 | + debug( |
| 571 | + `Couldn't deliver "seen" message for ${type}@${url} ${ |
| 572 | + allowed ? "A" : "F" |
| 573 | + } to document ${documentUrl} (${frameId}/${tabId})`, |
| 574 | + e |
| 575 | + ); |
| 576 | + } |
| 577 | + |
| 578 | + if (frameId === 0) { |
| 579 | + return; |
| 580 | + } |
| 581 | + |
575 | 582 | try { |
576 | 583 | await Messages.send( |
577 | 584 | "seen", |
|
0 commit comments