Created
September 14, 2011 16:46
-
-
Save neonux/1217064 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function coverage(aDump) | |
{ | |
return []; | |
} | |
function aggregate(aOriginalStats, aNewStats, aUpdate) | |
{ | |
// aUpdate(aScript, aLine) is called for every line that changed since aOriginalStats | |
} |
Author
neonux
commented
Sep 14, 2011
via email
On Wed, Sep 14, 2011 at 10:50, David Flanagan ***@***.*** wrote:
```
var coverage = new Coverage();
```
addListener({
onNewScript,
onScriptUpdate,
onLineUpdate,
}
file.lines.forEach(function(line) {
var linenum = line.linenum; // line number in filename
var coverage = line.coverage; // One of the strings
// "full", "some", "none", "dead"
var counts = line.counts; // An array of numbers
named counts:
{
execCount:
}
function lineUpdateCallback(filename, linenum, coverage, count) {
function lineUpdateCallback(script, lineObject) {
You can probably use this snippet we use in several devtools for listener stuff:
/**
- Add a listener for StyleEditorChrome events.
*
- The listener implements IStyleEditorChromeListener := {
- onContentAttach: Called when a content window has been attached.
- All editors are instantiated, though they might
- not be loaded yet.
- Arguments: (StyleEditorChrome aChrome)
- @see contentWindow
- @see StyleEditor.isLoaded
- @see StyleEditor.addActionListener
*
- onContentDetach: Called when the content window has been detached.
- Arguments: (StyleEditorChrome aChrome)
- @see contentWindow
*
- onEditorAdded: Called when a stylesheet (therefore a StyleEditor
- instance) has been added to the UI.
- Arguments (StyleEditorChrome aChrome,
- StyleEditor aEditor)
- }
*
- All listener methods are optional.
*
- @param IStyleEditorChromeListener aListener
- @see removeChromeListener
*/
addChromeListener: function SEC_addChromeListener(aListener)
{
this._listeners.push(aListener);
},
/**
- Remove a listener for Chrome events from the current list of listeners.
*
- @param IStyleEditorChromeListener aListener
- @see addChromeListener
*/
removeChromeListener: function SEC_removeChromeListener(aListener)
{
let index = this._listeners.indexOf(aListener);
if (index != -1) {
this._listeners.splice(index, 1);
}
},
/**
- Trigger named handlers in StyleEditorChrome listeners.
*
- @param string aName
- Name of the event to trigger.
- @param Array aArgs
- Optional array of arguments to pass to the listener(s).
- @see addActionListener
*/
_triggerChromeListeners: function SE__triggerChromeListeners(aName, aArgs)
{
// insert the origin Chrome instance as first argument
if (!aArgs) {
aArgs = [this];
} else {
aArgs.unshift(this);
}
// trigger all listeners that have this named handler
for (let i = 0; i < this._listeners.length; ++i) {
let listener = this._listeners[i];
let handler = listener["on" + aName];
if (handler) {
handler.apply(listener, aArgs);
}
}
},
…On Wed, Sep 14, 2011 at 12:33, Cedric Vivier ***@***.*** wrote:
On Wed, Sep 14, 2011 at 10:50, David Flanagan
***@***.***
wrote:
> ```
> var coverage = new Coverage();
> ```
addListener({
onNewScript,
onScriptUpdate,
onLineUpdate,
}
> file.lines.forEach(function(line) {
> var linenum = line.linenum; // line number in filename
> var coverage = line.coverage; // One of the strings
> // "full", "some", "none", "dead"
> var counts = line.counts; // An array of numbers
named counts:
{
execCount:
}
> function lineUpdateCallback(filename, linenum, coverage, count) {
function lineUpdateCallback(script, lineObject) {
load("Coverage.js")
var coverage = new Coverage();
coverage.addListener({
onNewScript: function(filename, filedata) {
print("New file: " + filename);
print(JSON.stringify(filedata));
},
onScriptUpdate: function(filename, filedata) {
print("File updated: " + filename);
print("covered: " + filedata.covered);
print("partial: " + filedata.partial);
print("uncovered: " + filedata.uncovered);
print("dead: " + filedata.dead);
},
onLineUpdate: function(filename, linedata) {
print("Line updated: " + filename + ":" + linedata.linenum);
print(linedata.counts);
}
});
coverage.parseData(snarf("test.dis1"));
coverage.parseData(snarf("test.dis2"));
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment