Left: | ||
Right: |
OLD | NEW |
---|---|
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-present eyeo GmbH | 3 * Copyright (C) 2006-present eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 // overridden when Chrome automatically resets them on navigation. | 153 // overridden when Chrome automatically resets them on navigation. |
154 if (browser.runtime.lastError) | 154 if (browser.runtime.lastError) |
155 ext.pages.onLoading._dispatch(page); | 155 ext.pages.onLoading._dispatch(page); |
156 }); | 156 }); |
157 } | 157 } |
158 | 158 |
159 // Update frame URL and parent in frame structure | 159 // Update frame URL and parent in frame structure |
160 let frame = createFrame(tabId, frameId); | 160 let frame = createFrame(tabId, frameId); |
161 frame.url = new URL(url); | 161 frame.url = new URL(url); |
162 | 162 |
163 let parentFrame = framesOfTabs.get(tabId).get(parentFrameId); | 163 let frames = framesOfTabs.get(tabId); |
164 let parentFrame = frames.get(parentFrameId); | |
165 if (!parentFrame && parentFrameId > 0) | |
166 parentFrame = frames.get(0); | |
167 | |
164 if (parentFrame) | 168 if (parentFrame) |
165 frame.parent = parentFrame; | 169 frame.parent = parentFrame; |
166 } | 170 } |
167 | 171 |
168 browser.webRequest.onHeadersReceived.addListener(details => | 172 browser.webRequest.onHeadersReceived.addListener(details => |
169 { | 173 { |
170 // We have to update the frame structure when switching to a new | 174 // We have to update the frame structure when switching to a new |
171 // document, so that we process any further requests made by that | 175 // document, so that we process any further requests made by that |
172 // document in the right context. Unfortunately, we cannot rely | 176 // document in the right context. Unfortunately, we cannot rely |
173 // on webNavigation.onCommitted since it isn't guaranteed to fire | 177 // on webNavigation.onCommitted since it isn't guaranteed to fire |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
521 { | 525 { |
522 let frames = new Map(); | 526 let frames = new Map(); |
523 framesOfTabs.set(tab.id, frames); | 527 framesOfTabs.set(tab.id, frames); |
524 | 528 |
525 for (let detail of details) | 529 for (let detail of details) |
526 { | 530 { |
527 let frame = {url: new URL(detail.url)}; | 531 let frame = {url: new URL(detail.url)}; |
528 frames.set(detail.frameId, frame); | 532 frames.set(detail.frameId, frame); |
529 | 533 |
530 if (detail.parentFrameId != -1) | 534 if (detail.parentFrameId != -1) |
535 { | |
531 frame.parent = frames.get(detail.parentFrameId); | 536 frame.parent = frames.get(detail.parentFrameId); |
537 | |
538 if (!frame.parent && detail.parentFrameId != 0) | |
Sebastian Noack
2018/07/25 19:31:24
Why not falling back to the top-level frame here i
Sebastian Noack
2018/07/25 19:31:24
Nit: Above you check for parentFrameId > 0, here y
kzar
2018/07/25 20:28:25
Well, if the parentFrameId is -1 I figure it's the
kzar
2018/07/25 20:28:25
Done.
| |
539 frame.parent = frames.get(0); | |
540 } | |
532 } | 541 } |
533 } | 542 } |
534 }); | 543 }); |
535 }); | 544 }); |
536 }); | 545 }); |
537 | 546 |
538 | 547 |
539 /* Message passing */ | 548 /* Message passing */ |
540 | 549 |
541 browser.runtime.onMessage.addListener((message, rawSender, sendResponse) => | 550 browser.runtime.onMessage.addListener((message, rawSender, sendResponse) => |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
590 return frames.get(0) || null; | 599 return frames.get(0) || null; |
591 } | 600 } |
592 }; | 601 }; |
593 } | 602 } |
594 | 603 |
595 return ext.onMessage._dispatch( | 604 return ext.onMessage._dispatch( |
596 message, sender, sendResponse | 605 message, sender, sendResponse |
597 ).includes(true); | 606 ).includes(true); |
598 }); | 607 }); |
599 } | 608 } |
OLD | NEW |