docshell/test/chrome/test_private_hidden_window.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 <!DOCTYPE HTML>
     2 <html>
     3 <!--
     4 https://bugzilla.mozilla.org/show_bug.cgi?id=829383
     5 -->
     6 <head>
     7   <title>Test for Bug 829383</title>
     8   <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
     9   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
    10 </head>
    11 <body>
    12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=829383">Mozilla Bug 829383</a>
    13 <p id="display"></p>
    14 <div id="content" style="display: none">
    15   <iframe name="target"></iframe>
    16 </div>
    17 <pre id="test">
    18 <script class="testbody" type="text/javascript">
    20 SimpleTest.waitForExplicitFinish();
    21 const Ci = Components.interfaces;
    22 var mainWindow = window.QueryInterface(Ci.nsIInterfaceRequestor)
    23                        .getInterface(Ci.nsIWebNavigation)
    24                        .QueryInterface(Ci.nsIDocShellTreeItem)
    25                        .rootTreeItem
    26                        .QueryInterface(Ci.nsIInterfaceRequestor)
    27                        .getInterface(Ci.nsIDOMWindow);
    29 // We need to wait for the hidden window to load, but can't access
    30 // an event target for a regular event listener.
    31 var hidden = mainWindow.Services.appShell.hiddenPrivateDOMWindow;
    32 mainWindow.PrivateBrowsingUtils.whenHiddenPrivateWindowReady(function(hidden) {
    33   var iframe = hidden.document.createElement('iframe');
    34   iframe.src = 'generic.html';
    35   hidden.document.body.appendChild(iframe);
    37   var win = mainWindow.OpenBrowserWindow({private: true});
    38   win.addEventListener("load", function onLoad() {
    39     win.removeEventListener("load", onLoad, false);
    40     win.close();
    41     win = null;
    42   }, false);
    43 });
    45 function observer(aSubject, aTopic, aData) {
    46   is(aTopic, "last-pb-context-exited", "Unexpected observer topic");
    47   mainWindow.Services.obs.removeObserver(observer, "last-pb-context-exited");
    48   SimpleTest.finish();
    49 }
    50 mainWindow.Services.obs.addObserver(observer, "last-pb-context-exited", false);
    52 </script>
    53 </pre>
    54 </body>
    55 </html>

mercurial