Skip to content

Commit d0a332f

Browse files
committed
Catch exception when trying to get secInfo when the API doesn't exist
1 parent 4de08ae commit d0a332f

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

webext/CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1414
better be, the browser should have halted this connection long before if it
1515
isn't!).
1616

17+
18+
### Changed
19+
20+
- Catch exception when trying to get securityInfo and the API doesn't exist.
21+
1722
## v1.0.2 - 2019-02-19
1823

1924
### Changed

webext/background.js

+20-2
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,26 @@ async function onHeadersReceived_filterAltSvc(details) {
316316

317317
async function onHeadersReceived_verifySelfAuthConnection(details) {
318318
let url = splitURL(details.url);
319-
let secInfo = await browser.webRequest.getSecurityInfo(
320-
details.requestId, {"certificateChain": true, "rawDER": true});
319+
let secInfo = null;
320+
try {
321+
secInfo = await browser.webRequest.getSecurityInfo(
322+
details.requestId, {"certificateChain": true, "rawDER": true});
323+
} catch (e) {
324+
if (e instanceof TypeError) {
325+
log_debug(
326+
"Caught exception trying to get securityInfo, assuming we",
327+
"don't have that API in the browser:", e);
328+
return;
329+
} else {
330+
throw e;
331+
}
332+
}
333+
334+
if (!secInfo) {
335+
log_error("Failed to get securityInfo. No API support? Should have",
336+
"caught this sooner.");
337+
return;
338+
}
321339

322340
if (secInfo.state != "secure") {
323341
log_debug("Stopped considering", url.hostname, "becuase not",

0 commit comments

Comments
 (0)