/[jscoverage]/trunk/jscoverage.jsm
ViewVC logotype

Diff of /trunk/jscoverage.jsm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 439 by siliconforks, Sun Jul 12 05:52:40 2009 UTC revision 505 by siliconforks, Sat Jan 2 04:55:54 2010 UTC
# Line 1  Line 1 
1  /*  /*
2      jscoverage.jsm - Firefox module      jscoverage.jsm - Firefox module
3      Copyright (C) 2008, 2009 siliconforks.com      Copyright (C) 2008, 2009, 2010 siliconforks.com
4    
5      This program is free software; you can redistribute it and/or modify      This program is free software; you can redistribute it and/or modify
6      it under the terms of the GNU General Public License as published by      it under the terms of the GNU General Public License as published by
# Line 52  Line 52 
52    
53  var JSCoverageUtils = {  var JSCoverageUtils = {
54    QueryInterface: function (aIID) {    QueryInterface: function (aIID) {
55      if (! aIID.equals(nsIObserver) && ! aIID.equals(nsISupports)) {      const Cc = Components.classes;
56        const Ci = Components.interfaces;
57    
58        if (! aIID.equals(Ci.nsIObserver) && ! aIID.equals(Ci.nsISupports)) {
59        throw Components.results.NS_ERROR_NO_INTERFACE;        throw Components.results.NS_ERROR_NO_INTERFACE;
60      }      }
61      return this;      return this;
62    },    },
63    
64      getReportDirectory: function() {
65        const Cc = Components.classes;
66        const Ci = Components.interfaces;
67    
68        var directoryService = Cc['@mozilla.org/file/directory_service;1'].getService(Ci.nsIProperties);
69        /*
70        CurProcD - directory in which the firefox process was started
71        CurWorkD - current working directory
72        Home - home directory
73        TmpD - temp directory
74        See xpcom/io/nsDirectoryServiceDefs.h
75        */
76        var reportDirectory = directoryService.get('CurProcD', Ci.nsILocalFile);
77        reportDirectory.appendRelativePath('jscoverage-report');
78        return reportDirectory;
79      },
80    
81    readExistingCoverage: function() {    readExistingCoverage: function() {
82      try {      try {
83        const Cc = Components.classes;        const Cc = Components.classes;
84        const Ci = Components.interfaces;        const Ci = Components.interfaces;
85    
86        var directoryService = Cc['@mozilla.org/file/directory_service;1'].getService(Ci.nsIProperties);        var reportDirectory = this.getReportDirectory();
       var reportDirectory = directoryService.get('CurWorkD', Ci.nsILocalFile);  
       reportDirectory.appendRelativePath('jscoverage-report');  
87        if (! reportDirectory.exists()) {        if (! reportDirectory.exists()) {
88          return;          return;
89        }        }
# Line 111  Line 129 
129        const Cc = Components.classes;        const Cc = Components.classes;
130        const Ci = Components.interfaces;        const Ci = Components.interfaces;
131    
132        var directoryService = Cc['@mozilla.org/file/directory_service;1'].getService(Ci.nsIProperties);        var reportDirectory = this.getReportDirectory();
       var reportDirectory = directoryService.get('CurWorkD', Ci.nsILocalFile);  
       reportDirectory.appendRelativePath('jscoverage-report');  
133        if (! reportDirectory.exists()) {        if (! reportDirectory.exists()) {
134          reportDirectory.create(Ci.nsIFile.DIRECTORY_TYPE, 0755);          reportDirectory.create(Ci.nsIFile.DIRECTORY_TYPE, 0755);
135        }        }
# Line 228  Line 244 
244    const Cc = Components.classes;    const Cc = Components.classes;
245    const Ci = Components.interfaces;    const Ci = Components.interfaces;
246    const jscoverage_observerService = Cc['@mozilla.org/observer-service;1'].getService(Ci.nsIObserverService);    const jscoverage_observerService = Cc['@mozilla.org/observer-service;1'].getService(Ci.nsIObserverService);
247      // 'xpcom-shutdown' works under xpcshell
248      // jscoverage_observerService.addObserver(JSCoverageUtils, 'quit-application', false);
249    jscoverage_observerService.addObserver(JSCoverageUtils, 'xpcom-shutdown', false);    jscoverage_observerService.addObserver(JSCoverageUtils, 'xpcom-shutdown', false);
250    
251    dump('jscoverage.jsm: initialized\n');    dump('jscoverage.jsm: initialized\n');

Legend:
Removed from v.439  
changed lines
  Added in v.505

  ViewVC Help
Powered by ViewVC 1.1.24