Hi all,
The above code was working fine in Firefox 66 (content_script.js):
try {
var status = -1
var data = ''
var path = 'file:///path/to/file.txt'
var xhr = new XMLHttpRequest()
xhr.open('GET', path, false)
xhr.addEventListener('load', function () {
status = this.status
// status is 0 for local file mode (i.e., file://)
if (status == 0 || status == 200) {
data = this.responseText
}
});
xhr.overrideMimeType('text/plain')
xhr.send()
console.log(data)
} catch (e) {
console.log('error', e)
}
But with Firefox 68, I get “A network error occurred”.
Please note that it’s working fine when using http(s) protocol (for instance, var path = 'http://localhost/file.txt'
).
In the Firefox 68 release note, there’s two changes on XMLHttpRequest
but, as far as I understand, they are related to my use case:
XMLHttpRequest
has been updated to no longer accept the non-standardmoz-chunked-arraybuffer
value for `responseType. Code still using it should be updated to use the Fetch API as a stream.
XMLHttpRequest
now outputs a warning to console if you perform a synchronous request while handling anunload,
beforeunload, orpagehide
event.
Should I submit a bug on https://bugzilla.mozilla.org ? Is it intended?