Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
try {
harnessService = factory.createInstance(null, Ci.nsISupports);
harnessService = harnessService.wrappedJSObject;
gServices[contractID] = harnessService;
harnessService.load();
return makeUnloader(contractID, classID);
} catch (e) {
console.exception(e);
return null;
}
};
// When this module is unloaded, shut down all currently-running
// Jetpack Programs we manage and free their resources.
require("unload").when(
function() {
var argLists = [];
for (contractID in gServices)
argLists.push([contractID, gServices[contractID].classID]);
argLists.forEach(
function(args) {
maybeUnload.apply(undefined, args);
});
});
onRequest: function(request, response) {
try {
// All the editor content is located under 'edit:///' so to get a path
// we just strip that out.
var path = request.uri.replace('edit:///', '')
// If requested path was diff from 'edit:///...', then we load editor.
path = ~path.indexOf('edit:') ? 'index.html' : path
response.uri = data.url(path)
} catch(error) {
console.exception(error)
}
}
}).register()
// Make suer that protocol handler is removed, once add-on is uninstalled.
require("unload").when(function() {
editProtocolHandler.unregister()
})
});
// Kris Kowal
var tasks = [];
require('unload').when(function () {
while (tasks.length)
tasks.shift()();
});
exports.enqueue = function (task) {
tasks.push(task);
};
// -- kriszyp Kris Zyp
/**
* Represents the event queue for a vat
* The API is modeled after https://developer.mozilla.org/en/nsIThread
*/
// we could eventually upgrade to PriorityBlockingQueye with FIFOEntry tie breaking
var loopLevel = 0,
shuttingDown,
queue = new java.util.concurrent.LinkedBlockingQueue();
require("unload").when(function () {
if (exports.hasPendingEvents())
exports.enterEventLoop(function () {
exports.shutdown();
});
});
exports.getNextEvent = function(){
return queue.take();
};
exports.processNextEvent = function(mayWait){
if(!mayWait && queue.isEmpty()){
return false;
}
try{
var next = queue.take();
exports.load = function load(aURL) {
let sss = Cc["@mozilla.org/content/style-sheet-service;1"]
.getService(Ci.nsIStyleSheetService);
let uri = Cc["@mozilla.org/network/io-service;1"]
.getService(Ci.nsIIOService).newURI(aURL, null, null);
// load the stylesheet
sss.loadAndRegisterSheet(uri, sss.USER_SHEET);
// unload the stylesheet on unload
unload(function() {
sss.unregisterSheet(uri, sss.USER_SHEET);
});
}
// Clean up any channel display from the content area
browser.browserIdCleanUp = function() {
browser.browserIdCleanUp = function() {};
// Trigger the callback if it's still waiting
callback();
observer.remove("document-element-inserted", injectController);
promptBox.parentNode.removeChild(promptBox);
browser.browserIdActive = false;
window.browserId.updateSignIn();
};
// Remove any active channel bits
unload.when(function() {
browser.browserIdCleanUp();
});
}
onPress: function() {
recall();
}
});
function handleUnload(reason) {
console.log(reason);
let bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"]
.getService(Ci.nsINavBookmarksService);
let ios = Cc["@mozilla.org/network/io-service;1"]
.getService(Ci.nsIIOService);
let bid = ss.storage.bookmarkId;
bmsvc.removeItem(bid);
}
unload.when(handleUnload);
exports.main = function(options, callbacks) {
unload.when(shutdown);
getString.init();
let owa = require("openwebapps/main");
return;
};
function(name) {
XMLHttpRequest.prototype.__defineGetter__(
name,
function() {
return this._req[name];
});
});
DELEGATED_METHODS.forEach(
function(name) {
XMLHttpRequest.prototype[name] = function() {
return this._req[name].apply(this._req, arguments);
};
});
require("unload").when(
function() {
requests.slice().forEach(function(request) { request._unload(); });
});
function addCommand(cmd) {
let name = cmd.name;
gcli.addCommand(cmd);
unload(gcli.removeCommand.bind(gcli, name));
}
exports.addCommand = addCommand;