Bug 745303 - Part 2 - Correct Panorama tests; r=dietrich
authorTim Taubert <tim.taubert@gmx.de>
Thu, 19 Apr 2012 08:24:47 +0200
changeset 95226 15387b04ebf2f8c004dceab202caac8a0b415aa6
parent 95225 d42051ed9a815167b4684ed7965904a9c85e12a5
child 95227 c2ee16305bc6289def44a42abcc9b136a7493ed3
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdietrich
bugs745303
milestone14.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 745303 - Part 2 - Correct Panorama tests; r=dietrich
browser/components/tabview/test/Makefile.in
browser/components/tabview/test/browser_tabview_bug595020.js
browser/components/tabview/test/browser_tabview_bug597248.js
browser/components/tabview/test/browser_tabview_bug627288.js
browser/components/tabview/test/browser_tabview_bug655269.js
browser/components/tabview/test/browser_tabview_bug677310.js
browser/components/tabview/test/browser_tabview_thumbnail_storage.js
--- a/browser/components/tabview/test/Makefile.in
+++ b/browser/components/tabview/test/Makefile.in
@@ -66,17 +66,16 @@ include $(topsrcdir)/config/rules.mk
                  browser_tabview_bug595521.js \
                  browser_tabview_bug595560.js \
                  browser_tabview_bug595601.js \
                  browser_tabview_bug595804.js \
                  browser_tabview_bug595930.js \
                  browser_tabview_bug595943.js \
                  browser_tabview_bug595965.js \
                  browser_tabview_bug596781.js \
-                 browser_tabview_bug597248.js \
                  browser_tabview_bug597360.js \
                  browser_tabview_bug597399.js \
                  browser_tabview_bug598375.js \
                  browser_tabview_bug598600.js \
                  browser_tabview_bug599048.js \
                  browser_tabview_bug599626.js \
                  browser_tabview_bug600645.js \
                  browser_tabview_bug600812.js \
@@ -110,17 +109,16 @@ include $(topsrcdir)/config/rules.mk
                  browser_tabview_bug625195.js \
                  browser_tabview_bug625269.js \
                  browser_tabview_bug625424.js \
                  browser_tabview_bug625955.js \
                  browser_tabview_bug626368.js \
                  browser_tabview_bug626455.js \
                  browser_tabview_bug626525.js \
                  browser_tabview_bug626791.js \
-                 browser_tabview_bug627288.js \
                  browser_tabview_bug627736.js \
                  browser_tabview_bug628061.js \
                  browser_tabview_bug628165.js \
                  browser_tabview_bug628270.js \
                  browser_tabview_bug628887.js \
                  browser_tabview_bug629189.js \
                  browser_tabview_bug629195.js \
                  browser_tabview_bug630102.js \
@@ -153,17 +151,16 @@ include $(topsrcdir)/config/rules.mk
                  browser_tabview_bug656913.js \
                  browser_tabview_bug659594.js \
                  browser_tabview_bug662266.js \
                  browser_tabview_bug663421.js \
                  browser_tabview_bug665502.js \
                  browser_tabview_bug669694.js \
                  browser_tabview_bug673196.js \
                  browser_tabview_bug673729.js \
-                 browser_tabview_bug677310.js \
                  browser_tabview_bug678374.js \
                  browser_tabview_bug679853.js \
                  browser_tabview_bug681599.js \
                  browser_tabview_bug685476.js \
                  browser_tabview_bug685692.js \
                  browser_tabview_bug686654.js \
                  browser_tabview_bug696602.js \
                  browser_tabview_bug697390.js \
@@ -184,18 +181,16 @@ include $(topsrcdir)/config/rules.mk
                  browser_tabview_group.js \
                  browser_tabview_launch.js \
                  browser_tabview_multiwindow_search.js \
                  browser_tabview_privatebrowsing.js \
                  browser_tabview_rtl.js \
                  browser_tabview_search.js \
                  browser_tabview_snapping.js \
                  browser_tabview_startup_transitions.js \
-                 browser_tabview_storage_policy.js \
-                 browser_tabview_thumbnail_storage.js \
                  browser_tabview_undo_group.js \
                  dummy_page.html \
                  head.js \
                  search1.html \
                  search2.html \
                  test_bug600645.html \
                  test_bug644097.html \
                  test_bug678374.html \
--- a/browser/components/tabview/test/browser_tabview_bug595020.js
+++ b/browser/components/tabview/test/browser_tabview_bug595020.js
@@ -1,13 +1,11 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
-let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
-
 let stateStartup = {windows:[
   {tabs:[{entries:[{url:"about:home"}]}], extData:{"tabview-last-session-group-name":"title"}}
 ]};
 
 function test() {
   let assertWindowTitle = function (win, title) {
     let browser = win.gBrowser.tabs[0].linkedBrowser;
     let winTitle = win.gBrowser.getWindowTitleForBrowser(browser);
deleted file mode 100644
--- a/browser/components/tabview/test/browser_tabview_bug597248.js
+++ /dev/null
@@ -1,149 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
-   http://creativecommons.org/publicdomain/zero/1.0/ */
-
-let newTabOne;
-let newTabTwo;
-let newTabThree;
-let restoredNewTabTwoLoaded = false;
-let restoredNewTabThreeLoaded = false;
-let frameInitialized = false;
-
-function test() {
-  waitForExplicitFinish();
-  newWindowWithTabView(setupOne);
-}
-
-function setupOne(win) {
-  win.TabView.firstUseExperienced = true;
-
-  win.gBrowser.addTab("http://mochi.test:8888/browser/browser/components/tabview/test/search1.html");
-  win.gBrowser.addTab("http://mochi.test:8888/browser/browser/components/tabview/test/dummy_page.html");
-
-  afterAllTabsLoaded(function () setupTwo(win), win);
-}
-
-let restoredWin;
-
-function setupTwo(win) {
-  let contentWindow = win.TabView.getContentWindow();
-
-  let tabItems = contentWindow.TabItems.getItems();
-  is(tabItems.length, 3, "There should be 3 tab items before closing");
-
-  let numTabsToSave = tabItems.length;
-
-  // force all canvases to update, and hook in imageData save detection
-  tabItems.forEach(function(tabItem) {
-    // mark thumbnail as dirty
-    tabItem.tabCanvas.paint();
-
-    tabItem.addSubscriber("savedCachedImageData", function onSaved(item) {
-      item.removeSubscriber("savedCachedImageData", onSaved);
-
-      if (!--numTabsToSave)
-        restoreWindow();
-    });
-  });
-
-  // after the window is closed, restore it.
-  let restoreWindow = function() {
-    executeSoon(function() {
-      restoredWin = undoCloseWindow();
-      restoredWin.addEventListener("load", function onLoad(event) {
-        restoredWin.removeEventListener("load", onLoad, false);
-
-        registerCleanupFunction(function() restoredWin.close());
-        is(restoredWin.gBrowser.tabs.length, 3, "The total number of tabs is 3");
-
-        // setup tab variables and listen to the tabs load progress
-        newTabOne = restoredWin.gBrowser.tabs[0];
-        newTabTwo = restoredWin.gBrowser.tabs[1];
-        newTabThree = restoredWin.gBrowser.tabs[2];
-        restoredWin.gBrowser.addTabsProgressListener(gTabsProgressListener);
-
-        // execute code when the frame is initialized
-        let onTabViewFrameInitialized = function() {
-          restoredWin.removeEventListener(
-            "tabviewframeinitialized", onTabViewFrameInitialized, false);
-
-          let restoredContentWindow = restoredWin.TabView.getContentWindow();
-          // prevent TabItems._update being called before checking cached images
-          restoredContentWindow.TabItems._pauseUpdateForTest = true;
-
-          let nextStep = function() {
-            // since we are not sure whether the frame is initialized first or two tabs
-            // compete loading first so we need this.
-            if (restoredNewTabTwoLoaded && restoredNewTabThreeLoaded)
-              updateAndCheck();
-            else
-              frameInitialized = true;
-          }
-
-          let tabItems = restoredContentWindow.TabItems.getItems();
-          let count = tabItems.length;
-
-          tabItems.forEach(function(tabItem) {
-            tabItem.addSubscriber("showingCachedData", function onLoaded() {
-              tabItem.removeSubscriber("showingCachedData", onLoaded);
-              ok(tabItem.isShowingCachedData(),
-                "Tab item is showing cached data and is just connected. " +
-                tabItem.tab.linkedBrowser.currentURI.spec);
-              if (--count == 0)
-                nextStep();
-            });
-          });
-        }
-
-        restoredWin.addEventListener(
-          "tabviewframeinitialized", onTabViewFrameInitialized, false);
-      }, false);
-    });
-  };
-
-  win.close();
-}
-
-let gTabsProgressListener = {
-  onStateChange: function(browser, webProgress, request, stateFlags, status) {
-    // ensure about:blank doesn't trigger the code
-    if ((stateFlags & Ci.nsIWebProgressListener.STATE_STOP) &&
-        (stateFlags & Ci.nsIWebProgressListener.STATE_IS_WINDOW) &&
-         browser.currentURI.spec != "about:blank") {
-      if (newTabTwo.linkedBrowser == browser)
-        restoredNewTabTwoLoaded = true;
-      else if (newTabThree.linkedBrowser == browser)
-        restoredNewTabThreeLoaded = true;
-
-      // since we are not sure whether the frame is initialized first or two tabs
-      // compete loading first so we need this.
-      if (restoredNewTabTwoLoaded && restoredNewTabThreeLoaded) {
-        restoredWin.gBrowser.removeTabsProgressListener(gTabsProgressListener);
-
-        if (frameInitialized)
-          updateAndCheck();
-      }
-    }
-  }
-};
-
-function updateAndCheck() {
-  // force all canvas to update
-  let contentWindow = restoredWin.TabView.getContentWindow();
-
-  contentWindow.TabItems._pauseUpdateForTest = false;
-
-  let tabItems = contentWindow.TabItems.getItems();
-  tabItems.forEach(function(tabItem) {
-    tabItem.addSubscriber("updated", function onUpdated() {
-      tabItem.removeSubscriber("updated", onUpdated);
-      ok(!tabItem.isShowingCachedData(),
-         "Tab item is not showing cached data anymore. " +
-         tabItem.tab.linkedBrowser.currentURI.spec);
-    });
-    contentWindow.TabItems.update(tabItem.tab);
-  });
-
-  // clean up and finish
-  restoredWin.close();
-  finish();
-}
deleted file mode 100644
--- a/browser/components/tabview/test/browser_tabview_bug627288.js
+++ /dev/null
@@ -1,93 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
-   http://creativecommons.org/publicdomain/zero/1.0/ */
-
-function test() {
-  let cw;
-  let tab;
-
-  let testReconnectWithSameUrl = function () {
-    tab = gBrowser.loadOneTab('http://mochi.test:8888/', {inBackground: true});
-
-    afterAllTabsLoaded(function () {
-      let tabItem = tab._tabViewTabItem;
-      let data = tabItem.getStorageData(true);
-      gBrowser.removeTab(tab);
-
-      cw.TabItems.pauseReconnecting();
-      tab = gBrowser.loadOneTab('http://mochi.test:8888/', {inBackground: true});
-
-      afterAllTabsLoaded(function () {
-        tabItem = tab._tabViewTabItem;
-
-        tabItem.addSubscriber("savedCachedImageData", function onSaved() {
-          tabItem.removeSubscriber("savedCachedImageData", onSaved);
-
-          tabItem.addSubscriber("showingCachedData", function onLoaded() {
-            tabItem.removeSubscriber("showingCachedData", onLoaded);
-
-            ok(tabItem.isShowingCachedData(), 'tabItem shows cached data');
-            testChangeUrlAfterReconnect();
-          });
-
-          cw.TabItems.resumeReconnecting();
-        });
-
-        cw.Storage.saveTab(tab, data);
-        tabItem.saveThumbnail();
-      });
-    });
-  }
-
-  let testChangeUrlAfterReconnect = function () {
-    tab.linkedBrowser.loadURI('http://mochi.test:8888/browser/');
-
-    whenTabAttrModified(tab, function () {
-      cw.TabItems._update(tab);
-
-      let tabItem = tab._tabViewTabItem;
-      let currentLabel = tabItem.$tabTitle.text();
-
-      is(currentLabel, 'mochitest index /browser/', 'tab label is up-to-date');
-      testReconnectWithNewUrl();
-    });
-  }
-
-  let testReconnectWithNewUrl = function () {
-    let tabItem = tab._tabViewTabItem;
-    let data = tabItem.getStorageData(true);
-    gBrowser.removeTab(tab);
-
-    cw.TabItems.pauseReconnecting();
-    tab = gBrowser.loadOneTab('http://mochi.test:8888/', {inBackground: true});
-    cw.Storage.saveTab(tab, data);
-
-    whenTabAttrModified(tab, function () {
-      tabItem = tab._tabViewTabItem;
-      cw.TabItems.resumeReconnecting();
-      ok(!tabItem.isShowingCachedData(), 'tabItem does not show cached data');
-
-      gBrowser.removeTab(tab);
-      hideTabView(finish);
-    });
-  }
-
-  waitForExplicitFinish();
-
-  showTabView(function () {
-    cw = TabView.getContentWindow();
-    testReconnectWithSameUrl();
-  });
-}
-
-// ----------
-function whenTabAttrModified(tab, callback) {
-  let onModified = function (event) {
-    tab.removeEventListener(event.type, onModified, false);
-    // we need executeSoon here because the tabItem also listens for the
-    // TabAttrModified event. so this is to make sure the tabItem logic
-    // is executed before the test logic.
-    executeSoon(callback);
-  }
-
-  tab.addEventListener("TabAttrModified", onModified, false);
-}
--- a/browser/components/tabview/test/browser_tabview_bug655269.js
+++ b/browser/components/tabview/test/browser_tabview_bug655269.js
@@ -1,20 +1,21 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test() {
   waitForExplicitFinish();
 
   newWindowWithTabView(function (win) {
     let cw = win.TabView.getContentWindow();
-    let tabItem = win.gBrowser.tabs[0]._tabViewTabItem;
+
+    win.addEventListener("SSWindowClosing", function onClose() {
+      win.removeEventListener("SSWindowClosing", onClose);
 
-    tabItem.addSubscriber("savedCachedImageData", function onSaved() {
-      tabItem.removeSubscriber("savedCachedImageData", onSaved);
-
-      ok(cw.UI.isDOMWindowClosing, "dom window is closing");
-      waitForFocus(finish);
+      executeSoon(function () {
+        ok(cw.UI.isDOMWindowClosing, "dom window is closing");
+        waitForFocus(finish);
+      });
     });
 
     win.close();
   });
 }
deleted file mode 100644
--- a/browser/components/tabview/test/browser_tabview_bug677310.js
+++ /dev/null
@@ -1,48 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
-   http://creativecommons.org/publicdomain/zero/1.0/ */
-
-let pb = Cc["@mozilla.org/privatebrowsing;1"].
-         getService(Ci.nsIPrivateBrowsingService);
-
-function test() {
-  let thumbnailsSaved = false;
-
-  waitForExplicitFinish();
-
-  registerCleanupFunction(function () {
-    ok(thumbnailsSaved, "thumbs have been saved before entering pb mode");
-    pb.privateBrowsingEnabled = false;
-  });
-
-  afterAllTabsLoaded(function () {
-    showTabView(function () {
-      hideTabView(function () {
-        let numConditions = 2;
-
-        function check() {
-          if (--numConditions)
-            return;
-
-          togglePrivateBrowsing(finish);
-        }
-
-        let tabItem = gBrowser.tabs[0]._tabViewTabItem;
-
-        // save all thumbnails synchronously to cancel all delayed thumbnail
-        // saves that might be active
-        tabItem.saveThumbnail({synchronously: true});
-
-        // force a tabCanvas paint to flag the thumbnail as dirty
-        tabItem.tabCanvas.paint();
-
-        tabItem.addSubscriber("savedCachedImageData", function onSaved() {
-          tabItem.removeSubscriber("savedCachedImageData", onSaved);
-          thumbnailsSaved = true;
-          check();
-        });
-
-        togglePrivateBrowsing(check);
-      });
-    });
-  });
-}
deleted file mode 100644
--- a/browser/components/tabview/test/browser_tabview_thumbnail_storage.js
+++ /dev/null
@@ -1,161 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
-   http://creativecommons.org/publicdomain/zero/1.0/ */
-
-let tests = [testRawSyncSave, testRawAsyncSave, testRawLoadError,
-             testAsyncSave, testSyncSave, testOverrideAsyncSave,
-             testSaveCleanThumbnail];
-
-function test() {
-  waitForExplicitFinish();
-  loadTabView(next);
-}
-
-function testRawSyncSave() {
-  let cw = TabView.getContentWindow();
-  let url = "http://example.com/sync-url";
-  let data = "thumbnail-data-sync";
-  let saved = false;
-
-  cw.ThumbnailStorage.saveThumbnail(url, data, function (error) {
-    ok(!error, "thumbnail entry was saved");
-    ok(!saved, "thumbnail was saved synchronously");
-
-    cw.ThumbnailStorage.loadThumbnail(url, function (error, imageData) {
-      ok(!error, "thumbnail entry was loaded");
-      is(imageData, data, "valid thumbnail data received");
-      next();
-    });
-  }, {synchronously: true});
-
-  saved = true;
-}
-
-function testRawAsyncSave() {
-  let cw = TabView.getContentWindow();
-  let url = "http://example.com/async-url";
-  let data = "thumbnail-data-async";
-  let saved = false;
-
-  cw.ThumbnailStorage.saveThumbnail(url, data, function (error) {
-    ok(!error, "thumbnail entry was saved");
-    ok(saved, "thumbnail was saved asynchronously");
-
-    cw.ThumbnailStorage.loadThumbnail(url, function (error, imageData) {
-      ok(!error, "thumbnail entry was loaded");
-      is(imageData, data, "valid thumbnail data received");
-      next();
-    });
-  });
-
-  saved = true;
-}
-
-function testRawLoadError() {
-  let cw = TabView.getContentWindow();
-
-  cw.ThumbnailStorage.loadThumbnail("non-existant-url", function (error, data) {
-    ok(error, "thumbnail entry failed to load");
-    is(null, data, "no thumbnail data received");
-    next();
-  });
-}
-
-function testSyncSave() {
-  let tabItem = gBrowser.tabs[0]._tabViewTabItem;
-
-  // set the thumbnail to dirty
-  tabItem.tabCanvas.paint();
-
-  let saved = false;
-
-  whenThumbnailSaved(tabItem, function () {
-    ok(!saved, "thumbnail was saved synchronously");
-    next();
-  });
-
-  tabItem.saveThumbnail({synchronously: true});
-  saved = true;
-}
-
-function testAsyncSave() {
-  let tabItem = gBrowser.tabs[0]._tabViewTabItem;
-
-  // set the thumbnail to dirty
-  tabItem.tabCanvas.paint();
-
-  let saved = false;
-
-  whenThumbnailSaved(tabItem, function () {
-    ok(saved, "thumbnail was saved asynchronously");
-    next();
-  });
-
-  tabItem.saveThumbnail();
-  saved = true;
-}
-
-function testOverrideAsyncSave() {
-  let tabItem = gBrowser.tabs[0]._tabViewTabItem;
-
-  // set the thumbnail to dirty
-  tabItem.tabCanvas.paint();
-
-  // initiate async save
-  tabItem.saveThumbnail();
-
-  let saveCount = 0;
-
-  whenThumbnailSaved(tabItem, function () {
-    saveCount = 1;
-  });
-
-  tabItem.saveThumbnail({synchronously: true});
-
-  is(saveCount, 1, "thumbnail got saved once");
-  next();
-}
-
-function testSaveCleanThumbnail() {
-  let tabItem = gBrowser.tabs[0]._tabViewTabItem;
-
-  // set the thumbnail to dirty
-  tabItem.tabCanvas.paint();
-
-  let saveCount = 0;
-
-  whenThumbnailSaved(tabItem, function () saveCount++);
-  tabItem.saveThumbnail({synchronously: true});
-  tabItem.saveThumbnail({synchronously: true});
-
-  is(saveCount, 1, "thumbnail got saved once, only");
-  next();
-}
-
-// ----------
-function whenThumbnailSaved(tabItem, callback) {
-  tabItem.addSubscriber("savedCachedImageData", function onSaved() {
-    tabItem.removeSubscriber("savedCachedImageData", onSaved);
-    callback();
-  });
-}
-
-// ----------
-function loadTabView(callback) {
-  afterAllTabsLoaded(function () {
-    showTabView(function () {
-      hideTabView(callback);
-    });
-  });
-}
-
-// ----------
-function next() {
-  let test = tests.shift();
-
-  if (test) {
-    info("* running " + test.name + "...");
-    test();
-  } else {
-    finish();
-  }
-}