Bug 961621 - Fix for intermittent browser_webconsole_bug_766001_JS_Console_in_Debugger.js | Timed out while waiting for: correct source and line test for debugger for index 2; r=me

This commit is contained in:
Mihai Sucan 2014-01-20 23:09:18 +02:00
Родитель 674a07993c
Коммит 25517b709e
3 изменённых файлов: 64 добавлений и 90 удалений

Просмотреть файл

@ -504,7 +504,10 @@ WebConsole.prototype = {
let showSource = ({ DebuggerView }) => {
if (DebuggerView.Sources.containsValue(aSourceURL)) {
DebuggerView.setEditorLocation(aSourceURL, aSourceLine, { noDebug: true });
DebuggerView.setEditorLocation(aSourceURL, aSourceLine,
{ noDebug: true }).then(() => {
this.ui.emit("source-in-debugger-opened");
});
return;
}
toolbox.selectTool("webconsole");

Просмотреть файл

@ -7,110 +7,67 @@
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test" +
"/test-bug-766001-js-console-links.html";
let nodes, dbg, toolbox, target, index = 0, src, line;
function test() {
let hud;
function test()
{
expectUncaughtException();
requestLongerTimeout(2);
addTab(TEST_URI);
browser.addEventListener("load", function onLoad() {
browser.removeEventListener("load", onLoad, true);
openConsole(null, testViewSource);
}, true);
}
Task.spawn(runner).then(finishTest);
function testViewSource(aHud)
{
registerCleanupFunction(function() {
nodes = dbg = toolbox = target = index = src = line = null;
});
function* runner() {
expectUncaughtException();
let {tab} = yield loadTab(TEST_URI);
hud = yield openConsole(tab);
let [exceptionRule, consoleRule] = yield waitForMessages({
webconsole: hud,
messages: [{
text: "document.bar",
category: CATEGORY_JS,
severity: SEVERITY_ERROR,
},
{
text: "Blah Blah",
category: CATEGORY_WEBDEV,
severity: SEVERITY_LOG,
}],
});
waitForMessages({
webconsole: aHud,
messages: [{
text: "document.bar",
category: CATEGORY_JS,
severity: SEVERITY_ERROR,
},
{
text: "Blah Blah",
category: CATEGORY_WEBDEV,
severity: SEVERITY_LOG,
}],
}).then(([exceptionRule, consoleRule]) => {
let exceptionMsg = [...exceptionRule.matched][0];
let consoleMsg = [...consoleRule.matched][0];
nodes = [exceptionMsg.querySelector(".location"),
consoleMsg.querySelector(".location")];
let nodes = [exceptionMsg.querySelector(".location"),
consoleMsg.querySelector(".location")];
ok(nodes[0], ".location node for the exception message");
ok(nodes[1], ".location node for the console message");
target = TargetFactory.forTab(gBrowser.selectedTab);
toolbox = gDevTools.getToolbox(target);
toolbox.once("jsdebugger-selected", checkLineAndClickNext);
for (let i = 0; i < nodes.length; i++) {
yield checkClickOnNode(i, nodes[i]);
yield gDevTools.showToolbox(hud.target, "webconsole");
}
EventUtils.sendMouseEvent({ type: "click" }, nodes[index%2]);
});
}
function checkLineAndClickNext(aEvent, aPanel)
{
if (index == 3) {
finishTest();
return;
// check again the first node.
yield checkClickOnNode(0, nodes[0]);
}
info(aEvent + " event fired for index " + index);
dbg = aPanel;
function* checkClickOnNode(index, node) {
info("checking click on node index " + index);
src = nodes[index%2].getAttribute("title");
ok(src, "source url found for index " + index);
line = nodes[index%2].sourceLine;
ok(line, "found source line for index " + index);
let url = node.getAttribute("title");
ok(url, "source url found for index " + index);
info("Waiting for the correct script to be selected for index " + index);
dbg.panelWin.on(dbg.panelWin.EVENTS.SOURCE_SHOWN, onSource);
}
let line = node.sourceLine;
ok(line, "found source line for index " + index);
function onSource(aEvent, aSource) {
if (aSource.url != src) {
return;
}
dbg.panelWin.off(dbg.panelWin.EVENTS.SOURCE_SHOWN, onSource);
ok(true, "Correct script is selected for index " + index);
checkCorrectLine(function() {
gDevTools.showToolbox(target, "webconsole").then(function() {
index++;
info("webconsole selected for index " + index);
toolbox.once("jsdebugger-selected", checkLineAndClickNext);
EventUtils.sendMouseEvent({ type: "click" }, nodes[index%2]);
executeSoon(() => {
EventUtils.sendMouseEvent({ type: "click" }, node);
});
});
}
function checkCorrectLine(aCallback)
{
waitForSuccess({
name: "correct source and line test for debugger for index " + index,
validatorFn: function()
{
let debuggerView = dbg.panelWin.DebuggerView;
if (debuggerView.editor &&
debuggerView.editor.getCursor().line == line - 1) {
return true;
}
return false;
},
successFn: function()
{
aCallback && executeSoon(aCallback);
},
failureFn: finishTest,
timeout: 10000,
});
yield hud.ui.once("source-in-debugger-opened", checkLine.bind(null, url, line));
}
function* checkLine(url, line) {
let toolbox = yield gDevTools.getToolbox(hud.target);
let {panelWin: { DebuggerView: view }} = toolbox.getPanel("jsdebugger");
is(view.Sources.selectedValue, url, "expected source url");
is(view.editor.getCursor().line, line - 1, "expected source line");
}
}

Просмотреть файл

@ -67,6 +67,20 @@ function addTab(aURL)
browser = gBrowser.getBrowserForTab(tab);
}
function loadTab(url) {
let deferred = promise.defer();
let tab = gBrowser.selectedTab = gBrowser.addTab(url);
let browser = gBrowser.getBrowserForTab(tab);
browser.addEventListener("load", function onLoad() {
browser.removeEventListener("load", onLoad, true);
deferred.resolve({tab: tab, browser: browser});
}, true);
return deferred.promise;
}
function afterAllTabsLoaded(callback, win) {
win = win || window;