gecko/dom/tests/mochitest/browser-frame/test_browserFrame8.html

63 lines
1.8 KiB
HTML

<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=742448
-->
<head>
<title>Test for Bug 742448</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=742448">Mozilla Bug 742448</a>
<!--
Test that <iframe mozbrowser>'s window.{top,parent,frameElement} methods are
not confused if we override window.top ourselves.
-->
<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;
// Override window.top in the parent iframe. This shouldn't confuse the
// inner one.
Object.defineProperty(iframe.contentWindow, 'top', {
get: function() { return 42; }
});
is(iframeCw.top, 42, '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>