Bug 933226 - Less likely OOM when running browser_480148.js. r=mccr8, a=test-only
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Thu, 31 Oct 2013 21:49:26 +0200
changeset 148638 d47c873f48c1f3cc0d65047af88c0b93d3969f93
parent 148637 1d96edd4c6feae62dd087d0587ce01bbb27db46a
child 148639 22fb8d1ae29a528ee415b77c5969655ab0588bcb
push id51
push userryanvm@gmail.com
push dateFri, 01 Nov 2013 12:18:30 +0000
reviewersmccr8, test-only
bugs933226
milestone24.1.0
Bug 933226 - Less likely OOM when running browser_480148.js. r=mccr8, a=test-only
browser/components/sessionstore/test/browser_480148.js
--- a/browser/components/sessionstore/test/browser_480148.js
+++ b/browser/components/sessionstore/test/browser_480148.js
@@ -1,16 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 function test() {
   /** Test for Bug 484108 **/
   waitForExplicitFinish();
-  requestLongerTimeout(4);
+  requestLongerTimeout(5);
 
   // builds the tests state based on a few parameters
   function buildTestState(num, selected, hidden, pinned) {
     let state = { windows: [ { "tabs": [], "selected": selected + 1 } ] };
     while (num--) {
       state.windows[0].tabs.push({
         entries: [
           { url: "http://example.com/?t=" + state.windows[0].tabs.length }
@@ -157,54 +157,60 @@ function test() {
   let testIndex = 0;
 
   function runNextTest() {
     if (tests.length == 0) {
       finish();
       return;
     }
 
-    info ("Starting test " + (++testIndex));
-    let test = tests.shift();
-    let state = buildTestState(test.totalTabs, test.selectedTab,
-                               test.hiddenTabs, test.pinnedTabs);
-    let tabbarWidth = Math.floor((test.shownTabs - 0.5) * tabMinWidth);
-    let win = openDialog(location, "_blank", "chrome,all,dialog=no");
-    let tabsRestored = [];
+    let wu = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
+                   .getInterface(Components.interfaces.nsIDOMWindowUtils);
+    wu.garbageCollect();
 
-    win.addEventListener("SSTabRestoring", function onSSTabRestoring(aEvent) {
-      let tab = aEvent.originalTarget;
-      let tabLink = tab.linkedBrowser.currentURI.spec;
-      let tabIndex =
-        tabLink.substring(tabLink.indexOf("?t=") + 3, tabLink.length);
+    setTimeout(function() {
+      info ("Starting test " + (++testIndex));
+      let test = tests.shift();
+      let state = buildTestState(test.totalTabs, test.selectedTab,
+                                 test.hiddenTabs, test.pinnedTabs);
+      let tabbarWidth = Math.floor((test.shownTabs - 0.5) * tabMinWidth);
+      let win = openDialog(location, "_blank", "chrome,all,dialog=no");
+      let tabsRestored = [];
 
-      // we need to compare with the tab's restoring index, no with the
-      // position index, since the pinned tabs change the positions in the
-      // tabbar. 
-      tabsRestored.push(tabIndex);
+      win.addEventListener("SSTabRestoring", function onSSTabRestoring(aEvent) {
+        let tab = aEvent.originalTarget;
+        let tabLink = tab.linkedBrowser.currentURI.spec;
+        let tabIndex =
+          tabLink.substring(tabLink.indexOf("?t=") + 3, tabLink.length);
+
+        // we need to compare with the tab's restoring index, no with the
+        // position index, since the pinned tabs change the positions in the
+        // tabbar. 
+        tabsRestored.push(tabIndex);
 
-      if (tabsRestored.length < state.windows[0].tabs.length)
-        return;
+        if (tabsRestored.length < state.windows[0].tabs.length)
+          return;
 
-      // all of the tabs should be restoring or restored by now
-      is(tabsRestored.length, state.windows[0].tabs.length,
-         "Test #" + testIndex + ": Number of restored tabs is as expected");
+        // all of the tabs should be restoring or restored by now
+        is(tabsRestored.length, state.windows[0].tabs.length,
+           "Test #" + testIndex + ": Number of restored tabs is as expected");
 
-      is(tabsRestored.join(" "), test.order.join(" "),
-         "Test #" + testIndex + ": 'visible' tabs restored first");
+        is(tabsRestored.join(" "), test.order.join(" "),
+           "Test #" + testIndex + ": 'visible' tabs restored first");
 
-      // cleanup
-      win.removeEventListener("SSTabRestoring", onSSTabRestoring, false);
-      win.close();
-      executeSoon(runNextTest);
-    }, false);
+        // cleanup
+        win.removeEventListener("SSTabRestoring", onSSTabRestoring, false);
+        win.close();
+        executeSoon(runNextTest);
+      }, false);
 
-    whenWindowLoaded(win, function(aEvent) {
-      let extent =
-        win.outerWidth - win.gBrowser.tabContainer.mTabstrip.scrollClientSize;
-      let windowWidth = tabbarWidth + extent;
-      win.resizeTo(windowWidth, win.outerHeight);
-      ss.setWindowState(win, JSON.stringify(state), true);
-    });
+      whenWindowLoaded(win, function(aEvent) {
+        let extent =
+          win.outerWidth - win.gBrowser.tabContainer.mTabstrip.scrollClientSize;
+        let windowWidth = tabbarWidth + extent;
+        win.resizeTo(windowWidth, win.outerHeight);
+        ss.setWindowState(win, JSON.stringify(state), true);
+      });
+    }, 1000);
   };
 
   runNextTest();
 }