Bug 1931425 - Limit how often moz-label's #setStyles runs r=reusable-components-revie...
[gecko.git] / netwerk / test / unit / test_bug263127.js
blob75dc6509808c1fa75266c9d5aaf7e55e00247da4
1 "use strict";
3 const { HttpServer } = ChromeUtils.importESModule(
4 "resource://testing-common/httpd.sys.mjs"
5 );
7 var server;
8 const BUGID = "263127";
10 var listener = {
11 QueryInterface: ChromeUtils.generateQI(["nsIDownloadObserver"]),
13 onDownloadComplete(downloader, request, status, file) {
14 do_test_pending();
15 server.stop(do_test_finished);
17 if (!file) {
18 do_throw("Download failed");
21 try {
22 file.remove(false);
23 } catch (e) {
24 do_throw(e);
27 Assert.ok(!file.exists());
29 do_test_finished();
33 function run_test() {
34 // start server
35 server = new HttpServer();
36 server.start(-1);
38 // Initialize downloader
39 var channel = NetUtil.newChannel({
40 uri: "http://localhost:" + server.identity.primaryPort + "/",
41 loadUsingSystemPrincipal: true,
42 });
43 var targetFile = Services.dirsvc.get("TmpD", Ci.nsIFile);
44 targetFile.append("bug" + BUGID + ".test");
45 if (targetFile.exists()) {
46 targetFile.remove(false);
49 var downloader = Cc["@mozilla.org/network/downloader;1"].createInstance(
50 Ci.nsIDownloader
52 downloader.init(listener, targetFile);
54 // Start download
55 channel.asyncOpen(downloader);
57 do_test_pending();