<!doctype html>
<script type="text/javascript">
window.testIframe = function(extensionId, iframeSrc) {
var iframe = document.createElement('iframe');
var responseSent = false;
return new Promise(resolve => {
window.onmessage = function(e) {
if (!responseSent) {
responseSent = true;
resolve(e.data);
document.body.removeChild(iframe);
}
};
iframe.onload = function() {
iframe.contentWindow.postMessage('ping', '*');
};
iframe.src = 'chrome-extension://' + extensionId + '/' + iframeSrc;
document.body.appendChild(iframe);
});
};
</script>