venkman-service.js
来自「proe5.0野火版下载(中文版免费下载)」· JavaScript 代码 · 共 565 行 · 第 1/2 页
JS
565 行
JSDChannel.prototype.loadGroup = null;JSDChannel.prototype.notificationCallbacks = null;JSDChannel.prototype.securityInfo = null;JSDChannel.prototype.open =function jsdch_open(){ throw Components.results.NS_ERROR_NOT_IMPLEMENTED;}JSDChannel.prototype.asyncOpen =function jsdch_aopen (streamListener, context){ this.streamListener = streamListener; this.context = context; if (!window && this.URI.spec == "x-jsd:debugger") { this.contentType = "x-application-jsd"; this.contentLength = 0; streamListener.onStartRequest(this, context); return; } var window = findDebuggerWindow(); var ary = this.URI.spec.match (/x-jsd:([^:]+)/); var exception; if (this.loadGroup) this.loadGroup.addRequest (this, null); if (window && "console" in window && ary) { try { window.asyncOpenJSDURL (this, streamListener, context); return; } catch (ex) { exception = ex; } } var str = "<html><head><title>Error</title></head><body>Could not load <<b>" + safeHTML(this.URI.spec) + "</b>><br>"; if (!ary) { str += "<b>Error parsing uri.</b>"; } else if (exception) { str += "<b>Internal error: " + safeHTML(exception) + "</b><br><pre>" + safeHTML(exception.stack); } else { str += "<b>Debugger is not running.</b>"; } str += "</body></html>"; this.respond (str);}JSDChannel.prototype.respond =function jsdch_respond (str){ this.streamListener.onStartRequest (this, this.context); var len = str.length; this.stringStream.setData (str, len); this.streamListener.onDataAvailable (this, this.context, this.stringStream, 0, len); this.streamListener.onStopRequest (this, this.context, Components.results.NS_OK); if (this.loadGroup) this.loadGroup.removeRequest (this, null, Components.results.NS_OK); this._isPending = false; }/* nsIRequest */JSDChannel.prototype.isPending =function jsdch_ispending (){ return this._isPending;}JSDChannel.prototype.status = Components.results.NS_OK;JSDChannel.prototype.cancel =function jsdch_cancel (status){ if (this._isPending) { this._isPending = false; this.streamListener.onStopRequest (this, this.context, status); if (this.loadGroup) { try { this.loadGroup.removeRequest (this, null, status); } catch (ex) { debug ("we're not in the load group?\n"); } } } this.status = status;}JSDChannel.prototype.suspend =JSDChannel.prototype.resume =function jsdch_notimpl (){ throw Components.results.NS_ERROR_NOT_IMPLEMENTED;}/*****************************************************************************//* x-application-jsd content handler */function JSDContentHandler (){}JSDContentHandler.prototype.QueryInterface =function jsdh_qi(iid){ if (!iid.equals(nsIContentHandler) && !iid.equals(nsISupports)) throw Components.results.NS_ERROR_NO_INTERFACE; return this;}JSDContentHandler.prototype.handleContent =function jsdh_handle(contentType, windowTarget, request){ var e; var channel = request.QueryInterface(nsIChannel); // prevent someone from invoking the debugger remotely by serving // up any old file with the x-application-jsd content type. if (channel.URI.spec != "x-jsd:debugger") { debug ("Not handling content from unknown location ``" + channel.URI.spec + "''"); return; } var window = findDebuggerWindow() if (window) { window.focus(); } else { var ass = Components.classes[ASS_CONTRACTID].getService(nsIAppShellService); window = ass.hiddenDOMWindow; var args = new Object(); args.url = channel.URI.spec; window.openDialog("chrome://venkman/content/venkman.xul", "_blank", "chrome,menubar,toolbar,resizable,dialog=no", args); }}/*****************************************************************************//* content handler factory object (IRCContentHandler) */var JSDContentHandlerFactory = new Object();JSDContentHandlerFactory.createInstance =function jsdhf_create(outer, iid){ if (outer != null) throw Components.results.NS_ERROR_NO_AGGREGATION; if (!iid.equals(nsIContentHandler) && !iid.equals(nsISupports)) throw Components.results.NS_ERROR_INVALID_ARG; return new JSDContentHandler();}/*****************************************************************************/var Module = new Object();Module.registerSelf =function (compMgr, fileSpec, location, type){ debug("*** Registering -venkman handler.\n"); compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar); compMgr.registerFactoryLocation(CLINE_SERVICE_CID, "Venkman CommandLine Service", CLINE_SERVICE_CTRID, fileSpec, location, type); catman = Components.classes[CATMAN_CTRID].getService(nsICategoryManager); catman.addCategoryEntry("command-line-argument-handlers", "venkman command line handler", CLINE_SERVICE_CTRID, true, true); debug("*** Registering x-jsd protocol handler.\n"); compMgr.registerFactoryLocation(JSDPROT_HANDLER_CID, "x-jsd protocol handler", JSDPROT_HANDLER_CTRID, fileSpec, location, type); debug("*** Registering x-application-jsd content handler.\n"); compMgr.registerFactoryLocation(JSDCNT_HANDLER_CID, "x-application-jsd content handler", JSDCNT_HANDLER_CTRID, fileSpec, location, type); try { const JSD_CTRID = "@mozilla.org/js/jsd/debugger-service;1"; const jsdIDebuggerService = Components.interfaces.jsdIDebuggerService; var jsds = Components.classes[JSD_CTRID].getService(jsdIDebuggerService); jsds.initAtStartup = true; } catch (ex) { debug ("*** ERROR initializing debugger service"); debug (ex); }}Module.unregisterSelf =function(compMgr, fileSpec, location){ compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar); compMgr.unregisterFactoryLocation(CLINE_SERVICE_CID, fileSpec); catman = Components.classes[CATMAN_CTRID].getService(nsICategoryManager); catman.deleteCategoryEntry("command-line-argument-handlers", CLINE_SERVICE_CTRID, true);}Module.getClassObject =function (compMgr, cid, iid) { if (cid.equals(CLINE_SERVICE_CID)) return CLineFactory; if (cid.equals(JSDPROT_HANDLER_CID)) return JSDProtocolHandlerFactory; if (cid.equals(JSDCNT_HANDLER_CID)) return JSDContentHandlerFactory; if (!iid.equals(Components.interfaces.nsIFactory)) throw Components.results.NS_ERROR_NOT_IMPLEMENTED; throw Components.results.NS_ERROR_NO_INTERFACE; }Module.canUnload =function(compMgr){ return true;}/* entrypoint */function NSGetModule(compMgr, fileSpec) { return Module;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?