зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1317366: Handle blocking WebRequest listeners returning non-object values. r=mixedpuppy
MozReview-Commit-ID: HMbgONPqsKU --HG-- extra : rebase_source : 08e20cd9e7b6732ab05ae2d1aeada8c80bdf222c
This commit is contained in:
Родитель
cfd14cf481
Коммит
0c9bfc0605
|
@ -13,7 +13,7 @@
|
|||
<script type="text/javascript">
|
||||
"use strict";
|
||||
|
||||
add_task(function* () {
|
||||
add_task(function* test_suspend() {
|
||||
let extension = ExtensionTestUtils.loadExtension({
|
||||
manifest: {
|
||||
permissions: [
|
||||
|
@ -23,17 +23,33 @@ add_task(function* () {
|
|||
},
|
||||
|
||||
background() {
|
||||
browser.webRequest.onBeforeSendHeaders.addListener(details => {
|
||||
let requestHeaders = details.requestHeaders.concat({name: "Foo", value: "Bar"});
|
||||
browser.webRequest.onBeforeSendHeaders.addListener(
|
||||
details => {
|
||||
// Make sure that returning undefined or a promise that resolves to
|
||||
// undefined does not break later handlers.
|
||||
},
|
||||
{urls: ["<all_urls>"]},
|
||||
["blocking", "requestHeaders"]);
|
||||
|
||||
return new Promise(resolve => {
|
||||
setTimeout(resolve, 500);
|
||||
}).then(() => {
|
||||
return {requestHeaders};
|
||||
});
|
||||
},
|
||||
{urls: ["<all_urls>"]},
|
||||
["blocking", "requestHeaders"]);
|
||||
browser.webRequest.onBeforeSendHeaders.addListener(
|
||||
details => {
|
||||
return Promise.resolve();
|
||||
},
|
||||
{urls: ["<all_urls>"]},
|
||||
["blocking", "requestHeaders"]);
|
||||
|
||||
browser.webRequest.onBeforeSendHeaders.addListener(
|
||||
details => {
|
||||
let requestHeaders = details.requestHeaders.concat({name: "Foo", value: "Bar"});
|
||||
|
||||
return new Promise(resolve => {
|
||||
setTimeout(resolve, 500);
|
||||
}).then(() => {
|
||||
return {requestHeaders};
|
||||
});
|
||||
},
|
||||
{urls: ["<all_urls>"]},
|
||||
["blocking", "requestHeaders"]);
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
@ -749,6 +749,10 @@ HttpObserverManager = {
|
|||
}
|
||||
|
||||
for (let {opts, result} of handlerResults) {
|
||||
if (!result || typeof result !== "object") {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (result.cancel) {
|
||||
this.maybeResume(channel);
|
||||
channel.cancel(Cr.NS_ERROR_ABORT);
|
||||
|
|
Загрузка…
Ссылка в новой задаче