Open Bug 1556507 Opened 6 years ago Updated 3 years ago

Precompressed gzip-files (javascript) are working with Chromium but not with Firefox

Categories

(Core :: DOM: Networking, defect, P3)

defect

Tracking

()

Tracking Status
firefox67 --- affected
firefox68 --- affected
firefox69 --- affected

People

(Reporter: damir.isanbirdin, Unassigned)

Details

(Whiteboard: [necko-triaged])

Attachments

(3 files)

User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36

Steps to reproduce:

  • precompress javascript file blah.js as blah.js.gz

Actual results:

  • javascript will be not recongnized

Expected results:

render as JavaScript

Hi,
Please, see if the issue is still reproducible on Nightly latest version, you can download it from here https://www.mozilla.org/en-US/firefox/nightly/all/
Also, could you please provide a example file?

thanks,

Flags: needinfo?(damir.isanbirdin)
Attached image Firefox bug
Flags: needinfo?(damir.isanbirdin)

(In reply to Luciana queirolo from comment #2)

Hi,

Nightly build is buggy as well: precompressed js are not rendering. Firefox still thinks - there is gzip-file. But forget to think a futher step- it is javascript- MIME. Look a last screenshot I did. Tested with safari, opera, edge- works very well , but not Firefox....

I will provide a simple example.
But it is very simple to reproduce: gzip any js-file. Include this file in your html . If you are using offline- your file name must be be *.js after gzip. If you are using server etc *.js.gz

Regards

Hi,(In reply to Luciana queirolo from comment #2)

An example project:

https://github.com/damir78/frfxdemo

I'm using spring boot (java).

You can start as DemoApplication.java as main class or
using script mvnw on linux or mvnw.cmd on windows.

Try
http://localhost:8080/hello.html

Regards
Damir

Hi, I managed to reproduce this issue on Windows 10 in our Latest nightly build 69.0a1 (2019-07-07), as well as Beta 68 and Release 67.0.4, I was using spring boot and the Demo from https://github.com/damir78/frfxdemo, after starting the DemoApplication.java and reaching http://localhost:8080/hello.html the Hello world prompt wouldnt be displayed like it is on Chrome or Edge.

I'm not sure what the correct component for this issue is, if its Javascript Engine or maybe File Handling but hopefully our devs can move it to the correct one. Thanks for taking the time to report this issue.

Status: UNCONFIRMED → NEW
Component: Untriaged → JavaScript Engine
Ever confirmed: true
Product: Firefox → Core

Andrea, any idea where this bug belongs and who might look at it?
My guess would be that this is related to the HTTP headers of the pre-compress JS file or to some automatic mime-type inference that Chrome does and not Firefox.

Component: JavaScript Engine → DOM: Core & HTML
Flags: needinfo?(amarchesini)

Reproduced using this node script, in case anyone doesn't want to install Java.

This is definitely a MIME handling thing. I don't know what the right component is, but File Handling is closer than JavaScript Engine.

const gzipped_bytes = Buffer.from([
  31, 139, 8, 8, 245, 88, 39, 93, 0, 3, 116, 101, 115, 116, 46, 106, 115, 0,
  75, 201, 79, 46, 205, 77, 205, 43, 209, 43, 47, 202, 44, 73, 213, 80, 178,
  201, 48, 180, 203, 72, 205, 201, 201, 87, 40, 207, 47, 202, 73, 177, 209,
  7, 242, 149, 52, 173, 185, 0, 14, 85, 38, 26, 40, 0, 0, 0
]);

require('http').createServer((req, res) => {
  console.log(req.url);
  if (req.url == "/") {
    res.writeHead(200, {"Content-Type": "text/html"});
    res.write('<script src="test.js"></script>');
  } else if (req.url == "/test.js") {
    res.writeHead(200, {
      "Content-Type": "application/x-gzip",
      "Content-Encoding": "gzip"
    });
    res.write(gzipped_bytes);
  } else {
    res.writeHead(404);
  }
  res.end();
}).listen(8080);

Jason, thanks for this test! So the issue is that we are actually treating JS differently because its content-type is not valid.
annevk, based on the mime-sniff spec, should we treat this JS as text/javascript, or we should ignore it (as we do)?

This sounds like a server-side bug, because the Content-Type should describe the content, and not the encoding.

Flags: needinfo?(amarchesini) → needinfo?(annevk)

The classic script loader does not care much for the Content-Type header (except for blocking on certain specific MIME types, such as text/csv). Bug 1030660 seems more suspect here. We probably need more tests to find out what other user agents do exactly in order to feel confident on changing our code around this.

Flags: needinfo?(annevk)
Component: DOM: Core & HTML → DOM: Networking
Priority: -- → P3
Whiteboard: [necko-triaged]
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: