Mitigate undesireable side-effect of 901c325eab

Related discussion/issue:
- https://github.com/uBlockOrigin/uMatrix-issues/issues/156#issuecomment-494427094
- https://github.com/uBlockOrigin/uMatrix-issues/issues/155

Due to a Chromium issue about not providing the proper context
information, a negative side-effect was introduced with fix
to #155. This commit will force the originator of a network
request of type `main_frame` to be that of the request URL
itself, i.e. the originator of a top-level document request
is the requested document itself.
This commit is contained in:
Raymond Hill 2019-05-21 11:21:34 -04:00
parent 0807d71704
commit 1ddb822509
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 7 additions and 3 deletions

View File

@ -71,17 +71,21 @@
const parsedURL = new URL('https://www.example.org/');
vAPI.net.normalizeDetails = function(details) {
let type = details.type;
// https://github.com/uBlockOrigin/uMatrix-issues/issues/156#issuecomment-494427094
if ( type === 'main_frame' ) {
details.documentUrl = details.url;
}
// Chromium 63+ supports the `initiator` property, which contains
// the URL of the origin from which the network request was made.
if (
else if (
typeof details.initiator === 'string' &&
details.initiator !== 'null'
) {
details.documentUrl = details.initiator;
}
let type = details.type;
// https://github.com/gorhill/uBlock/issues/1493
// Chromium 49+/WebExtensions support a new request type: `ping`,
// which is fired as a result of using `navigator.sendBeacon`.