commit 1305066f21439675842aad91844e6b490df8c3e0 Author: Shane Caraveo scaraveo@mozilla.com Date: Fri May 25 16:41:19 2018 -0400
Bug 1464481 - fix and test crash when getting registered channelwrapper, r=kmag
MozReview-Commit-ID: LEGojHEb742
--HG-- extra : rebase_source : 7018cfef6b7415ea275dc2c3e414586396a9e2be --- dom/chrome-webidl/ChannelWrapper.webidl | 2 +- .../test/mochitest/test_ext_webrequest_hsts.html | 25 ++++++++++++++++++++++ toolkit/modules/addons/WebRequest.jsm | 4 +++- 3 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/dom/chrome-webidl/ChannelWrapper.webidl b/dom/chrome-webidl/ChannelWrapper.webidl index 2777aab65c8e..bc959d30d043 100644 --- a/dom/chrome-webidl/ChannelWrapper.webidl +++ b/dom/chrome-webidl/ChannelWrapper.webidl @@ -52,7 +52,7 @@ interface ChannelWrapper : EventTarget { * Returns the wrapper instance for the given channel. The same wrapper is * always returned for a given channel. */ - static ChannelWrapper getRegisteredChannel(unsigned long long aChannelId, + static ChannelWrapper? getRegisteredChannel(unsigned long long aChannelId, WebExtensionPolicy extension, TabParent? tabParent);
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_webrequest_hsts.html b/toolkit/components/extensions/test/mochitest/test_ext_webrequest_hsts.html index ad4d4f32a657..849527ea4a80 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_webrequest_hsts.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_webrequest_hsts.html @@ -185,6 +185,31 @@ add_task(async function test_hsts_header() {
await extension.unload(); }); + +add_task(async function test_nonBlocking_securityInfo() { + let extension = ExtensionTestUtils.loadExtension({ + manifest: { + "permissions": [ + "webRequest", + "<all_urls>", + ], + }, + async background() { + let tab; + browser.webRequest.onHeadersReceived.addListener(async (details) => { + let securityInfo = await browser.webRequest.getSecurityInfo(details.requestId, {}); + browser.test.assertTrue(!securityInfo, "securityInfo undefined on http request"); + browser.tabs.remove(tab.id); + browser.test.notifyPass("success"); + }, {urls: ["<all_urls>"], types: ["main_frame"]}); + tab = await browser.tabs.create({url: "https://example.org/tests/toolkit/components/extensions/test/mochitest/file_...); + }, + }); + await extension.startup(); + + await extension.awaitFinish("success"); + await extension.unload(); +}); </script> </head> <body> diff --git a/toolkit/modules/addons/WebRequest.jsm b/toolkit/modules/addons/WebRequest.jsm index a4c9e9859a21..6a95182a3876 100644 --- a/toolkit/modules/addons/WebRequest.jsm +++ b/toolkit/modules/addons/WebRequest.jsm @@ -1012,7 +1012,9 @@ var WebRequest = {
getSecurityInfo: (details) => { let channel = ChannelWrapper.getRegisteredChannel(details.id, details.extension, details.tabParent); - return SecurityInfo.getSecurityInfo(channel.channel, details.options); + if (channel) { + return SecurityInfo.getSecurityInfo(channel.channel, details.options); + } }, };
tbb-commits@lists.torproject.org