mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 00:35:44 +00:00
Bug 808264 - Intermittent browser_webconsole_bug_782653_CSS_links_in_Style_Editor.js | Timed out while waiting for: Wait for the source-editor to load
This commit is contained in:
parent
4c2fb68703
commit
eae67ee933
@ -7,11 +7,10 @@
|
|||||||
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test" +
|
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test" +
|
||||||
"/test-bug-782653-css-errors.html";
|
"/test-bug-782653-css-errors.html";
|
||||||
|
|
||||||
let nodes;
|
let nodes, hud, SEC;
|
||||||
|
|
||||||
let styleEditorWin;
|
function test()
|
||||||
|
{
|
||||||
function test() {
|
|
||||||
addTab(TEST_URI);
|
addTab(TEST_URI);
|
||||||
browser.addEventListener("load", function onLoad() {
|
browser.addEventListener("load", function onLoad() {
|
||||||
browser.removeEventListener("load", onLoad, true);
|
browser.removeEventListener("load", onLoad, true);
|
||||||
@ -19,17 +18,26 @@ function test() {
|
|||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function testViewSource(hud) {
|
function testViewSource(aHud)
|
||||||
|
{
|
||||||
|
hud = aHud;
|
||||||
|
|
||||||
|
registerCleanupFunction(function() {
|
||||||
|
nodes = hud = SEC = null;
|
||||||
|
});
|
||||||
|
|
||||||
|
let selector = ".webconsole-msg-cssparser .webconsole-location";
|
||||||
|
|
||||||
waitForSuccess({
|
waitForSuccess({
|
||||||
name: "find the location node",
|
name: "find the location node",
|
||||||
validatorFn: function()
|
validatorFn: function()
|
||||||
{
|
{
|
||||||
return hud.outputNode.querySelector(".webconsole-location");
|
return hud.outputNode.querySelector(selector);
|
||||||
},
|
},
|
||||||
successFn: function()
|
successFn: function()
|
||||||
{
|
{
|
||||||
nodes = hud.outputNode.querySelectorAll(".webconsole-location");
|
nodes = hud.outputNode.querySelectorAll(selector);
|
||||||
|
is(nodes.length, 2, "correct number of css messages");
|
||||||
|
|
||||||
Services.ww.registerNotification(observer);
|
Services.ww.registerNotification(observer);
|
||||||
|
|
||||||
@ -39,84 +47,9 @@ function testViewSource(hud) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkStyleEditorForSheetAndLine(aStyleSheetIndex, aLine, aCallback) {
|
|
||||||
|
|
||||||
function doCheck(aEditor) {
|
|
||||||
function checkLineAndCallback() {
|
|
||||||
info("In checkLineAndCallback()");
|
|
||||||
is(aEditor.sourceEditor.getCaretPosition().line, aLine,
|
|
||||||
"Correct line is selected");
|
|
||||||
if (aCallback) {
|
|
||||||
aCallback();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkForCorrectSheet() {
|
|
||||||
if (aEditor.styleSheetIndex != SEC.selectedStyleSheetIndex) {
|
|
||||||
ok(false, "Correct Style Sheet was not selected.");
|
|
||||||
if (aCallback) {
|
|
||||||
executeSoon(aCallback);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
info("Editor is already loaded, check the current line of caret");
|
|
||||||
executeSoon(checkLineAndCallback);
|
|
||||||
}
|
|
||||||
|
|
||||||
ok(aEditor, "aEditor is defined.");
|
|
||||||
|
|
||||||
// Source-editor is already loaded, check the current sheet and line.
|
|
||||||
if (aEditor.sourceEditor) {
|
|
||||||
checkForCorrectSheet();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
info("source editor is not loaded, waiting for it.");
|
|
||||||
// Source-editor is not loaded, polling regularly and waiting for it to load
|
|
||||||
waitForSuccess({
|
|
||||||
name: "Wait for the source-editor to load",
|
|
||||||
validatorFn: function()
|
|
||||||
{
|
|
||||||
return aEditor.sourceEditor;
|
|
||||||
},
|
|
||||||
successFn: checkForCorrectSheet,
|
|
||||||
failureFn: aCallback,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
let SEC = styleEditorWin.styleEditorChrome;
|
|
||||||
ok(SEC, "Syle Editor Chrome is defined properly while calling for [" +
|
|
||||||
aStyleSheetIndex + ", " + aLine + "]");
|
|
||||||
|
|
||||||
// Editors are not ready, so wait for them.
|
|
||||||
if (!SEC.editors.length) {
|
|
||||||
info("Editor is not ready, waiting before doing check.");
|
|
||||||
SEC.addChromeListener({
|
|
||||||
onEditorAdded: function onEditorAdded(aChrome, aEditor) {
|
|
||||||
info("Editor loaded now. Removing listener and doing check.");
|
|
||||||
aChrome.removeChromeListener(this);
|
|
||||||
executeSoon(function() {
|
|
||||||
doCheck(aEditor);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
// Execute soon so that selectedStyleSheetIndex has correct value.
|
|
||||||
else {
|
|
||||||
info("Editor is defined, opening the desired editor for now and " +
|
|
||||||
"checking later if it is correct");
|
|
||||||
for (let aEditor of SEC.editors) {
|
|
||||||
if (aEditor.styleSheetIndex == aStyleSheetIndex) {
|
|
||||||
doCheck(aEditor);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let observer = {
|
let observer = {
|
||||||
observe: function(aSubject, aTopic, aData) {
|
observe: function(aSubject, aTopic, aData)
|
||||||
|
{
|
||||||
if (aTopic != "domwindowopened") {
|
if (aTopic != "domwindowopened") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -124,21 +57,79 @@ let observer = {
|
|||||||
info("Style Editor window was opened in response to clicking " +
|
info("Style Editor window was opened in response to clicking " +
|
||||||
"the location node");
|
"the location node");
|
||||||
|
|
||||||
|
function sheetForNode(aNode)
|
||||||
|
{
|
||||||
|
let href = aNode.getAttribute("title");
|
||||||
|
let sheet, i = 0;
|
||||||
|
while((sheet = content.document.styleSheets[i++])) {
|
||||||
|
if (sheet.href == href) {
|
||||||
|
return sheet;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ok(false, "no sheet found");
|
||||||
|
}
|
||||||
|
|
||||||
executeSoon(function() {
|
executeSoon(function() {
|
||||||
styleEditorWin = window.StyleEditor
|
let styleEditorWin = window.StyleEditor.StyleEditorManager
|
||||||
.StyleEditorManager
|
.getEditorForWindow(content.window);
|
||||||
.getEditorForWindow(content.window);
|
ok(styleEditorWin, "Style Editor window is defined");
|
||||||
ok(styleEditorWin, "Style Editor Window is defined");
|
|
||||||
waitForFocus(function() {
|
waitForFocus(function() {
|
||||||
checkStyleEditorForSheetAndLine(0, 7, function() {
|
SEC = styleEditorWin.styleEditorChrome;
|
||||||
checkStyleEditorForSheetAndLine(1, 6, function() {
|
ok(SEC, "Style Editor Chrome is defined");
|
||||||
|
|
||||||
|
let sheet = sheetForNode(nodes[0]);
|
||||||
|
checkStyleEditorForSheetAndLine(sheet, 7, function() {
|
||||||
|
let sheet = sheetForNode(nodes[1]);
|
||||||
|
EventUtils.sendMouseEvent({ type: "click" }, nodes[1]);
|
||||||
|
checkStyleEditorForSheetAndLine(sheet, 6, function() {
|
||||||
window.StyleEditor.toggle();
|
window.StyleEditor.toggle();
|
||||||
styleEditorWin = null;
|
|
||||||
finishTest();
|
finishTest();
|
||||||
});
|
});
|
||||||
EventUtils.sendMouseEvent({ type: "click" }, nodes[1]);
|
|
||||||
});
|
});
|
||||||
}, styleEditorWin);
|
}, styleEditorWin);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function checkStyleEditorForSheetAndLine(aStyleSheet, aLine, aCallback)
|
||||||
|
{
|
||||||
|
let editor = null;
|
||||||
|
|
||||||
|
let performLineCheck = {
|
||||||
|
name: "source editor load",
|
||||||
|
validatorFn: function()
|
||||||
|
{
|
||||||
|
return editor.sourceEditor;
|
||||||
|
},
|
||||||
|
successFn: function()
|
||||||
|
{
|
||||||
|
is(editor.sourceEditor.getCaretPosition().line, aLine,
|
||||||
|
"correct line is selected");
|
||||||
|
is(SEC.selectedStyleSheetIndex, editor.styleSheetIndex,
|
||||||
|
"correct stylesheet is selected in the editor");
|
||||||
|
|
||||||
|
executeSoon(aCallback);
|
||||||
|
},
|
||||||
|
failureFn: aCallback,
|
||||||
|
};
|
||||||
|
|
||||||
|
waitForSuccess({
|
||||||
|
name: "editor for stylesheet",
|
||||||
|
validatorFn: function()
|
||||||
|
{
|
||||||
|
for (let item of SEC.editors) {
|
||||||
|
if (item.styleSheet == aStyleSheet) {
|
||||||
|
editor = item;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
successFn: function()
|
||||||
|
{
|
||||||
|
waitForSuccess(performLineCheck);
|
||||||
|
},
|
||||||
|
failureFn: finishTest,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user