EDIT: The problem here was the third line not being written the proper way and it wouldn't work either way. browser.notifications did what I needed.
This is what I currently have. It needs to cancel the request and notify why it has been cancelled. The request cancellation part works fine, however, I am not sure where the notification code should go. I tried by adding innerhtml inside function, but that breaks the code.
browser.webRequest.onBeforeRequest.addListener(
function() {
getElementsByTagName(body).innerhtml = '<p>Test</p>'; // the problem
return {cancel: true};
},
{
urls: ["(links)"]
},
["blocking"]
);
In addition to what Paul said, I think you probably want body to be a string: