<!DOCTYPE html>
<script>
// Tries to open two popups and reports how many successfully opened.
function openPopupsAndReport() {
var popups = 0;
return new Promise(resolve => {
window.addEventListener('message', function(a) {
if (a.data == 1) {
let popup = !!window.open();
popups += popup ? 1 : 0;
} else {
resolve(popups);
}
});
window.postMessage(1, document.location);
window.postMessage(1, document.location);
window.postMessage(2, document.location);
});
}
</script>