2 <?xml-stylesheet type=
"text/css" href=
"chrome://global/skin"?>
3 <?xml-stylesheet type=
"text/css" href=
"chrome://mochikit/content/tests/SimpleTest/test.css"?>
5 https://bugzilla.mozilla.org/show_bug.cgi?id=760802
7 <window title=
"Mozilla Bug 760802"
8 xmlns=
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
9 <script src=
"chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
11 <!-- test results are displayed in the html:body -->
12 <body xmlns=
"http://www.w3.org/1999/xhtml">
13 <a href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=760802"
14 target=
"_blank">Mozilla Bug
760802</a>
16 <div id=
"content" style=
"display: none"/>
17 <iframe id=
"iframe_not_editable" width=
"300" height=
"150"
18 src=
"data:text/html,<html><body></body></html>"/><br/>
21 <!-- test code goes here -->
22 <script type=
"application/javascript"><![CDATA[
23 SimpleTest.waitForExplicitFinish();
25 function getBaseWindowInterface(win) {
31 function getBaseWindowInterfaceFromDocShell(win) {
32 return win.docShell.QueryInterface(Ci.nsIBaseWindow);
35 function shouldThrowException(fun, exception) {
40 $(
"display").innerHTML +=
"<br/>OK thrown: "+e.message;
41 return (e instanceof Components.Exception &&
42 e.result === exception)
45 function doesntThrowException(fun) {
46 return !shouldThrowException(fun);
49 var baseWindow = getBaseWindowInterface(this);
50 var nativeHandle = baseWindow.nativeHandle;
51 $(
"display").innerHTML =
"found nativeHandle for this window: "+nativeHandle;
53 var win = Services.wm.getMostRecentWindow(
"navigator:browser");
54 let docShell = getBaseWindowInterfaceFromDocShell(win);
57 shouldThrowException(function(){docShell.nativeHandle;},
58 Cr.NS_ERROR_NOT_IMPLEMENTED),
59 "nativeHandle should not be implemented for nsDocShell"
62 ok(typeof(nativeHandle) ===
"string",
"nativeHandle should be a string");
63 ok(nativeHandle.match(/^
0x[
0-
9a-f]+$/),
"nativeHandle should have a memory address format");
65 var iWin = document.getElementById(
"iframe_not_editable").contentWindow;
66 is(getBaseWindowInterface(iWin).nativeHandle, nativeHandle,
67 "the nativeHandle of an iframe should be its parent's nativeHandle");
69 var dialog = win.openDialog(
"data:text/plain,this is an active window.",
"_blank",
70 "chrome,dialog=yes,width=100,height=100");
72 isnot(getBaseWindowInterface(dialog).nativeHandle,
"",
73 "the nativeHandle of a dialog should not be empty");
77 todo(false,
"the nativeHandle of a window without a mainWidget should be empty"); // how to build a window without a mainWidget ?