rendered paste bodyfunction test_get() { //plugin.installPlugin(''); var data = {}; var e = {}; e.name = "tmp.pdf"; e.source = "http://the-erm.com/591-096811-007A.pdf"; var pluginDownloader = { onStartRequest: function(req, c) { var ary = e.source.match(/([^\/]+?)((\..{0,3}){0,2})$/); data.of = plugin.getTempFile((ary ? ary[2] : undefined)); data.ofH = fopen(data.of, ">"); }, onDataAvailable: function(req, ctx, s, o, c) { if (!data.is) data.is = toSInputStream(s, true); data.ofH.write(data.is.readBytes(c)); }, onStopRequest: function(req, ctx, code) { data.ofH.close(); if (code == 0) { if (getPluginById("plugin-install")) dispatch("disable-plugin plugin-install"); plugin.doInstall(e.name, data.of, e.destination); if (getPluginById("plugin-install")) dispatch("enable-plugin plugin-install"); } else { display("Error downloading: " + code, MT_ERROR); } try { data.outFile.remove(false); } catch(e) {} } }; try { const ioSvc = getService("@mozilla.org/network/io-service;1", "nsIIOService"); var channel = ioSvc.newChannel(e.source, "UTF-8", null); display("Downloading from '" + e.source + "'...", MT_INFO); channel.asyncOpen(pluginDownloader, null); } catch (ex) { alert("Error downloading: "); return; } }