<!--
Copyright 2015 The Chromium Authors
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<body>
<iframe></iframe>
<script>
var frame = document.querySelector('iframe');
var port = null;
var seenRequest = false;
// Message arrives from <webview>.
window.onmessage = function(e) {
seenRequest = true;
port = e.source;
if (e.data == 'load-frames') {
// Start loading the iframe.
frame.src = 'child_frame.html';
}
};
frame.onload = function() {
if (seenRequest) {
var childFrame =
frame.contentWindow.document.getElementById('child-frame');
childFrame.onload = function() {
port.postMessage('frames-loaded', '*');
};
// Load the nested iframe.
childFrame.src = 'data:text/html,Hello';
}
};
</script>
</body>