Bug 1154847, Add DAMP test for stepping in the debugger, r?bgrins
--- a/testing/talos/talos/tests/devtools/addon/content/damp.html
+++ b/testing/talos/talos/tests/devtools/addon/content/damp.html
@@ -12,27 +12,29 @@ var defaultConfig = {
subtests: {
webconsoleOpen: true,
inspectorOpen: true,
debuggerOpen: true,
styleEditorOpen: true,
performanceOpen: true,
netmonitorOpen: true,
saveAndReadHeapSnapshot: true,
+ debuggerStepping: true
}
};
var testsInfo = {
webconsoleOpen: "Measure open/close toolbox on webconsole panel",
inspectorOpen: "Measure open/close toolbox on inspector panel",
debuggerOpen: "Measure open/close toolbox on debugger panel",
styleEditorOpen: "Measure open/close toolbox on style editor panel",
performanceOpen: "Measure open/close toolbox on performance panel",
netmonitorOpen: "Measure open/close toolbox on network monitor panel",
saveAndReadHeapSnapshot: "Measure open/close toolbox on memory panel and save/read heap snapshot",
+ debuggerStepping: "Measure performance while stepping in complex scripts"
};
function updateConfig() {
config = {subtests: []};
for (var test in defaultConfig.subtests) {
if ($("subtest-" + test).checked) {
config.subtests.push(test);
}
@@ -53,16 +55,17 @@ function updateConfig() {
<div id="hide-during-run">
Visit <a href="https://wiki.mozilla.org/Buildbot/Talos/Tests#DAMP">talos/TART</a> for detailed info.<br/>
<ul>
<li><b>If you just opened the browser</b> - give Firefox few seconds to settle down before testing.</li>
</ul>
Utilities:
<a href="pages/simple.html">simple page</a>
+ <a href="pages/stepping.html">stepping page</a>
<a href="http://localhost/tests/tp5n/bild.de/www.bild.de/index.html">complicated page</a>
<br/><br/>
<b>Configure DAMP</b> (CTRL-F5 to reset to talos defaults) <button type="button" onclick="deselectAll()">Deselect all tests</button><br/>
<script>
for (var test in defaultConfig.subtests) {
document.write('<input type="checkbox" id="subtest-' + test + '" ' + (defaultConfig.subtests[test] ? "" : "un") + 'checked>'
+ test + '</input>'
+ '<span style="color:grey"> ' + testsInfo[test] + '</span>'
--- a/testing/talos/talos/tests/devtools/addon/content/damp.js
+++ b/testing/talos/talos/tests/devtools/addon/content/damp.js
@@ -7,16 +7,17 @@ const { getActiveTab } = devtools.requir
const { getMostRecentBrowserWindow } = devtools.require("sdk/window/utils");
const ThreadSafeChromeUtils = devtools.require("ThreadSafeChromeUtils");
const {Task} = Cu.import("resource://gre/modules/Task.jsm", {});
const webserver = Services.prefs.getCharPref("addon.test.damp.webserver");
const SIMPLE_URL = "chrome://damp/content/pages/simple.html";
const COMPLICATED_URL = webserver + "/tests/tp5n/bild.de/www.bild.de/index.html";
+const STEPPING_URL = "chrome://damp/content/pages/stepping.html";
function Damp() {
// Path to the temp file where the heap snapshot file is saved. Set by
// saveHeapSnapshot and read by readHeapSnapshot.
this._heapSnapshotFilePath = null;
// HeapSnapshot instance. Set by readHeapSnapshot, used by takeCensus.
this._snapshot = null;
}
@@ -139,16 +140,52 @@ Damp.prototype = {
this._results.push({
name: label + ".takeCensus",
value: end - start
});
return Promise.resolve();
},
+ _getDebuggerSteppingTest: Task.async(function*() {
+ yield this.testSetup(STEPPING_URL);
+ let toolbox = yield this.openToolbox(null, "jsdebugger");
+ let stepCounter = 50;
+ let panelWin = toolbox.getPanel("jsdebugger").panelWin;
+ let gStepInbutton = panelWin.document.getElementById("step-in");
+ // Pause the page by clicking a button that triggers a debugger; statement.
+ // Doing it through jsterm.execute() because it's pausing *this* thread too otherwise.
+ yield toolbox.openSplitConsole();
+ setTimeout(() => {
+ let cmd = 'document.getElementById("start").click();';
+ toolbox.getPanel("webconsole").hud.jsterm.execute(cmd);
+ },0);
+ // now we need to wait until the debugger stopped
+ yield new Promise(resolve => {
+ panelWin.gThreadClient.addOneTimeListener("paused", resolve);
+ });
+
+ let start = performance.now();
+ for(let i = 0; i < stepCounter; i++) {
+ setTimeout(() => {gStepInbutton.click();}, 0);
+ yield new Promise( resolve => {
+ panelWin.gThreadClient.addOneTimeListener("paused", resolve);
+ });
+ }
+ let end = performance.now();
+ // Return "average milliseconds taken per 'step into' command"
+ this._results.push({
+ name: "debuggerstep",
+ value: ( end - start ) / stepCounter
+ });
+
+ yield this.closeToolbox(null);
+ yield this.testTeardown();
+ }),
+
_getToolLoadingTests: function(url, label) {
let subtests = {
webconsoleOpen: Task.async(function*() {
yield this.testSetup(url);
yield this.openToolbox(label + ".webconsole", "webconsole");
yield this.reloadPage(label + ".webconsole");
yield this.closeToolbox(label + ".webconsole");
yield this.testTeardown();
@@ -321,11 +358,12 @@ Damp.prototype = {
this._dampTab = this._win.gBrowser.selectedTab;
this._win.gBrowser.selectedBrowser.focus(); // Unfocus the URL bar to avoid caret blink
Profiler.mark("DAMP - start", true);
let tests = [];
tests = tests.concat(this._getToolLoadingTests(SIMPLE_URL, "simple"));
tests = tests.concat(this._getToolLoadingTests(COMPLICATED_URL, "complicated"));
+ tests = tests.concat(this._getDebuggerSteppingTest);
this._doSequence(tests, this._doneInternal);
}
}
new file mode 100644
--- /dev/null
+++ b/testing/talos/talos/tests/devtools/addon/content/pages/stepping.html
@@ -0,0 +1,50 @@
+<!-- Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ -->
+<!doctype html>
+
+<html>
+ <head>
+ <meta charset="utf-8"/>
+ <title>Debugger test page</title>
+ </head>
+
+ <body>
+ <button id="start">Start!</button>
+
+ <script type="text/javascript">
+ function normal(aArg) {
+ var r = 10;
+ var a = squareAndOne(r);
+ var b = squareUntil(r, 99999999999); //recurses 3 times, returns on 4th call
+ var c = addUntil(r, 5, 1050); // recurses 208 times and returns on the 209th call
+ return a + b + c;
+
+ }
+
+ function squareAndOne(arg){
+ return (arg * arg) + 1;
+ }
+ function squareUntil(arg, limit){
+ if(arg * arg >= limit){
+ return arg * arg;
+ }else{
+ return squareUntil(arg * arg, limit);
+ }
+ }
+
+ function addUntil(arg1, arg2, limit){
+ if(arg1 + arg2 > limit){
+ return arg1 + arg2;
+ }else{
+ if(arg1 === 950) debugger;
+ return addUntil(arg1 + arg2, arg2, limit);
+ }
+ }
+
+ var normalBtn = document.getElementById("start");
+ normalBtn.addEventListener("click", normal, false);
+
+ </script>
+ </body>
+
+</html>