Open Bug 717877 Opened 13 years ago Updated 1 year ago

nsUpdateService.js should use (async) XMLHttpRequest instead of DOMParser::parseFromStream

Categories

(Toolkit :: Application Update, defect, P3)

defect

Tracking

()

People

(Reporter: hsivonen, Assigned: WeirdAl)

References

(Blocks 2 open bugs)

Details

In order to avoid synchronous IO and in order to allow us to avoid maintaining chrome-only duplicate functionality, please migrate nsUpdateService.js to use XMLHttpRequest in the async mode with responseType set to "document" instead of using nsIDOMParser::parseFromStream.
Assigning a P2 as it's not clear how much of an impact this main thread IO has. Feel free to deprioritize.
Whiteboard: [Snappy] → [Snappy:P2]
To do this, it looks like nsUpdateService's ensureUpdates needs to be asynchronous, as well as all calling it, so things like getUpdateAt which is used in several places.
Summary: nsUpdateService.js should use (async) XMLHttpRequest instead of nsIDOMParser::parseFromStream → nsUpdateService.js should use (async) XMLHttpRequest instead of DOMParser::parseFromStream
Priority: -- → P3
Whiteboard: [Snappy:P2]

This is now the last use of parseFromStream.

Saving for future reference:

      const fileOptions = {
        read : true,
        write: fileName === FILE_ACTIVE_UPDATE_XML
      };
      let fileP = await OS.File.open(file.path, fileOptions);
      let decoder = new TextDecoder('utf-8');
      let contents = decoder.decode(await fileP.read());

      var parser = new DOMParser();
      var doc = parser.parseFromString(
        contents,
        "text/xml"
      );
Assignee: nobody → ajvincent

Hi Hsin-Yi-

I'm needinfo-ing you because I wasn't sure who to ask about this, and you are on Triage for "DOM: Core & HTML". I wanted to make sure that changing out DOMParser::parseFromStream for the solution in Comment 4 isn't going to have any unexpected side effects for us. Does this seem reasonable? Are there any cases we will need to handle differently?

Thanks!

Flags: needinfo?(htsai)
Blocks: 1642043

AFAICT, comment 4 should work albeit in theory a bit less efficiently than using XHR in the "document" mode. (I haven't tested if XHR with local files works from chrome.)

(Comment 6 seemed to answer the NIed question, thank you Henri)

Flags: needinfo?(htsai)
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.