fix navigation errors being misreported lol professional grade software
This commit is contained in:
@@ -296,7 +296,7 @@ An `EventEmitter` instance that emits the following events:
|
|||||||
| `browser_connect` | `ws` | Browser connected |
|
| `browser_connect` | `ws` | Browser connected |
|
||||||
| `browser_disconnect` | `{}` | Browser disconnected |
|
| `browser_disconnect` | `{}` | Browser disconnected |
|
||||||
| `dom_ready` | `{ id, index, status, active, title, url, container }` | A tab finished loading |
|
| `dom_ready` | `{ id, index, status, active, title, url, container }` | A tab finished loading |
|
||||||
| `dom_load_fail` | `{ id }` | A tab failed to load |
|
| `dom_load_fail` | `{ id, url, error }` | A tab failed to load (Network error, `<=400` code) |
|
||||||
| `web_request` | `{ id, url, status, origin, type, method, container, headers }` | A request was sent |
|
| `web_request` | `{ id, url, status, origin, type, method, container, headers }` | A request was sent |
|
||||||
| `web_response` | `{ id, url, status, origin, type, method, container, body }` | A response was received |
|
| `web_response` | `{ id, url, status, origin, type, method, container, body }` | A response was received |
|
||||||
|
|
||||||
|
|||||||
46
ext/bg.js
46
ext/bg.js
@@ -15,7 +15,7 @@ var proxy_map = {};
|
|||||||
|
|
||||||
var web_response_whitelist = ["main_frame", "xmlhttprequest"];
|
var web_response_whitelist = ["main_frame", "xmlhttprequest"];
|
||||||
|
|
||||||
const log_debug = true;
|
const log_debug = false;
|
||||||
|
|
||||||
browser.browserAction.setBadgeBackgroundColor({
|
browser.browserAction.setBadgeBackgroundColor({
|
||||||
color: [0, 0, 0, 0]
|
color: [0, 0, 0, 0]
|
||||||
@@ -638,16 +638,56 @@ browser.tabs.onUpdated.addListener(function(tabid, event, tab){
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
browser.webRequest.onHeadersReceived.addListener(function(page){
|
||||||
|
|
||||||
|
if(page.type != "main_frame"){
|
||||||
|
|
||||||
|
return
|
||||||
|
};
|
||||||
|
|
||||||
|
// send error on 4xx code
|
||||||
|
if(page.statusCode >= 400){
|
||||||
|
|
||||||
|
send_event(
|
||||||
|
global_ws,
|
||||||
|
{
|
||||||
|
"action": "dom_load_fail",
|
||||||
|
"data": {
|
||||||
|
id: page.tabId,
|
||||||
|
url: page.url,
|
||||||
|
error: page.statusLine.trim()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ urls: ["<all_urls>"] }
|
||||||
|
);
|
||||||
|
|
||||||
browser.webNavigation.onErrorOccurred.addListener(function(page){
|
browser.webNavigation.onErrorOccurred.addListener(function(page){
|
||||||
|
|
||||||
if(connected === false){ return; }
|
if(
|
||||||
|
connected === false ||
|
||||||
|
// must be an error in parent frame
|
||||||
|
page.frameId !== 0 ||
|
||||||
|
// ignore HSTS error. See:
|
||||||
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=1801326
|
||||||
|
page.error == "Error code 2152398850" ||
|
||||||
|
// page-load abort
|
||||||
|
page.error == "NS_BINDING_ABORTED"
|
||||||
|
){
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
send_event(
|
send_event(
|
||||||
global_ws,
|
global_ws,
|
||||||
{
|
{
|
||||||
"action": "dom_load_fail",
|
"action": "dom_load_fail",
|
||||||
"data": {
|
"data": {
|
||||||
id: page.tabId
|
id: page.tabId,
|
||||||
|
url: page.url,
|
||||||
|
error: page.error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user