Bug 750241 - Filter console messages to prevent intermittent orange; r=hsivonen

This commit is contained in:
Masatoshi Kimura 2012-07-30 12:47:19 +01:00
parent 9e36b6f071
commit 412f59d922
2 changed files with 15 additions and 3 deletions

View File

@ -32,11 +32,17 @@ function resolveURL(relative) {
return a.href;
}
var resolvedURL = resolveURL(tests[0]);
var expectedErrors = [
'[JavaScript Warning: "A form was submitted in the windows-1252 encoding which cannot encode all Unicode characters, so user input may get corrupted. To avoid this problem, the page should be changed so that the form is submitted in the UTF-8 encoding either by changing the encoding of the page itself to UTF-8 or by specifying accept-charset=utf-8 on the form element." {file: "' + resolveURL(tests[0]) + '" line: 1}]'
'[JavaScript Warning: "A form was submitted in the windows-1252 encoding which cannot encode all Unicode characters, so user input may get corrupted. To avoid this problem, the page should be changed so that the form is submitted in the UTF-8 encoding either by changing the encoding of the page itself to UTF-8 or by specifying accept-charset=utf-8 on the form element." {file: "' + resolvedURL + '" line: 1}]'
];
function consoleError(msg) {
function consoleError(msg, fileName) {
// Ignore messages not generated by the test
if (fileName !== resolvedURL) {
return;
}
var expected = expectedErrors.shift();
is(msg, expected, "Not the right error message");
}

View File

@ -756,7 +756,13 @@ SpecialPowersAPI.prototype = {
var consoleListener = {
userListener: listener,
observe: function(consoleMessage) {
this.userListener(consoleMessage.message);
var fileName;
try {
fileName = consoleMessage.QueryInterface(Ci.nsIScriptError)
.sourceName;
} catch (e) {
}
this.userListener(consoleMessage.message, fileName);
}
};