Bug 1463538 - Fail PaymentRequest UI tests upon console errors. r=jaws

MozReview-Commit-ID: 2IzUaENZjfl

--HG--
extra : rebase_source : 3cce2b9a6ec32ba02c0fd60fa3c2c7ee1e6da0a5
This commit is contained in:
Matthew Noorenberghe 2018-07-24 19:24:29 -07:00
parent 791b509e81
commit 8be80047e1
2 changed files with 32 additions and 0 deletions

View File

@ -313,11 +313,27 @@ function cleanupFormAutofillStorage() {
}
add_task(async function setup_head() {
SpecialPowers.registerConsoleListener(function onConsoleMessage(msg) {
if (msg.isWarning || !msg.errorMessage) {
// Ignore warnings and non-errors.
return;
}
if (msg.category == "CSP_CSPViolationWithURI" && msg.errorMessage.includes("at inline")) {
// Ignore unknown CSP error.
return;
}
if (msg.errorMessage.match(/docShell is null.*BrowserUtils.jsm/)) {
// Bug 1478142 - Console spam from the Find Toolbar.
return;
}
ok(false, msg.message || msg.errorMessage);
});
await setupFormAutofillStorage();
registerCleanupFunction(function cleanup() {
paymentSrv.cleanup();
cleanupFormAutofillStorage();
Services.prefs.clearUserPref(RESPONSE_TIMEOUT_PREF);
SpecialPowers.postConsoleSentinel();
});
});

View File

@ -46,3 +46,19 @@ function promiseContentToChromeMessage(messageType) {
function deepClone(obj) {
return JSON.parse(JSON.stringify(obj));
}
// Listen for errors to fail tests
SpecialPowers.registerConsoleListener(function onConsoleMessage(msg) {
if (msg.isWarning || !msg.errorMessage) {
// Ignore warnings and non-errors.
return;
}
if (msg.category == "CSP_CSPViolationWithURI" && msg.errorMessage.includes("at inline")) {
// Ignore unknown CSP error.
return;
}
ok(false, msg.message || msg.errorMessage);
});
SimpleTest.registerCleanupFunction(function cleanup() {
SpecialPowers.postConsoleSentinel();
});