Reference to the answer for my previous question here. Briefly: When an error occurs in a navigation webRequest
(e.g. a DNS lookup error), the URL to which the tab navigates is available in the url
property of webNavigation.onDOMContentLoaded
event for the navigation to the displayed error page, but the actual URL displayed (i.e. the about:neterror
URL) is not available through other means.
I want to follow the answer's method for getting the error page URL. I wrote this example code where I receive an error page in the browser but when I use webNavigation.onDOMContentLoaded
to get the actual URL for the error, the code returns nothing at all. Note that, the code returns the correct URL if there is no error.
Here is my example (test.js):
var filter = {
url:
[
{hostContains: "pagedoesnotexist.com"}
]
}
function logOnDOMContentLoaded(details) {
console.log("onDOMContentLoaded: " + details.url);
}
browser.webNavigation.onDOMContentLoaded.addListener(logOnDOMContentLoaded, filter);
And, the manifest.json
{
"manifest_version": 2,
"name": "test
"version": "1.0",
"background": {
"scripts": ["test.js"]
},
"permissions": [
"<all_urls>",
"activeTab",
"tabs",
"storage",
"webRequest",
"webNavigation"
]
}