Bug 769771: add support for specifying content type of an html:iframe, r=bz

--HG--
extra : transplant_source : %97%CDKKQ%11%F4%98%C0%D6e%B81%BE6a%3Ah_%07
This commit is contained in:
Gavin Sharp 2012-06-29 15:03:53 -04:00
parent 1744d44393
commit f7ba48e261
5 changed files with 96 additions and 1 deletions

View File

@ -622,7 +622,7 @@ SetTreeOwnerAndChromeEventHandlerOnDocshellTree(nsIDocShellTreeItem* aItem,
/**
* Set the type of the treeitem and hook it up to the treeowner.
* @param aItem the treeitem we're wrking working with
* @param aItem the treeitem we're working with
* @param aOwningContent the content node that owns aItem
* @param aTreeOwner the relevant treeowner; might be null
* @param aParentType the nsIDocShellTreeItem::GetType of our parent docshell
@ -643,6 +643,8 @@ AddTreeItemToTreeOwner(nsIDocShellTreeItem* aItem, nsIContent* aOwningContent,
if (aOwningContent->IsXUL()) {
aOwningContent->GetAttr(kNameSpaceID_None, nsGkAtoms::type, value);
} else {
aOwningContent->GetAttr(kNameSpaceID_None, nsGkAtoms::mozframetype, value);
}
// we accept "content" and "content-xxx" values.

View File

@ -31,6 +31,7 @@
GK_ATOM(_empty, "")
GK_ATOM(moz, "_moz")
GK_ATOM(mozframetype, "mozframetype")
GK_ATOM(mozallowfullscreen, "mozallowfullscreen")
GK_ATOM(moztype, "_moz-type")
GK_ATOM(mozdirty, "_moz_dirty")

View File

@ -93,6 +93,8 @@ _TEST_FILES = \
test_bug311007.xul \
bug311007_window.xul \
test_principalInherit.xul \
test_mozFrameType.xul \
mozFrameType_window.xul \
$(NULL)
_DOCSHELL_SUBHARNESS = \

View File

@ -0,0 +1,51 @@
<?xml version="1.0"?>
<!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
<window title="Test mozFrameType attribute"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="runTests();">
<html:iframe id="normalFrame"/>
<html:iframe id="typeContentFrame" mozframetype="content"/>
<script type="application/javascript" src="docshell_helpers.js" />
<script type="application/javascript"><![CDATA[
function runTests() {
let opener = window.opener;
let SimpleTest = opener.wrappedJSObject.SimpleTest;
let Ci = Components.interfaces;
function getDocShellType(frame) {
return frame.contentWindow.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDocShell)
.QueryInterface(Ci.nsIDocShellTreeItem)
.itemType;
}
var normalFrame = document.getElementById("normalFrame");
var typeContentFrame = document.getElementById("typeContentFrame");
SimpleTest.is(getDocShellType(normalFrame), Ci.nsIDocShellTreeItem.typeChrome,
"normal iframe in chrome document is typeChrome");
SimpleTest.is(getDocShellType(typeContentFrame), Ci.nsIDocShellTreeItem.typeContent,
"iframe with mozFrameType='content' in chrome document is typeContent");
// Wait for the window to be closed before finishing the test
let ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
.getService(Components.interfaces.nsIWindowWatcher);
ww.registerNotification(function(subject, topic, data) {
if (topic == "domwindowclosed") {
ww.unregisterNotification(arguments.callee);
SimpleTest.waitForFocus(function() {
SimpleTest.finish();
}, opener);
}
});
window.close();
}
]]></script>
</window>

View File

@ -0,0 +1,39 @@
<?xml version="1.0"?>
<!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet
href="chrome://mochikit/content/tests/SimpleTest/test.css"
type="text/css"?>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=769771
-->
<window title="Test mozFrameType attribute"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<title>Test mozFrameType attribute</title>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<body xmlns="http://www.w3.org/1999/xhtml">
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
</pre>
</body>
<script class="testbody" type="application/javascript">
<![CDATA[
/** Test for Bug 769771 **/
SimpleTest.waitForExplicitFinish();
window.open("mozFrameType_window.xul", "mozFrameType",
"chrome,width=600,height=600");
]]>
</script>
</window>