Bug 1882714 [wpt PR 44850] - Update wpt metadata, a=testonly
[gecko.git] / widget / tests / test_bug760802.xhtml
blob831b4dea93dc7cf30caa292f9bc95c1e1f9a2ef3
1 <?xml version="1.0"?>
2 <?xml-stylesheet type="text/css" href="chrome://global/skin"?>
3 <?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
4 <!--
5 https://bugzilla.mozilla.org/show_bug.cgi?id=760802
6 -->
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>
15 <p id="display"></p>
16 <div id="content" style="display: none"/>
17 <iframe id="iframe_not_editable" width="300" height="150"
18 src="data:text/html,&lt;html&gt;&lt;body&gt;&lt;/body&gt;&lt;/html&gt;"/><br/>
19 </body>
21 <!-- test code goes here -->
22 <script type="application/javascript"><![CDATA[
23 SimpleTest.waitForExplicitFinish();
25 function getBaseWindowInterface(win) {
26 return win.docShell
27 .treeOwner
28 .nsIBaseWindow;
31 function getBaseWindowInterfaceFromDocShell(win) {
32 return win.docShell.QueryInterface(Ci.nsIBaseWindow);
35 function shouldThrowException(fun, exception) {
36 try {
37 fun.call();
38 return false;
39 } catch (e) {
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);
56 ok(
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");
75 dialog.close();
77 todo(false, "the nativeHandle of a window without a mainWidget should be empty"); // how to build a window without a mainWidget ?
79 SimpleTest.finish();
80 ]]></script>
81 </window>