mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 888407 - Fix for intermittent browser_console_iframe_messages.js | Test timed out, failed to match rule: iframe 1; r=me
This commit is contained in:
parent
6491b478e3
commit
395ca3718f
@ -8,16 +8,56 @@
|
||||
|
||||
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-consoleiframes.html";
|
||||
|
||||
let expectedMessages = [
|
||||
{
|
||||
text: "main file",
|
||||
category: CATEGORY_WEBDEV,
|
||||
severity: SEVERITY_LOG,
|
||||
},
|
||||
{
|
||||
text: "blah",
|
||||
category: CATEGORY_JS,
|
||||
severity: SEVERITY_ERROR
|
||||
},
|
||||
{
|
||||
text: "iframe 2",
|
||||
category: CATEGORY_WEBDEV,
|
||||
severity: SEVERITY_LOG
|
||||
},
|
||||
{
|
||||
text: "iframe 3",
|
||||
category: CATEGORY_WEBDEV,
|
||||
severity: SEVERITY_LOG
|
||||
}
|
||||
];
|
||||
|
||||
// "iframe 1" console messages can be coalesced into one if they follow each
|
||||
// other in the sequence of messages (depending on timing). If they do not, then
|
||||
// they will be displayed in the console output independently, as separate
|
||||
// messages. This is why we need to match any of the following two rules.
|
||||
let expectedMessagesAny = [
|
||||
{
|
||||
name: "iframe 1 (count: 2)",
|
||||
text: "iframe 1",
|
||||
category: CATEGORY_WEBDEV,
|
||||
severity: SEVERITY_LOG,
|
||||
count: 2
|
||||
},
|
||||
{
|
||||
name: "iframe 1 (repeats: 2)",
|
||||
text: "iframe 1",
|
||||
category: CATEGORY_WEBDEV,
|
||||
severity: SEVERITY_LOG,
|
||||
repeats: 2
|
||||
},
|
||||
];
|
||||
|
||||
function test()
|
||||
{
|
||||
expectUncaughtException();
|
||||
addTab(TEST_URI);
|
||||
browser.addEventListener("load", function onLoad() {
|
||||
browser.removeEventListener("load", onLoad, true);
|
||||
|
||||
// Test for cached nsIConsoleMessages.
|
||||
Services.console.logStringMessage("test1 for bug859756");
|
||||
|
||||
info("open web console");
|
||||
openConsole(null, consoleOpened);
|
||||
}, true);
|
||||
@ -29,31 +69,16 @@ function consoleOpened(hud)
|
||||
|
||||
waitForMessages({
|
||||
webconsole: hud,
|
||||
messages: [
|
||||
{
|
||||
text: "main file",
|
||||
category: CATEGORY_WEBDEV,
|
||||
severity: SEVERITY_LOG,
|
||||
},
|
||||
{
|
||||
text: "blah",
|
||||
category: CATEGORY_JS,
|
||||
severity: SEVERITY_ERROR
|
||||
},
|
||||
{
|
||||
text: "iframe 1",
|
||||
category: CATEGORY_WEBDEV,
|
||||
severity: SEVERITY_LOG,
|
||||
count: 2
|
||||
},
|
||||
{
|
||||
text: "iframe 2",
|
||||
category: CATEGORY_WEBDEV,
|
||||
severity: SEVERITY_LOG
|
||||
}
|
||||
],
|
||||
messages: expectedMessages,
|
||||
}).then(() => {
|
||||
closeConsole(null, onWebConsoleClose);
|
||||
info("first messages matched");
|
||||
waitForMessages({
|
||||
webconsole: hud,
|
||||
messages: expectedMessagesAny,
|
||||
matchCondition: "any",
|
||||
}).then(() => {
|
||||
closeConsole(null, onWebConsoleClose);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@ -66,34 +91,17 @@ function onWebConsoleClose()
|
||||
function onBrowserConsoleOpen(hud)
|
||||
{
|
||||
ok(hud, "browser console opened");
|
||||
Services.console.logStringMessage("test2 for bug859756");
|
||||
|
||||
waitForMessages({
|
||||
webconsole: hud,
|
||||
messages: [
|
||||
{
|
||||
text: "main file",
|
||||
category: CATEGORY_WEBDEV,
|
||||
severity: SEVERITY_LOG,
|
||||
},
|
||||
{
|
||||
text: "blah",
|
||||
category: CATEGORY_JS,
|
||||
severity: SEVERITY_ERROR
|
||||
},
|
||||
{
|
||||
text: "iframe 1",
|
||||
category: CATEGORY_WEBDEV,
|
||||
severity: SEVERITY_LOG,
|
||||
count: 2
|
||||
},
|
||||
{
|
||||
text: "iframe 2",
|
||||
category: CATEGORY_WEBDEV,
|
||||
severity: SEVERITY_LOG
|
||||
}
|
||||
],
|
||||
messages: expectedMessages,
|
||||
}).then(() => {
|
||||
closeConsole(null, finishTest);
|
||||
info("first messages matched");
|
||||
waitForMessages({
|
||||
webconsole: hud,
|
||||
messages: expectedMessagesAny,
|
||||
matchCondition: "any",
|
||||
}).then(() => {
|
||||
closeConsole(null, finishTest);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -855,6 +855,12 @@ function getMessageElementText(aElement)
|
||||
* @param object aOptions
|
||||
* Options for what you want to wait for:
|
||||
* - webconsole: the webconsole instance you work with.
|
||||
* - matchCondition: "any" or "all". Default: "all". The promise
|
||||
* returned by this function resolves when all of the messages are
|
||||
* matched, if the |matchCondition| is "all". If you set the condition to
|
||||
* "any" then the promise is resolved by any message rule that matches,
|
||||
* irrespective of order - waiting for messages stops whenever any rule
|
||||
* matches.
|
||||
* - messages: an array of objects that tells which messages to wait for.
|
||||
* Properties:
|
||||
* - text: string or RegExp to match the textContent of each new
|
||||
@ -905,6 +911,7 @@ function waitForMessages(aOptions)
|
||||
let rulesMatched = 0;
|
||||
let listenerAdded = false;
|
||||
let deferred = promise.defer();
|
||||
aOptions.matchCondition = aOptions.matchCondition || "all";
|
||||
|
||||
function checkText(aRule, aText)
|
||||
{
|
||||
@ -1154,9 +1161,15 @@ function waitForMessages(aOptions)
|
||||
}
|
||||
}
|
||||
|
||||
function allRulesMatched()
|
||||
{
|
||||
return aOptions.matchCondition == "all" && rulesMatched == rules.length ||
|
||||
aOptions.matchCondition == "any" && rulesMatched > 0;
|
||||
}
|
||||
|
||||
function maybeDone()
|
||||
{
|
||||
if (rulesMatched == rules.length) {
|
||||
if (allRulesMatched()) {
|
||||
if (listenerAdded) {
|
||||
webconsole.ui.off("messages-added", onMessagesAdded);
|
||||
webconsole.ui.off("messages-updated", onMessagesAdded);
|
||||
@ -1169,7 +1182,7 @@ function waitForMessages(aOptions)
|
||||
}
|
||||
|
||||
function testCleanup() {
|
||||
if (rulesMatched == rules.length) {
|
||||
if (allRulesMatched()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1198,7 +1211,7 @@ function waitForMessages(aOptions)
|
||||
|
||||
executeSoon(() => {
|
||||
onMessagesAdded("messages-added", webconsole.outputNode.childNodes);
|
||||
if (rulesMatched != rules.length) {
|
||||
if (!allRulesMatched()) {
|
||||
listenerAdded = true;
|
||||
registerCleanupFunction(testCleanup);
|
||||
webconsole.ui.on("messages-added", onMessagesAdded);
|
||||
|
Loading…
Reference in New Issue
Block a user