2012-09-19 13:26:19 +00:00
|
|
|
<?xml version="1.0"?>
|
|
|
|
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
|
|
|
|
<?xml-stylesheet type="text/css" href="/tests/SimpleTest/test.css"?>
|
2012-07-25 01:35:32 +00:00
|
|
|
<!--
|
|
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=760802
|
|
|
|
-->
|
2012-09-19 13:26:19 +00:00
|
|
|
<window title="Mozilla Bug 760802"
|
|
|
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
|
|
|
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
|
|
|
|
|
|
|
<!-- test results are displayed in the html:body -->
|
|
|
|
<body xmlns="http://www.w3.org/1999/xhtml">
|
|
|
|
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=760802"
|
|
|
|
target="_blank">Mozilla Bug 760802</a>
|
|
|
|
<p id="display"></p>
|
|
|
|
<div id="content" style="display: none"/>
|
|
|
|
<iframe id="iframe_not_editable" width="300" height="150"
|
|
|
|
src="data:text/html,<html><body></body></html>"/><br/>
|
|
|
|
</body>
|
|
|
|
|
|
|
|
<!-- test code goes here -->
|
|
|
|
<script type="application/javascript"><![CDATA[
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
2012-07-25 01:35:32 +00:00
|
|
|
const Cc = Components.classes;
|
|
|
|
const Ci = Components.interfaces;
|
|
|
|
|
|
|
|
function getBaseWindowInterface(win) {
|
2012-09-19 13:26:19 +00:00
|
|
|
return win.QueryInterface(Ci.nsIInterfaceRequestor)
|
2012-07-25 01:35:32 +00:00
|
|
|
.getInterface(Ci.nsIWebNavigation)
|
|
|
|
.QueryInterface(Ci.nsIDocShellTreeItem)
|
|
|
|
.treeOwner
|
|
|
|
.QueryInterface(Ci.nsIInterfaceRequestor)
|
|
|
|
.nsIBaseWindow;
|
|
|
|
}
|
|
|
|
|
2012-07-26 23:28:10 +00:00
|
|
|
function getBaseWindowInterfaceFromDocShell(win) {
|
|
|
|
return win.QueryInterface(Ci.nsIInterfaceRequestor)
|
|
|
|
.getInterface(Ci.nsIWebNavigation)
|
|
|
|
.QueryInterface(Ci.nsIDocShell)
|
|
|
|
.QueryInterface(Ci.nsIBaseWindow);
|
|
|
|
}
|
|
|
|
|
|
|
|
function shouldThrowException(fun, exception) {
|
2012-07-25 01:35:32 +00:00
|
|
|
try {
|
|
|
|
fun.call();
|
|
|
|
return false;
|
|
|
|
} catch (e) {
|
2012-09-19 13:26:19 +00:00
|
|
|
$("display").innerHTML += "<br/>OK thrown: "+e.message;
|
2012-07-26 23:28:10 +00:00
|
|
|
return (e instanceof Components.Exception &&
|
|
|
|
e.result === exception)
|
2012-07-25 01:35:32 +00:00
|
|
|
}
|
|
|
|
}
|
2012-07-26 23:28:10 +00:00
|
|
|
function doesntThrowException(fun) !shouldThrowException(fun)
|
2012-07-25 01:35:32 +00:00
|
|
|
|
2012-09-19 13:26:19 +00:00
|
|
|
var baseWindow = getBaseWindowInterface(this);
|
2012-07-25 01:35:32 +00:00
|
|
|
var nativeHandle = baseWindow.nativeHandle;
|
|
|
|
$("display").innerHTML = "found nativeHandle for this window: "+nativeHandle;
|
|
|
|
|
|
|
|
var wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
|
|
|
|
var win = wm.getMostRecentWindow("navigator:browser");
|
2012-07-26 23:28:10 +00:00
|
|
|
var docShell = getBaseWindowInterfaceFromDocShell(win);
|
2012-07-25 01:35:32 +00:00
|
|
|
|
|
|
|
ok(
|
2012-07-26 23:28:10 +00:00
|
|
|
shouldThrowException(function(){docShell.nativeHandle;},
|
|
|
|
Components.results.NS_ERROR_NOT_IMPLEMENTED),
|
2012-07-25 01:35:32 +00:00
|
|
|
"nativeHandle should not be implemented for nsDocShell"
|
|
|
|
);
|
|
|
|
|
|
|
|
ok(typeof(nativeHandle) === "string", "nativeHandle should be a string");
|
|
|
|
ok(nativeHandle.match(/^0x[0-9a-f]+$/), "nativeHandle should have a memory address format");
|
|
|
|
|
2012-09-19 13:26:19 +00:00
|
|
|
var iWin = document.getElementById("iframe_not_editable").contentWindow;
|
2012-07-25 01:35:32 +00:00
|
|
|
is(getBaseWindowInterface(iWin).nativeHandle, nativeHandle,
|
2012-09-19 13:26:19 +00:00
|
|
|
"the nativeHandle of an iframe should be its parent's nativeHandle");
|
2012-07-25 01:35:32 +00:00
|
|
|
|
2012-09-19 13:26:19 +00:00
|
|
|
var dialog = win.openDialog("data:text/plain,this is an active window.", "_blank",
|
|
|
|
"chrome,dialog=yes,width=100,height=100");
|
2012-07-25 01:35:32 +00:00
|
|
|
|
|
|
|
isnot(getBaseWindowInterface(dialog).nativeHandle, "",
|
|
|
|
"the nativeHandle of a dialog should not be empty");
|
|
|
|
|
|
|
|
dialog.close();
|
|
|
|
|
|
|
|
todo(false, "the nativeHandle of a window without a mainWidget should be empty"); // how to build a window without a mainWidget ?
|
|
|
|
|
2012-09-19 13:26:19 +00:00
|
|
|
SimpleTest.finish();
|
|
|
|
]]></script>
|
|
|
|
</window>
|