dom/tests/mochitest/browser-frame/test_browserFrame7.html
author Justin Lebar <justin.lebar@gmail.com>
Wed, 28 Mar 2012 11:36:03 -0700
changeset 93863 e69f1c7562aa9b5eea20b976dad20e7abafdba3e
child 97560 f6f8d92907b578c8bf49e32bc5d0d04d1ef17b5e
permissions -rw-r--r--
Bug 736688 - Part 2: Move browser frame tests to their own directory. r=smaug

<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=725796
-->
<head>
  <title>Test for Bug 725796</title>
  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <script type="application/javascript" src="browserFrameHelpers.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=725796">Mozilla Bug 725796</a>

<!--
  Test that an <iframe mozbrowser> is a window.{top,parent,frameElement} barrier.

  If <iframe mozbrowser> is changed to run in a separate process, this test
  will not work.
-->

<script type="application/javascript;version=1.7">
"use strict";

browserFrameHelpers.setEnabledPref(true);
browserFrameHelpers.addToWhitelist();

var iframe = document.createElement('iframe');
iframe.addEventListener('load', function() {
  outerIframeLoaded();
});
iframe.mozbrowser = true;
iframe.src = 'data:text/html,Outer iframe';
document.body.appendChild(iframe);

SimpleTest.waitForExplicitFinish();

function outerIframeLoaded() {
  var innerIframe = iframe.contentDocument.createElement('iframe');
  iframe.contentDocument.body.appendChild(innerIframe);

  var iframeCw = iframe.contentWindow;
  var innerCw = innerIframe.contentWindow;

  is(iframeCw.top, iframeCw, 'iframe top');
  is(iframeCw.parent, iframeCw, 'iframe parent');
  is(iframeCw.frameElement, null, 'iframe frameElement');

  is(innerCw.top, iframeCw, 'inner iframe top');
  is(innerCw.parent, iframeCw, 'inner iframe parent');
  is(innerCw.frameElement, innerIframe, 'inner iframe frameElement');
  SimpleTest.finish();
}

</script>
</body>
</html>