michael@0: function test() michael@0: { michael@0: waitForExplicitFinish(); michael@0: michael@0: var level1 = false; michael@0: var level2 = false; michael@0: function test1() { michael@0: // Load the following URI (which runs some child popup tests) in a new window (B), michael@0: // then add a blank tab to B and call replaceTabWithWindow to detach the URI tab michael@0: // into yet a new window (C), then close B. michael@0: // Now run the tests again and then close C. michael@0: // The test results does not matter, all this is just to exercise some code to michael@0: // catch assertions or crashes. michael@0: var chromeroot = getRootDirectory(gTestPath); michael@0: var uri = chromeroot + "browser_tab_dragdrop2_frame1.xul"; michael@0: let window_B = openDialog(location, "_blank", "chrome,all,dialog=no,left=200,top=200,width=200,height=200", uri); michael@0: window_B.addEventListener("load", function(aEvent) { michael@0: window_B.removeEventListener("load", arguments.callee, false); michael@0: if (level1) return; level1=true; michael@0: executeSoon(function () { michael@0: window_B.gBrowser.addEventListener("load", function(aEvent) { michael@0: window_B.removeEventListener("load", arguments.callee, true); michael@0: if (level2) return; level2=true; michael@0: is(window_B.gBrowser.getBrowserForTab(window_B.gBrowser.tabs[0]).contentWindow.location, uri, "sanity check"); michael@0: //alert("1:"+window_B.gBrowser.getBrowserForTab(window_B.gBrowser.tabs[0]).contentWindow.location); michael@0: var windowB_tab2 = window_B.gBrowser.addTab("about:blank", {skipAnimation: true}); michael@0: setTimeout(function () { michael@0: //alert("2:"+window_B.gBrowser.getBrowserForTab(window_B.gBrowser.tabs[0]).contentWindow.location); michael@0: window_B.gBrowser.addEventListener("pagehide", function(aEvent) { michael@0: window_B.gBrowser.removeEventListener("pagehide", arguments.callee, true); michael@0: executeSoon(function () { michael@0: // alert("closing window_B which has "+ window_B.gBrowser.tabs.length+" tabs\n"+ michael@0: // window_B.gBrowser.getBrowserForTab(window_B.gBrowser.tabs[0]).contentWindow.location); michael@0: window_B.close(); michael@0: michael@0: var doc = window_C.gBrowser.getBrowserForTab(window_C.gBrowser.tabs[0]) michael@0: .docShell.contentViewer.DOMDocument; michael@0: var calls = doc.defaultView.test_panels(); michael@0: window_C.close(); michael@0: finish(); michael@0: }); michael@0: }, true); michael@0: window_B.gBrowser.selectedTab = window_B.gBrowser.tabs[0]; michael@0: var window_C = window_B.gBrowser.replaceTabWithWindow(window_B.gBrowser.tabs[0]); michael@0: }, 1000); // 1 second to allow the tests to create the popups michael@0: }, true); michael@0: }); michael@0: }, false); michael@0: } michael@0: michael@0: test1(); michael@0: }