Bug 1404671 check the error string
MozReview-Commit-ID: GEiFEb7JMdh
--- a/toolkit/components/extensions/test/mochitest/head_webrequest.js
+++ b/toolkit/components/extensions/test/mochitest/head_webrequest.js
@@ -227,17 +227,21 @@ function background(events) {
// sure they're all consistent.
expectedIp = expectedIp || details.ip;
browser.test.assertEq(expectedIp, details.ip, `correct ip for ${details.url}`);
}
if (expected.headers && expected.headers.response) {
checkHeaders("response", expected, details);
}
},
- onErrorOccurred() {},
+ onErrorOccurred(expected, details, result) {
+ if (expected.error) {
+ browser.test.assertEq(expected.error, details.error, "expected error message received in onErrorOccurred");
+ }
+ },
};
function getListener(name) {
return details => {
let result = {};
browser.test.log(`${name} ${details.requestId} ${details.url}`);
let expected = getExpected(details);
if (!expected) {
--- a/toolkit/components/extensions/test/mochitest/test_ext_webrequest_basic.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_webrequest_basic.html
@@ -344,16 +344,17 @@ add_task(async function test_webRequest_
"dummy_page.html": {
type: "sub_frame",
status: 404,
},
"badrobot": {
type: "sub_frame",
status: 404,
events: ["onBeforeRequest", "onBeforeSendHeaders", "onSendHeaders", "onErrorOccurred"],
+ error: "NS_ERROR_UNKNOWN_HOST",
},
};
extension.sendMessage("set-expected", {expect, origin: location.href});
await extension.awaitMessage("continue");
addFrame("data:text/plain,webRequestTest");
addFrame("data:text/plain,webRequestTest_bad");
await extension.awaitMessage("cancelled");
addFrame("redirection.sjs");