docshell/test/chrome/test_bug846906.xul

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/docshell/test/chrome/test_bug846906.xul	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,72 @@
     1.4 +<?xml version="1.0"?>
     1.5 +<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
     1.6 +<?xml-stylesheet type="text/css" href="/tests/SimpleTest/test.css"?>
     1.7 +<!--
     1.8 +https://bugzilla.mozilla.org/show_bug.cgi?id=846906
     1.9 +-->
    1.10 +<window title="Mozilla Bug 846906"
    1.11 +        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    1.12 +
    1.13 +  <script type="application/javascript"
    1.14 +          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
    1.15 +
    1.16 +  <!-- test code goes here -->
    1.17 +  <script type="application/javascript">
    1.18 +  <![CDATA[
    1.19 +
    1.20 +  /** Test for Bug 846906 **/
    1.21 +  SimpleTest.waitForExplicitFinish();
    1.22 +
    1.23 +  var appShellService = Components.classes["@mozilla.org/appshell/appShellService;1"]
    1.24 +                                  .getService(Components.interfaces.nsIAppShellService);
    1.25 +  ok(appShellService, "Should be able to get app shell service");
    1.26 +
    1.27 +  var webNavigation = appShellService.createWindowlessBrowser();
    1.28 +  ok(webNavigation, "Should be able to create windowless browser");
    1.29 +
    1.30 +  var interfaceRequestor = webNavigation.QueryInterface(Components.interfaces.nsIInterfaceRequestor);
    1.31 +  ok(interfaceRequestor, "Should be able to query interface requestor interface");
    1.32 +
    1.33 +  var docShell = interfaceRequestor.getInterface(Components.interfaces.nsIDocShell);
    1.34 +  ok(docShell, "Should be able to get doc shell interface");
    1.35 + 
    1.36 +  var document = webNavigation.document;
    1.37 +  ok(document, "Should be able to get document");
    1.38 +
    1.39 +  var iframe = document.createElement("iframe");
    1.40 +  ok(iframe, "Should be able to create iframe");
    1.41 +
    1.42 +  iframe.onload = function () {
    1.43 +    ok(true, "Should receive initial onload event");
    1.44 +
    1.45 +    iframe.onload = function () {
    1.46 +        ok(true, "Should receive onload event");
    1.47 +
    1.48 +        var contentDocument = iframe.contentDocument;
    1.49 +        ok(contentDocument, "Should be able to get content document");
    1.50 +
    1.51 +        var div = contentDocument.getElementById("div1");
    1.52 +        ok(div, "Should be able to get element by id");
    1.53 +
    1.54 +        var rect = div.getBoundingClientRect();
    1.55 +        ok(rect, "Should be able to get bounding client rect");
    1.56 +
    1.57 +        // xxx: can we do better than hardcoding these values here?
    1.58 +        is(rect.width, 1024);
    1.59 +        is(rect.height, 768);
    1.60 +
    1.61 +        SimpleTest.finish();
    1.62 +    };
    1.63 +    iframe.setAttribute("src", "http://mochi.test:8888/chrome/docshell/test/chrome/bug846906.html");
    1.64 +  };
    1.65 +  document.documentElement.appendChild(iframe);
    1.66 +    
    1.67 +  ]]>
    1.68 +  </script>
    1.69 +
    1.70 +  <!-- test results are displayed in the html:body -->
    1.71 +  <body xmlns="http://www.w3.org/1999/xhtml">
    1.72 +  <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=846906"
    1.73 +     target="_blank">Mozilla Bug 846906</a>
    1.74 +  </body>
    1.75 +</window>

mercurial