mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
8bea8e6d63
--HG-- extra : rebase_source : d97be65ec4c033f5eca37bc0b6f94979398fcf02
42 lines
1.2 KiB
JavaScript
42 lines
1.2 KiB
JavaScript
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
importScripts("resource://gre/modules/osfile.jsm");
|
|
|
|
function log(message) {
|
|
dump("WebManagerWorker " + message + "\n");
|
|
}
|
|
|
|
onmessage = function(event) {
|
|
let { url, path } = event.data;
|
|
|
|
let file = OS.File.open(path, { truncate: true });
|
|
let request = new XMLHttpRequest({ mozSystem: true });
|
|
|
|
request.open("GET", url, true);
|
|
request.responseType = "moz-chunked-arraybuffer";
|
|
|
|
request.onprogress = function(event) {
|
|
log("onprogress: received " + request.response.byteLength + " bytes");
|
|
let bytesWritten = file.write(new Uint8Array(request.response));
|
|
log("onprogress: wrote " + bytesWritten + " bytes");
|
|
};
|
|
|
|
request.onreadystatechange = function(event) {
|
|
log("onreadystatechange: " + request.readyState);
|
|
|
|
if (request.readyState == 4) {
|
|
file.close();
|
|
|
|
if (request.status == 200 || request.status == 0) {
|
|
postMessage({ type: "success" });
|
|
} else {
|
|
postMessage({ type: "failure", message: request.statusText });
|
|
}
|
|
}
|
|
};
|
|
|
|
request.send(null);
|
|
}
|