2010-10-11 09:57:56 -07:00
|
|
|
/* vim:set ts=2 sw=2 sts=2 et: */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-10-11 09:57:56 -07:00
|
|
|
|
|
|
|
// Tests that console groups behave properly.
|
|
|
|
|
2012-04-15 13:10:00 -07:00
|
|
|
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html";
|
2010-10-11 09:57:56 -07:00
|
|
|
|
|
|
|
function test() {
|
|
|
|
addTab(TEST_URI);
|
2012-05-31 03:30:56 -07:00
|
|
|
browser.addEventListener("load", function onLoad() {
|
|
|
|
browser.removeEventListener("load", onLoad, true);
|
|
|
|
openConsole(null, testGroups);
|
|
|
|
}, true);
|
2010-10-11 09:57:56 -07:00
|
|
|
}
|
|
|
|
|
2012-05-31 03:30:56 -07:00
|
|
|
function testGroups(HUD) {
|
2010-10-11 09:57:56 -07:00
|
|
|
let jsterm = HUD.jsterm;
|
2012-05-31 03:30:56 -07:00
|
|
|
let outputNode = HUD.outputNode;
|
2012-06-02 03:45:32 -07:00
|
|
|
jsterm.clearOutput();
|
2010-10-11 09:57:56 -07:00
|
|
|
|
2010-12-23 07:59:19 -08:00
|
|
|
// We test for one group by testing for zero "new" groups. The
|
|
|
|
// "webconsole-new-group" class creates a divider. Thus one group is
|
|
|
|
// indicated by zero new groups, two groups are indicated by one new group,
|
|
|
|
// and so on.
|
|
|
|
|
2012-06-02 03:45:32 -07:00
|
|
|
let waitForSecondMessage = {
|
|
|
|
name: "second console message",
|
|
|
|
validatorFn: function()
|
|
|
|
{
|
|
|
|
return outputNode.querySelectorAll(".webconsole-msg-output").length == 2;
|
|
|
|
},
|
|
|
|
successFn: function()
|
|
|
|
{
|
|
|
|
let timestamp1 = Date.now();
|
|
|
|
if (timestamp1 - timestamp0 < 5000) {
|
|
|
|
is(outputNode.querySelectorAll(".webconsole-new-group").length, 0,
|
|
|
|
"no group dividers exist after the second console message");
|
|
|
|
}
|
2010-10-11 09:57:56 -07:00
|
|
|
|
2012-06-02 03:45:32 -07:00
|
|
|
for (let i = 0; i < outputNode.itemCount; i++) {
|
|
|
|
outputNode.getItemAtIndex(i).timestamp = 0; // a "far past" value
|
|
|
|
}
|
2010-12-23 07:59:19 -08:00
|
|
|
|
2012-06-02 03:45:32 -07:00
|
|
|
jsterm.execute("2");
|
|
|
|
waitForSuccess(waitForThirdMessage);
|
|
|
|
},
|
|
|
|
failureFn: finishTest,
|
|
|
|
};
|
2010-10-11 09:57:56 -07:00
|
|
|
|
2012-06-02 03:45:32 -07:00
|
|
|
let waitForThirdMessage = {
|
|
|
|
name: "one group divider exists after the third console message",
|
|
|
|
validatorFn: function()
|
|
|
|
{
|
|
|
|
return outputNode.querySelectorAll(".webconsole-new-group").length == 1;
|
|
|
|
},
|
|
|
|
successFn: finishTest,
|
|
|
|
failureFn: finishTest,
|
|
|
|
};
|
2010-10-11 09:57:56 -07:00
|
|
|
|
2012-06-02 03:45:32 -07:00
|
|
|
let timestamp0 = Date.now();
|
|
|
|
jsterm.execute("0");
|
2010-10-11 09:57:56 -07:00
|
|
|
|
2012-06-02 03:45:32 -07:00
|
|
|
waitForSuccess({
|
|
|
|
name: "no group dividers exist after the first console message",
|
|
|
|
validatorFn: function()
|
|
|
|
{
|
|
|
|
return outputNode.querySelectorAll(".webconsole-new-group").length == 0;
|
|
|
|
},
|
|
|
|
successFn: function()
|
|
|
|
{
|
|
|
|
jsterm.execute("1");
|
|
|
|
waitForSuccess(waitForSecondMessage);
|
|
|
|
},
|
|
|
|
failureFn: finishTest,
|
|
|
|
});
|
|
|
|
}
|