Permalink
Browse files

Merging

  • Loading branch information...
Nicholas C. Zakas
Nicholas C. Zakas committed Apr 4, 2009
2 parents 5957a60 + 9429805 commit 82f2bfc1097795cd7b16bfbbba773553f96a514f
View
470 LICENSE

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -380,6 +380,49 @@ FBL.ns(function() { with (FBL) {
if ( typeof id == "string" && canChrome(win) )
return document.getElementById( id );
},
+
+ getProfile: function() {
+ var ret = { time: 0, calls: 0, data: [] };
+ var table = context.getPanel("console").panelNode
+ .getElementsByClassName("profileSizer");
+ table = table[table.length - 1].parentNode.parentNode;
+
+ var time = table.getElementsByClassName("profileTime")[0].textContent
+ .match(/([\d.]+)ms, (\d+) call/);
+
+ ret.time = parseFloat(time[1]);
+ ret.calls = parseFloat(time[2]);
+
+ var rows = table.getElementsByTagName("tr");
+ for ( var i = 1; i < rows.length; i++ ) {
+ var row = rows[i];
+ ret.data.push({
+ name: row.childNodes[0].textContent,
+ calls: parseFloat(row.childNodes[1].textContent),
+ percent: parseFloat(row.childNodes[2].textContent),
+ ownTime: parseFloat(row.childNodes[3].textContent),
+ time: parseFloat(row.childNodes[4].textContent),
+ avgTime: parseFloat(row.childNodes[5].textContent),
+ minTime: parseFloat(row.childNodes[6].textContent),
+ maxTime: parseFloat(row.childNodes[7].textContent),
+ fileName: row.childNodes[8].textContent
+ });
+ }
+
+ return ret;
+ },
+
+ profile: function( fn ) {
+ win.console.profile();
+ win.__profile = fn;
+ try {
+ win.__profile();
+ } finally {
+ win.console.profileEnd();
+ delete win.__profile;
+ return this.getProfile();
+ }
+ },
/*
* Tests that a condition is true and outputs the results.
@@ -399,6 +442,20 @@ FBL.ns(function() { with (FBL) {
panel.appendResults([result]);
}
},
+
+ /*
+ * Inserts a log message
+ * @param {String} msg The message to display.
+ */
+ log: function( msg ) {
+ var result = new Firebug.FireUnitModule.TestResult(win, undefined, msg, undefined, undefined, true);
+ if ( testQueue ) {
+ queueResults.push(result);
+ } else {
+ var panel = context.getPanel(panelName);
+ panel.appendResults([result]);
+ }
+ },
/*
* Compares two strings to see if they are the same. If they are,
@@ -624,14 +681,16 @@ FBL.ns(function() { with (FBL) {
if (FBTrace.DBG_FIREUNIT)
FBTrace.sysout("fireunit.FireUnitPanel.updateOption: " + name + ": " + value);
- if (name == "fireunit.showPass" || name == "fireunit.showFail")
+
+ if (name == "fireunit.showPass" || name == "fireunit.showFail" || name == "fireunit.showLog" )
this.updatePanelFilter();
},
updatePanelFilter: function()
{
var showPass = Firebug.getPref(Firebug.prefDomain, "fireunit.showPass");
var showFail = Firebug.getPref(Firebug.prefDomain, "fireunit.showFail");
+ var showLog = Firebug.getPref(Firebug.prefDomain, "fireunit.showLog");
// Update styles on the root table (contains the list of results).
// These styles ensure proper visibility of pass and fail tests according
@@ -640,13 +699,15 @@ FBL.ns(function() { with (FBL) {
var table = getElementByClass(panelNode, "testTable");
showPass ? setClass(table, "showPass") : removeClass(table, "showPass");
showFail ? setClass(table, "showFail") : removeClass(table, "showFail");
+ showLog ? setClass(table, "showLog") : removeClass(table, "showLog");
},
getOptionsMenuItems: function(context)
{
var items = [];
items.push(this.optionMenu($FU_STR("fireunit.option.Passing Tests"), "fireunit.showPass"));
items.push(this.optionMenu($FU_STR("fireunit.option.Failing Tests"), "fireunit.showFail"));
+ items.push(this.optionMenu($FU_STR("fireunit.option.Log"), "fireunit.showLog"));
items.push("-");
items.push({
label: $FU_STR("fireunit.option.Enable Privileges"),
@@ -701,7 +762,7 @@ FBL.ns(function() { with (FBL) {
var summary = { passing: 0, failing: 0 };
for (var row = tbody.firstChild; row; row = row.nextSibling) {
if (hasClass(row, "testResultRow"))
- hasClass(row, "testError") ? summary.failing++ : summary.passing++;
+ hasClass(row, "testError") ? summary.failing++ : hasClass(row, "testOK") ? summary.passing++ : true;
}
// Append summary row.
@@ -734,7 +795,8 @@ FBL.ns(function() { with (FBL) {
FOR("result", "$results",
TR({"class": "testResultRow", _repObject: "$result",
$testError: "$result|isError",
- $testOK: "$result|isOK"},
+ $testOK: "$result|isOK",
+ $testLog: "$result|isLog"},
TD({"class": "testResultCol", width: "100%"},
DIV({"class": "testResultMessage testResultLabel"},
"$result|getMessage"
@@ -780,13 +842,18 @@ FBL.ns(function() { with (FBL) {
},
isError: function(result)
- {
- return !result.pass;
+ { // result.log takes precedence
+ return !result.log && !result.pass;
},
isOK: function(result)
+ { // result.log takes precedence
+ return !result.log && result.pass;
+ },
+
+ isLog: function(result)
{
- return result.pass;
+ return result.log;
},
summaryPassed: function(summary)
@@ -1223,12 +1290,14 @@ FBL.ns(function() { with (FBL) {
/**
* This object represents a test-result.
*/
- Firebug.FireUnitModule.TestResult = function(win, pass, msg, expected, result)
+ Firebug.FireUnitModule.TestResult = function(win, pass, msg, expected, result, log)
{
var location = win.location.href;
this.fileName = location.substr(location.lastIndexOf("/") + 1);
- this.pass = pass ? true : false;
+ this.pass = pass;
+ this.log = log;
+
this.msg = clean(msg);
this.expected = expected;
this.result = result;
@@ -1,18 +1,19 @@
-fireunit.panel.Test=Test
-fireunit.tab.Stack=Test Location
-fireunit.tab.Compare=Compare
-fireunit.title.Expected=Expected Result
-fireunit.title.Result=Actual Result
-fireunit.title.Difference=Difference
-fireunit.switch.view_source=view source
-fireunit.switch.pretty_print=pretty print
-fireunit.option.Passing_Tests=Passing Tests
-fireunit.option.Failing_Tests=Failing Tests
-fireunit.option.Enable_Privileges=Enable Privileges
-fireunit.item.View_Source=View Source
-fireunit.item.Copy=Copy
-fireunit.item.Copy_All=Copy All
-fireunit.test.Line=Line
-fireunit.label.Pass=Pass
-fireunit.label.Fail=Fail
-fireunit.label.Timeout=Timeout
+fireunit.panel.Test=Test
+fireunit.tab.Stack=Test Location
+fireunit.tab.Compare=Compare
+fireunit.title.Expected=Expected Result
+fireunit.title.Result=Actual Result
+fireunit.title.Difference=Difference
+fireunit.switch.view_source=view source
+fireunit.switch.pretty_print=pretty print
+fireunit.option.Passing_Tests=Passing Tests
+fireunit.option.Failing_Tests=Failing Tests
+fireunit.option.Log=Log
+fireunit.option.Enable_Privileges=Enable Privileges
+fireunit.item.View_Source=View Source
+fireunit.item.Copy=Copy
+fireunit.item.Copy_All=Copy All
+fireunit.test.Line=Line
+fireunit.label.Pass=Pass
+fireunit.label.Fail=Fail
+fireunit.label.Timeout=Timeout
@@ -94,6 +94,10 @@
display: table-row !important;
}
+.testTable.showLog .testResultRow.testLog {
+ display: table-row !important;
+}
+
.testTable.showPass .testResultRow.testOK {
display: table-row !important;
}
@@ -123,6 +127,11 @@
padding-left: 18px;
}
+.testResultRow.testLog
+{
+ color: Blue;
+}
+
.summaryPass.testResultSummaryLabel {
color: Green;
}
@@ -1,6 +1,7 @@
-pref("extensions.firebug.fireunit.showPass", true);
-pref("extensions.firebug.fireunit.showFail", true);
-pref("extensions.firebug.fireunit.testTimeout", 0); // Break timeout for stuck unit test. Disabled by default.
-
-// Support for tracing console
-pref("extensions.firebug.DBG_FIREUNIT", false);
+pref("extensions.firebug.fireunit.showPass", true);
+pref("extensions.firebug.fireunit.showFail", true);
+pref("extensions.firebug.fireunit.showLog", true);
+pref("extensions.firebug.fireunit.testTimeout", 0); // Break timeout for stuck unit test. Disabled by default.
+
+// Support for tracing console
+pref("extensions.firebug.DBG_FIREUNIT", false);
View
@@ -1,24 +1,24 @@
-<?xml version="1.0"?>
-
-<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:em="http://www.mozilla.org/2004/em-rdf#">
-
- <Description about="urn:mozilla:install-manifest">
- <em:id>fireunit@mozilla.com</em:id>
- <em:version>0.9</em:version>
-
- <!-- Firefox -->
- <em:targetApplication>
- <Description>
- <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
- <em:minVersion>2.0</em:minVersion>
- <em:maxVersion>3.1.*</em:maxVersion>
- </Description>
- </em:targetApplication>
-
- <em:name>FireUnit</em:name>
- <em:description>Firebug JavaScript Testing Extension</em:description>
- <em:creator>John Resig</em:creator>
- <em:homepageURL>http://fireunit.org/</em:homepageURL>
- </Description>
-</RDF>
+<?xml version="1.0"?>
+
+<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:em="http://www.mozilla.org/2004/em-rdf#">
+
+ <Description about="urn:mozilla:install-manifest">
+ <em:id>fireunit@mozilla.com</em:id>
+ <em:version>1.0a1</em:version>
+
+ <!-- Firefox -->
+ <em:targetApplication>
+ <Description>
+ <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
+ <em:minVersion>2.0</em:minVersion>
+ <em:maxVersion>3.1.*</em:maxVersion>
+ </Description>
+ </em:targetApplication>
+
+ <em:name>FireUnit</em:name>
+ <em:description>Firebug JavaScript Testing Extension</em:description>
+ <em:creator>John Resig</em:creator>
+ <em:homepageURL>http://fireunit.org/</em:homepageURL>
+ </Description>
+</RDF>

0 comments on commit 82f2bfc

Please sign in to comment.