Backed out changeset c6c9fb016b33 (bug 1041297) for mochitest-bc failures.
authorRyan VanderMeulen <ryanvm@gmail.com>
Fri, 06 Mar 2015 13:38:48 -0500
changeset 250274 33176406bcfe
parent 250273 c3e7a20e8c91
child 250275 f64d1d504422
push id4533
push userryanvm@gmail.com
push date2015-03-06 18:38 +0000
treeherdermozilla-beta@f64d1d504422 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1041297
milestone37.0
backs outc6c9fb016b33
Backed out changeset c6c9fb016b33 (bug 1041297) for mochitest-bc failures.
browser/base/content/test/general/browser_tab_dragdrop2.js
browser/base/content/test/general/browser_tab_dragdrop2_frame1.xul
--- a/browser/base/content/test/general/browser_tab_dragdrop2.js
+++ b/browser/base/content/test/general/browser_tab_dragdrop2.js
@@ -1,57 +1,52 @@
-"use strict";
-
-const ROOT = getRootDirectory(gTestPath);
-const URI = ROOT + "browser_tab_dragdrop2_frame1.xul";
-
-// Load the test page (which runs some child popup tests) in a new window.
-// After the tests were run, tear off the tab into a new window and run popup
-// tests a second time. We don't care about tests results, exceptions and
-// crashes will be caught.
-add_task(function* () {
-  // Open a new window.
-  let args = "chrome,all,dialog=no";
-  let win = window.openDialog(getBrowserURL(), "_blank", args, URI);
-
-  // Wait until the tests were run.
-  yield promiseTestsDone(win);
-  ok(true, "tests succeeded");
-
-  // Create a second tab so that we can move the original one out.
-  win.gBrowser.addTab("about:blank", {skipAnimation: true});
-
-  // Tear off the original tab.
-  let browser = win.gBrowser.selectedBrowser;
-  let tabClosed = promiseWaitForEvent(browser, "pagehide", true);
-  let win2 = win.gBrowser.replaceTabWithWindow(win.gBrowser.tabs[0]);
+function test()
+{
+  waitForExplicitFinish();
 
-  // Add a 'TestsDone' event listener to ensure that the docShells is properly
-  // swapped to the new window instead of the page being loaded again. If this
-  // works fine we should *NOT* see a TestsDone event.
-  let onTestsDone = () => ok(false, "shouldn't run tests when tearing off");
-  win2.addEventListener("TestsDone", onTestsDone);
-
-  // Wait until the original tab is gone and the new window is ready.
-  yield Promise.all([tabClosed, promiseDelayedStartupFinished(win2)]);
-
-  // Remove the 'TestsDone' event listener as now
-  // we're kicking off a new test run manually.
-  win2.removeEventListener("TestsDone", onTestsDone);
+  var level1 = false;
+  var level2 = false;
+  function test1() {
+    // Load the following URI (which runs some child popup tests) in a new window (B),
+    // then add a blank tab to B and call replaceTabWithWindow to detach the URI tab
+    // into yet a new window (C), then close B.
+    // Now run the tests again and then close C.
+    // The test results does not matter, all this is just to exercise some code to
+    // catch assertions or crashes.
+    var chromeroot = getRootDirectory(gTestPath);
+    var uri = chromeroot + "browser_tab_dragdrop2_frame1.xul";
+    let window_B = openDialog(location, "_blank", "chrome,all,dialog=no,left=200,top=200,width=200,height=200", uri);
+    window_B.addEventListener("load", function(aEvent) {
+      window_B.removeEventListener("load", arguments.callee, false);
+      if (level1) return; level1=true;
+      executeSoon(function () {
+        window_B.gBrowser.addEventListener("load", function(aEvent) {
+          window_B.removeEventListener("load", arguments.callee, true);
+          if (level2) return; level2=true;
+          is(window_B.gBrowser.getBrowserForTab(window_B.gBrowser.tabs[0]).contentWindow.location, uri, "sanity check");
+          //alert("1:"+window_B.gBrowser.getBrowserForTab(window_B.gBrowser.tabs[0]).contentWindow.location);
+          var windowB_tab2 = window_B.gBrowser.addTab("about:blank", {skipAnimation: true});
+          setTimeout(function () {
+            //alert("2:"+window_B.gBrowser.getBrowserForTab(window_B.gBrowser.tabs[0]).contentWindow.location);
+            window_B.gBrowser.addEventListener("pagehide", function(aEvent) {
+              window_B.gBrowser.removeEventListener("pagehide", arguments.callee, true);
+              executeSoon(function () {
+                // alert("closing window_B which has "+ window_B.gBrowser.tabs.length+" tabs\n"+
+                //      window_B.gBrowser.getBrowserForTab(window_B.gBrowser.tabs[0]).contentWindow.location);
+                window_B.close();
 
-  // Run tests once again.
-  let promise = promiseTestsDone(win2);
-  win2.content.test_panels();
-  yield promise;
-  ok(true, "tests succeeded a second time");
+                var doc = window_C.gBrowser.getBrowserForTab(window_C.gBrowser.tabs[0])
+                            .docShell.contentViewer.DOMDocument;
+                var calls = doc.defaultView.test_panels();
+                window_C.close();
+                finish();
+              });
+            }, true);
+            window_B.gBrowser.selectedTab = window_B.gBrowser.tabs[0];
+            var window_C = window_B.gBrowser.replaceTabWithWindow(window_B.gBrowser.tabs[0]);
+            }, 1000);  // 1 second to allow the tests to create the popups
+        }, true);
+      });
+    }, false);
+  }
 
-  // Cleanup.
-  yield promiseWindowClosed(win2);
-  yield promiseWindowClosed(win);
-});
-
-function promiseTestsDone(win) {
-  return promiseWaitForEvent(win, "TestsDone");
+  test1();
 }
-
-function promiseDelayedStartupFinished(win) {
-  return new Promise(resolve => whenDelayedStartupFinished(win, resolve));
-}
--- a/browser/base/content/test/general/browser_tab_dragdrop2_frame1.xul
+++ b/browser/base/content/test/general/browser_tab_dragdrop2_frame1.xul
@@ -32,43 +32,41 @@
 
   <!-- test code goes here -->
   <script type="application/javascript"><![CDATA[
 
 SimpleTest.waitForExplicitFinish();
 
 var currentTest = null;
 
-var i, waitSteps;
+var i = 0;
 var my_debug = false;
 function test_panels()
 {
-  i = waitSteps = 0;
   checkTreeCoords();
 
   addEventListener("popupshown", popupShown, false);
   addEventListener("popuphidden", nextTest, false);
   return nextTest();
 }
 
 function nextTest()
 {
   ok(true,"popuphidden " + i)
   if (i == tests.length) {
-    let details = {bubbles: true, cancelable: false};
-    document.dispatchEvent(new CustomEvent("TestsDone", details));
     return i;
   }
 
   currentTest = tests[i];
   var panel = createPanel(currentTest.attrs);
-  SimpleTest.waitForFocus(() => currentTest.test(panel));
+  currentTest.test(panel);
   return i;
 }
 
+var waitSteps = 0;
 function popupShown(event)
 {
   var panel = event.target;
   if (waitSteps > 0 && navigator.platform.indexOf("Linux") >= 0 &&
       panel.boxObject.screenY == 210) {
     waitSteps--;
     setTimeout(popupShown, 10, event);
     return;