1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/docshell/test/chrome/test_private_hidden_window.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,56 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=829383 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 829383</title> 1.11 + <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" /> 1.13 +</head> 1.14 +<body> 1.15 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=829383">Mozilla Bug 829383</a> 1.16 +<p id="display"></p> 1.17 +<div id="content" style="display: none"> 1.18 + <iframe name="target"></iframe> 1.19 +</div> 1.20 +<pre id="test"> 1.21 +<script class="testbody" type="text/javascript"> 1.22 + 1.23 +SimpleTest.waitForExplicitFinish(); 1.24 +const Ci = Components.interfaces; 1.25 +var mainWindow = window.QueryInterface(Ci.nsIInterfaceRequestor) 1.26 + .getInterface(Ci.nsIWebNavigation) 1.27 + .QueryInterface(Ci.nsIDocShellTreeItem) 1.28 + .rootTreeItem 1.29 + .QueryInterface(Ci.nsIInterfaceRequestor) 1.30 + .getInterface(Ci.nsIDOMWindow); 1.31 + 1.32 +// We need to wait for the hidden window to load, but can't access 1.33 +// an event target for a regular event listener. 1.34 +var hidden = mainWindow.Services.appShell.hiddenPrivateDOMWindow; 1.35 +mainWindow.PrivateBrowsingUtils.whenHiddenPrivateWindowReady(function(hidden) { 1.36 + var iframe = hidden.document.createElement('iframe'); 1.37 + iframe.src = 'generic.html'; 1.38 + hidden.document.body.appendChild(iframe); 1.39 + 1.40 + var win = mainWindow.OpenBrowserWindow({private: true}); 1.41 + win.addEventListener("load", function onLoad() { 1.42 + win.removeEventListener("load", onLoad, false); 1.43 + win.close(); 1.44 + win = null; 1.45 + }, false); 1.46 +}); 1.47 + 1.48 +function observer(aSubject, aTopic, aData) { 1.49 + is(aTopic, "last-pb-context-exited", "Unexpected observer topic"); 1.50 + mainWindow.Services.obs.removeObserver(observer, "last-pb-context-exited"); 1.51 + SimpleTest.finish(); 1.52 +} 1.53 +mainWindow.Services.obs.addObserver(observer, "last-pb-context-exited", false); 1.54 + 1.55 +</script> 1.56 +</pre> 1.57 +</body> 1.58 +</html> 1.59 +