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=846906
7 <window title=
"Mozilla Bug 846906"
8 xmlns=
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
10 <script src=
"chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
12 <!-- test code goes here -->
13 <script type=
"application/javascript">
16 /** Test for Bug
846906 */
17 SimpleTest.waitForExplicitFinish();
19 var appShellService = SpecialPowers.Services.appShell;
20 ok(appShellService,
"Should be able to get app shell service");
22 var windowlessBrowser = appShellService.createWindowlessBrowser();
23 ok(windowlessBrowser,
"Should be able to create windowless browser");
25 ok(windowlessBrowser instanceof Ci.nsIWindowlessBrowser,
26 "Windowless browser should implement nsIWindowlessBrowser");
28 var webNavigation = windowlessBrowser.QueryInterface(Ci.nsIWebNavigation);
29 ok(webNavigation,
"Windowless browser should implement nsIWebNavigation");
31 var interfaceRequestor = windowlessBrowser.QueryInterface(Ci.nsIInterfaceRequestor);
32 ok(interfaceRequestor,
"Should be able to query interface requestor interface");
34 var docShell = windowlessBrowser.docShell;
35 ok(docShell,
"Should be able to get doc shell interface");
37 var document = webNavigation.document;
38 ok(document,
"Should be able to get document");
40 var iframe = document.createXULElement(
"iframe");
41 ok(iframe,
"Should be able to create iframe");
43 iframe.onload = function () {
44 ok(true,
"Should receive initial onload event");
46 iframe.onload = function () {
47 ok(true,
"Should receive onload event");
49 var contentDocument = iframe.contentDocument;
50 ok(contentDocument,
"Should be able to get content document");
52 var div = contentDocument.getElementById(
"div1");
53 ok(div,
"Should be able to get element by id");
55 var rect = div.getBoundingClientRect();
56 ok(rect,
"Should be able to get bounding client rect");
58 // xxx: can we do better than hardcoding these values here?
62 windowlessBrowser.close();
64 // Once the browser is closed, nsIWebNavigation and
65 // nsIInterfaceRequestor methods should no longer be accessible.
67 windowlessBrowser.getInterface(Ci.nsIDocShell);
70 is(e.result, Cr.NS_ERROR_NULL_POINTER);
74 windowlessBrowser.document;
77 is(e.result, Cr.NS_ERROR_NULL_POINTER);
82 iframe.setAttribute(
"src",
"http://mochi.test:8888/chrome/docshell/test/chrome/bug846906.html");
84 document.documentElement.appendChild(iframe);
89 <!-- test results are displayed in the html:body -->
90 <body xmlns=
"http://www.w3.org/1999/xhtml">
91 <a href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=846906"
92 target=
"_blank">Mozilla Bug
846906</a>