| LEFT | RIGHT |
| 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 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 } | 601 } |
| 602 | 602 |
| 603 // We are looking for the frame that contains the element which | 603 // We are looking for the frame that contains the element which |
| 604 // has triggered this request. For most requests (e.g. images) we | 604 // has triggered this request. For most requests (e.g. images) we |
| 605 // can just use the request's frame ID, but for subdocument requests | 605 // can just use the request's frame ID, but for subdocument requests |
| 606 // (e.g. iframes) we must instead use the request's parent frame ID. | 606 // (e.g. iframes) we must instead use the request's parent frame ID. |
| 607 let {frameId, type} = details; | 607 let {frameId, type} = details; |
| 608 if (type == "sub_frame") | 608 if (type == "sub_frame") |
| 609 frameId = details.parentFrameId; | 609 frameId = details.parentFrameId; |
| 610 | 610 |
| 611 let frame2 = null; |
| 612 if (details.frameAncestors) { |
| 613 for (let i = details.frameAncestors.length - 1; i >= 0; i--) { |
| 614 frame2 = {id: details.frameAncestors[i].frameId, |
| 615 url: new URL(details.frameAncestors[i].url), |
| 616 parent: frame2}; |
| 617 } |
| 618 |
| 619 // the url here is not correct I think. |
| 620 if (type != "sub_frame") |
| 621 frame2 = {url: new URL(details.documentUrl), parent: frame2}; |
| 622 } |
| 623 |
| 611 // Sometimes requests are not associated with a browser tab and | 624 // Sometimes requests are not associated with a browser tab and |
| 612 // in this case we want to still be able to view the url being called. | 625 // in this case we want to still be able to view the url being called. |
| 626 let page = null; |
| 613 let frame = null; | 627 let frame = null; |
| 614 let page = null; | |
| 615 if (details.tabId != -1) | 628 if (details.tabId != -1) |
| 616 { | 629 { |
| 617 frame = ext.getFrame(details.tabId, frameId); | 630 // Only Firefox supports frameAncestors, so we have to keep the list |
| 631 // of frames ourself. |
| 632 if (!frame) |
| 633 frame = ext.getFrame(details.tabId, frameId); |
| 634 |
| 635 |
| 636 let s = (f, a = []) => { |
| 637 a.push(f.url.toString()); |
| 638 if (f.parent) |
| 639 return s(f.parent, a) |
| 640 return a; |
| 641 } |
| 642 |
| 643 if (s(frame).length > 0) |
| 644 console.log(url.toString(), s(frame), s(frame2)) |
| 645 |
| 618 page = new Page({id: details.tabId}); | 646 page = new Page({id: details.tabId}); |
| 619 } | 647 } |
| 620 | 648 |
| 621 if (ext.webRequest.onBeforeRequest._dispatch( | 649 if (ext.webRequest.onBeforeRequest._dispatch( |
| 622 url, type, page, frame).includes(false)) | 650 url, type, page, frame).includes(false)) |
| 623 return {cancel: true}; | 651 return {cancel: true}; |
| 624 }, {urls: ["<all_urls>"]}, ["blocking"]); | 652 }, {urls: ["<all_urls>"]}, ["blocking"]); |
| 625 | 653 |
| 626 | 654 |
| 627 /* Message passing */ | 655 /* Message passing */ |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 ext.windows = { | 714 ext.windows = { |
| 687 create(createData, callback) | 715 create(createData, callback) |
| 688 { | 716 { |
| 689 browser.windows.create(createData, createdWindow => | 717 browser.windows.create(createData, createdWindow => |
| 690 { | 718 { |
| 691 afterTabLoaded(callback)(createdWindow.tabs[0]); | 719 afterTabLoaded(callback)(createdWindow.tabs[0]); |
| 692 }); | 720 }); |
| 693 } | 721 } |
| 694 }; | 722 }; |
| 695 } | 723 } |
| LEFT | RIGHT |