Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: ext/background.js

Issue 29633597: Issue 6119 - Work in Progress use framAncestors in Firefox
Patch Set: Created Dec. 8, 2017, 11:48 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
624 // Sometimes requests are not associated with a browser tab and 611 // Sometimes requests are not associated with a browser tab and
625 // in this case we want to still be able to view the url being called. 612 // in this case we want to still be able to view the url being called.
613 let frame = null;
626 let page = null; 614 let page = null;
627 let frame = null;
628 if (details.tabId != -1) 615 if (details.tabId != -1)
629 { 616 {
630 // Only Firefox supports frameAncestors, so we have to keep the list 617 frame = ext.getFrame(details.tabId, frameId);
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
646 page = new Page({id: details.tabId}); 618 page = new Page({id: details.tabId});
647 } 619 }
648 620
649 if (ext.webRequest.onBeforeRequest._dispatch( 621 if (ext.webRequest.onBeforeRequest._dispatch(
650 url, type, page, frame).includes(false)) 622 url, type, page, frame).includes(false))
651 return {cancel: true}; 623 return {cancel: true};
652 }, {urls: ["<all_urls>"]}, ["blocking"]); 624 }, {urls: ["<all_urls>"]}, ["blocking"]);
653 625
654 626
655 /* Message passing */ 627 /* Message passing */
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 ext.windows = { 686 ext.windows = {
715 create(createData, callback) 687 create(createData, callback)
716 { 688 {
717 browser.windows.create(createData, createdWindow => 689 browser.windows.create(createData, createdWindow =>
718 { 690 {
719 afterTabLoaded(callback)(createdWindow.tabs[0]); 691 afterTabLoaded(callback)(createdWindow.tabs[0]);
720 }); 692 });
721 } 693 }
722 }; 694 };
723 } 695 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld