But instead of transferring of current URL with POST to http://example.com/run.html?bm and load related page, as i get it in Chrome - i get only an empty tab (about:blank).
I can imagine a couple of reasons without actually testing this myself. One would be that your code can’t access the document of window.open(), since it’s about:blank. Another one is that you’re running too early to have a document (which I have to admit, I do not know window.open well enough).
My solution suggestion would be to use the tabs API instead to read the current URL and open a tab and set the URL to a data: document or an extension html page that then does the POST redirect to your thing.
function submitForm(request, sender, sendResponse)
{
var f = document.createElement('form');
f.setAttribute('method','post');
f.setAttribute('action','http://gtmetrix.com/analyze.html?bm');
var i = document.createElement('input');
i.setAttribute('type','hidden');
i.setAttribute('name','url]');
i.setAttribute('value', request.url);
f.appendChild(i);
document.getElementsByTagName('body')[0].appendChild(f);
f.submit();
}
chrome.runtime.onMessage.addListener(submitForm);
But i currently absolutely miss debugging skills for FF - doesn’t work, don’t know why:)
Than, in the submitForm.js i execute the code with the message listener, like this:
function submitForm(request, sender, sendResponse) {
var f = document.createElement('form');
f.setAttribute('method','post');
f.setAttribute('action','https://gtmetrix.com/analyze.html?bm');
var i = document.createElement('input');
i.setAttribute('type','hidden');
i.setAttribute('name','url');
i.setAttribute('value', request.url);
f.appendChild(i);
document.getElementsByTagName('body')[0].appendChild(f);
f.submit();
}
browser.runtime.onMessage.addListener(submitForm);
New tab is indeed opening, but… remains empty grrrr
the code from my previous answer is working. But! It works ONLY after FF57 - and me, the great thinker, was testing it with FF 49. The cause of this fail is in usage of matchAboutBlank: true - which is properly working in newer FF versions.