mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1253924 - Implement statusLine + fix & test statusCode r=kmag
MozReview-Commit-ID: BhyM10w8iGt
This commit is contained in:
parent
c10ba6ec3f
commit
c51da12299
@ -53,7 +53,7 @@ function WebRequestEventManager(context, eventName) {
|
||||
return;
|
||||
}
|
||||
|
||||
let optional = ["requestHeaders", "responseHeaders", "statusCode", "redirectUrl"];
|
||||
let optional = ["requestHeaders", "responseHeaders", "statusCode", "statusLine", "redirectUrl"];
|
||||
for (let opt of optional) {
|
||||
if (opt in data) {
|
||||
data2[opt] = data[opt];
|
||||
|
@ -96,6 +96,20 @@ function backgroundScript() {
|
||||
return url.startsWith(BASE) || /^data:.*\bwebRequestTest\b/.test(url);
|
||||
}
|
||||
|
||||
let statuses = [
|
||||
{url: /_script_good\b/, code: 200, line: /^HTTP\/1.1 200 OK\b/i},
|
||||
{url: /\bredirection\b/, code: 302, line: /^HTTP\/1.1 302\b/},
|
||||
{url: /\bnonexistent_script_/, code: 404, line: /^HTTP\/1.1 404 Not Found\b/i},
|
||||
];
|
||||
function checkStatus(details) {
|
||||
for (let {url, code, line} of statuses) {
|
||||
if (url.test(details.url)) {
|
||||
browser.test.assertTrue(code === details.statusCode, `HTTP status code ${code} for ${details.url} (found ${details.statusCode})`);
|
||||
browser.test.assertTrue(line.test(details.statusLine), `HTTP status line ${line} for ${details.url} (found ${details.statusLine})`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function checkType(details) {
|
||||
let expected_type = "???";
|
||||
if (details.url.indexOf("style") != -1) {
|
||||
@ -302,6 +316,7 @@ function backgroundScript() {
|
||||
|
||||
browser.test.assertEq(details.tabId, savedTabId, "correct tab ID");
|
||||
checkType(details);
|
||||
checkStatus(details);
|
||||
|
||||
let id = frameIDs.get(details.url);
|
||||
browser.test.assertEq(id, details.frameId, "frame ID same in onBeforeRedirect as onBeforeRequest");
|
||||
@ -344,6 +359,7 @@ function backgroundScript() {
|
||||
}
|
||||
completedUrls[kind].add(details.url);
|
||||
}
|
||||
checkStatus(details);
|
||||
}
|
||||
|
||||
function onHeadersReceived(details) {
|
||||
|
@ -87,6 +87,20 @@ function parseExtra(extra, allowed) {
|
||||
return result;
|
||||
}
|
||||
|
||||
function mergeStatus(data, channel) {
|
||||
try {
|
||||
data.statusCode = channel.responseStatus;
|
||||
let statusText = channel.responseStatusText;
|
||||
let maj = {};
|
||||
let min = {};
|
||||
channel.QueryInterface(Ci.nsIHttpChannelInternal).getResponseVersion(maj, min);
|
||||
data.statusLine = `HTTP/${maj.value}.${min.value} ${data.statusCode} ${statusText}`;
|
||||
} catch (e) {
|
||||
// NS_ERROR_NOT_AVAILABLE might be thrown.
|
||||
Cu.reportError(e);
|
||||
}
|
||||
}
|
||||
|
||||
var HttpObserverManager;
|
||||
|
||||
var ContentPolicyManager = {
|
||||
@ -404,7 +418,7 @@ HttpObserverManager = {
|
||||
let responseHeaderNames;
|
||||
|
||||
let includeStatus = kind === "headersReceived" ||
|
||||
kind === "onBeforeRedirect" ||
|
||||
kind === "onRedirect" ||
|
||||
kind === "onStart" ||
|
||||
kind === "onStop";
|
||||
|
||||
@ -443,7 +457,7 @@ HttpObserverManager = {
|
||||
responseHeaderNames = data.responseHeaders.map(h => h.name);
|
||||
}
|
||||
if (includeStatus) {
|
||||
data.statusCode = channel.responseStatus;
|
||||
mergeStatus(data, channel);
|
||||
}
|
||||
|
||||
let result = null;
|
||||
|
Loading…
Reference in New Issue
Block a user