<html>
<body>
<head>
<script>
if (window.testRunner) {
  testRunner.dumpAsText();
  testRunner.waitUntilDone();
}

function log(msg) {
  var div = document.createElement('div');
  div.appendChild(document.createTextNode(msg));
  document.getElementById('console').appendChild(div);
}

window.addEventListener('message', function (e) {
  switch(e.data) {
   case 'ready':
    // Call the function stored from the old iframe content.
    setTimeout(ready_callback, 0);
    break;
   case 'done':
    if (window.testRunner)
      testRunner.notifyDone();
    break;
   default:
    log(e.data);
    break;
  }
}, false);

var stored_function = function() {
  log('FAIL: Original function called.');
};

function set_function(f) {
  // Store function in old_function.
  stored_function = f;
  // Change the source of the iframe.
  frames[0].location =
    "http://localhost:8000/security/resources/object-literals-cross-origin.html";
}

function ready_callback() {
  stored_function();
  frames[0].postMessage('go', '*');
}
</script>
</head>
<iframe src="resources/object-literals-same-origin.html"></iframe>
<div id="console">
</div>
</body>
</html>
