tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_bug846906.xhtml (3204B)


      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=846906
      6 -->
      7 <window title="Mozilla Bug 846906"
      8        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
      9 
     10  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
     11 
     12  <!-- test code goes here -->
     13  <script type="application/javascript">
     14  <![CDATA[
     15 
     16  /** Test for Bug 846906 */
     17  SimpleTest.waitForExplicitFinish();
     18 
     19  var appShellService = SpecialPowers.Services.appShell;
     20  ok(appShellService, "Should be able to get app shell service");
     21 
     22  var windowlessBrowser = appShellService.createWindowlessBrowser();
     23  ok(windowlessBrowser, "Should be able to create windowless browser");
     24 
     25  ok(windowlessBrowser instanceof Ci.nsIWindowlessBrowser,
     26     "Windowless browser should implement nsIWindowlessBrowser");
     27 
     28  var webNavigation = windowlessBrowser.QueryInterface(Ci.nsIWebNavigation);
     29  ok(webNavigation, "Windowless browser should implement nsIWebNavigation");
     30 
     31  var interfaceRequestor = windowlessBrowser.QueryInterface(Ci.nsIInterfaceRequestor);
     32  ok(interfaceRequestor, "Should be able to query interface requestor interface");
     33 
     34  var docShell = windowlessBrowser.docShell;
     35  ok(docShell, "Should be able to get doc shell interface");
     36 
     37  var document = webNavigation.document;
     38  ok(document, "Should be able to get document");
     39 
     40  var iframe = document.createXULElement("iframe");
     41  ok(iframe, "Should be able to create iframe");
     42 
     43  iframe.onload = function () {
     44    ok(true, "Should receive initial onload event");
     45 
     46    iframe.onload = function () {
     47        ok(true, "Should receive onload event");
     48 
     49        var contentDocument = iframe.contentDocument;
     50        ok(contentDocument, "Should be able to get content document");
     51 
     52        var div = contentDocument.getElementById("div1");
     53        ok(div, "Should be able to get element by id");
     54 
     55        var rect = div.getBoundingClientRect();
     56        ok(rect, "Should be able to get bounding client rect");
     57 
     58        // xxx: can we do better than hardcoding these values here?
     59        is(rect.width, 1024);
     60        is(rect.height, 768);
     61 
     62        windowlessBrowser.close();
     63 
     64        // Once the browser is closed, nsIWebNavigation and
     65        // nsIInterfaceRequestor methods should no longer be accessible.
     66        try {
     67          windowlessBrowser.getInterface(Ci.nsIDocShell);
     68          ok(false);
     69        } catch (e) {
     70          is(e.result, Cr.NS_ERROR_NULL_POINTER);
     71        }
     72 
     73        try {
     74          windowlessBrowser.document;
     75          ok(false);
     76        } catch (e) {
     77          is(e.result, Cr.NS_ERROR_NULL_POINTER);
     78        }
     79 
     80        SimpleTest.finish();
     81    };
     82    iframe.setAttribute("src", "http://mochi.test:8888/chrome/docshell/test/chrome/bug846906.html");
     83  };
     84  document.documentElement.appendChild(iframe);
     85 
     86  ]]>
     87  </script>
     88 
     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>
     93  </body>
     94 </window>