Open piquark6046 opened 1 year ago
Probably because on Firefox xhr
requests are redirected using data:
URI.
Also, please transcribe here the filter to use for your repro case.
Added into Steps to Reproduce
.
I think that uBO on a chromium-based web browser [^1] is also affected.
[^1]: Brave 1.48.171
I get exceptions being raised. Probably should move your <script>
tag just before </body>
.
All methods and property return empty data.
A redirect only loads a specific resource, nothing else, thats always been the case with any redirect and not limited to xhr only.
I want to go through repro steps, but your test case has an issue, your script references elements in the DOM which may not be there yet. If you move your script tag at the end of the body, the repro case will work without throwing an exception.
Fixed.
Similar (the site uses response.status
as bait):
https://github.com/uBlockOrigin/uAssets/issues/14204
let src = '[Some URL]';
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), 10_000);
let response;
try {
response = await fetch(src, {signal: controller.signal});
}
if (response.status !== 200) {
this.#showFail();
return;
}
Isn't the behavior shown in the this thread by design?
https://github.com/uBlockOrigin/uBlock-issues/wiki/Resources-Library#no-fetch-ifjs- & https://github.com/uBlockOrigin/uBlock-issues/wiki/Resources-Library#no-xhr-ifjs-:
returning a promise which always resolve to an
empty
response.
Anyway, AdGuard's fix: https://github.com/AdguardTeam/Scriptlets/commit/531ea12e1c5ddc7d26bd61cdc095a30894d0687e#diff-ff559a075c8491c9b6a0cdeea5aceee74950e68eb2423435ab3afaa87c4452ccR28
@gorhill
are you planning to support no-fetch-if
to return actual response?
this is required for case here
https://github.com/uBlockOrigin/uAssets/issues/19295
firefox
@ghajini https://github.com/uBlockOrigin/uBlock-issues/issues/2526 Did you mean this issue?
yes for no-fetch-if
What was done for no-xhr-if
in https://github.com/gorhill/uBlock/commit/bf591d93fbc692b7ccd0dfe630ed1cb0e5a33cfd needs to be done for no-fetch-if
.
'expires'?
'expires' was not added or is missing..
Adding expires
is too arbitrary, it's not always there. I would want to see many real cases before I start to consider throwing in there arbitrary headers.
@gorhill will the Resources-Library get a update? The latest features like length:
are missing.
I can update the wiki in a week or so.
Still not updated
Prerequisites
I tried to reproduce the issue when...
Description
Screencast from 2023-03-01 14-13-33.webm
A specific URL where the issue occurs.
https://piquark6046.github.io/testpage/XMLResponseHeader/
Steps to Reproduce
The step to reproduce is attached in the video.
Expected behavior
XMLHttpRequest.prototype.status
returns200
.XMLHttpRequest.prototype.getResponseHeader('content-length')
returns a digit number.XMLHttpRequest.prototype.getResponseHeader('expires')
returns a date and time.XMLHttpRequest.prototype.getAllResponseHeaders()
returns response header of a request.Actual behavior
When a
$redirect
filter is applied:XMLHttpRequest.prototype.status
returns0
.XMLHttpRequest.prototype.getResponseHeader('content-length')
returns anull
.XMLHttpRequest.prototype.getResponseHeader('expires')
returnsnull
.XMLHttpRequest.prototype.getAllResponseHeaders()
returns an empty string.When a scriptlet filter is applied:
uBO version
1.47.2
Browser name and version
Mozilla Firefox Developer Edition 111.0b7
Operating System and version
Ubuntu 22.10