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

Side by Side Diff: ext/background.js

Issue 29602570: Issue 6010 - Ignore requests initiated by the browser or extensions (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome
Patch Set: Created Nov. 9, 2017, 4:17 p.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 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 // Filter out requests from non web protocols. Ideally, we'd explicitly 581 // Filter out requests from non web protocols. Ideally, we'd explicitly
582 // specify the protocols we are interested in (i.e. http://, https://, 582 // specify the protocols we are interested in (i.e. http://, https://,
583 // ws:// and wss://) with the url patterns, given below, when adding this 583 // ws:// and wss://) with the url patterns, given below, when adding this
584 // listener. But unfortunately, Chrome <=57 doesn't support the WebSocket 584 // listener. But unfortunately, Chrome <=57 doesn't support the WebSocket
585 // protocol and is causing an error if it is given. 585 // protocol and is causing an error if it is given.
586 let url = new URL(details.url); 586 let url = new URL(details.url);
587 if (url.protocol != "http:" && url.protocol != "https:" && 587 if (url.protocol != "http:" && url.protocol != "https:" &&
588 url.protocol != "ws:" && url.protocol != "wss:") 588 url.protocol != "ws:" && url.protocol != "wss:")
589 return; 589 return;
590 590
591 if (details.originUrl)
592 {
593 // Firefox-only currently, ignore requests initiated by the browser and
594 // extensions.
595 let originUrl = new URL(details.originUrl);
596 if (originUrl.protocol == "chrome:" ||
597 originUrl.protocol == "moz-extension:")
598 {
599 return;
600 }
601 }
602
591 // We are looking for the frame that contains the element which 603 // We are looking for the frame that contains the element which
592 // has triggered this request. For most requests (e.g. images) we 604 // has triggered this request. For most requests (e.g. images) we
593 // 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
594 // (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.
595 let {frameId, type} = details; 607 let {frameId, type} = details;
596 if (type == "sub_frame") 608 if (type == "sub_frame")
597 frameId = details.parentFrameId; 609 frameId = details.parentFrameId;
598 610
599 // Sometimes requests are not associated with a browser tab and 611 // Sometimes requests are not associated with a browser tab and
600 // 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.
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 ext.windows = { 686 ext.windows = {
675 create(createData, callback) 687 create(createData, callback)
676 { 688 {
677 browser.windows.create(createData, createdWindow => 689 browser.windows.create(createData, createdWindow =>
678 { 690 {
679 afterTabLoaded(callback)(createdWindow.tabs[0]); 691 afterTabLoaded(callback)(createdWindow.tabs[0]);
680 }); 692 });
681 } 693 }
682 }; 694 };
683 } 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