Skip to content

Commit

Permalink
Some test files
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrews54757 committed Nov 21, 2023
1 parent cc480ac commit 64619bf
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/iframe.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<title>iframe test</title>
</head>
<body>
<h1>Hello world!</h1>
<script>
// send a message to the parent
window.parent.postMessage('hello parent!', '*');
</script>
</body>
</html>
31 changes: 31 additions & 0 deletions test/iframetest.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!DOCTYPE html>
<html>
<head>
<title>iframe test</title>
<script>
const queue = [];
// listen for messages from the iframe
window.addEventListener('message', function(e) {
console.log('parent received message!:', e);
const el = document.createElement('div');
el.textContent = JSON.stringify(e.data);
const logEl = document.getElementById('log');
if (logEl) {
queue.forEach(function(el) {
logEl.appendChild(el);
});
queue.length = 0;
logEl.appendChild(el);
} else {
queue.push(el);
}
}, false);
</script>
</head>
<body>
<h1>Message Event Data</h1>
<div id="log"></div>
<iframe src="iframe.html" width="100%" height="100%"></iframe>

</body>
</html>

0 comments on commit 64619bf

Please sign in to comment.