more random browser chrome test cleanup (no bug)
authorDão Gottwald <dao@mozilla.com>
Sat, 11 Jun 2011 16:54:23 +0200
changeset 71430 85a2a18ab8ee93d178d33f9219a38d2dd2d074f0
parent 71429 ae5f9abf13d9acbc7dff10f353512e7277cd9257
child 71431 568056abc91eb5f00194b29b4548dfe1daf06592
push id159
push usereakhgari@mozilla.com
push dateTue, 16 Aug 2011 17:53:11 +0000
treeherdermozilla-beta@8786e3e49240 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone7.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
more random browser chrome test cleanup (no bug)
browser/base/content/test/browser_bug321000.js
browser/base/content/test/browser_scratchpad_files.js
browser/components/places/tests/perf/browser_ui_000_data.js
browser/components/places/tests/perf/browser_ui_bookmarks_sidebar.js
browser/components/places/tests/perf/browser_ui_history_menu.js
browser/components/places/tests/perf/browser_ui_history_sidebar.js
browser/components/places/tests/perf/browser_ui_history_sidebar_2.js
browser/components/places/tests/perf/browser_ui_history_sidebar_3.js
browser/components/places/tests/perf/browser_ui_locationbar.js
docshell/test/navigation/browser_bug343515.js
toolkit/components/downloads/test/browser/browser_nsIDownloadManagerUI.js
toolkit/mozapps/extensions/test/browser/head.js
toolkit/mozapps/extensions/test/xpinstall/head.js
--- a/browser/base/content/test/browser_bug321000.js
+++ b/browser/base/content/test/browser_bug321000.js
@@ -33,19 +33,16 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-const Ci = Components.interfaces;
-const Cc = Components.classes;
-
 const kTestString = "  hello hello  \n  world\nworld  ";
 
 var gTests = [
 
   { desc: "Urlbar strips newlines and surrounding whitespace",
     element: gURLBar,
     expected: kTestString.replace(/\s*\n\s*/g,'')
   },
@@ -82,18 +79,17 @@ function next_test() {
 
 function test_paste(aCurrentTest) {
   var element = aCurrentTest.element;
 
   // Register input listener.
   var inputListener = {
     test: aCurrentTest,
     handleEvent: function(event) {
-      var element = event.target;
-      element.removeEventListener("input", this, false);
+      element.removeEventListener(event.type, this, false);
 
       is(element.value, this.test.expected, this.test.desc);
 
       // Clear the field and go to next test.
       element.value = "";
       setTimeout(next_test, 0);
     }
   }
--- a/browser/base/content/test/browser_scratchpad_files.js
+++ b/browser/base/content/test/browser_scratchpad_files.js
@@ -1,16 +1,12 @@
 /* vim: set ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const Cu = Components.utils;
-
 Cu.import("resource://gre/modules/NetUtil.jsm");
 Cu.import("resource://gre/modules/FileUtils.jsm");
 
 // Reference to the Scratchpad chrome window object.
 let gScratchpadWindow;
 
 // Reference to the Scratchpad object.
 let gScratchpad;
--- a/browser/components/places/tests/perf/browser_ui_000_data.js
+++ b/browser/components/places/tests/perf/browser_ui_000_data.js
@@ -47,26 +47,16 @@ and bookmarks.
 */
 
 /*********************** begin header **********************/
 waitForExplicitFinish();
 
 const TEST_IDENTIFIER = "ui-perf-test";
 const TEST_SUITE = "places";
 
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const Cr = Components.results;
-
-var wm = Cc["@mozilla.org/appshell/window-mediator;1"].
-         getService(Ci.nsIWindowMediator);
-var win = wm.getMostRecentWindow("navigator:browser");
-
-var ios = Cc["@mozilla.org/network/io-service;1"].
-          getService(Ci.nsIIOService);
 var hs = Cc["@mozilla.org/browser/nav-history-service;1"].
          getService(Ci.nsINavHistoryService);
 var bs = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
          getService(Ci.nsINavBookmarksService);
 
 function add_visit(aURI, aDate) {
   var placeID = hs.addVisit(aURI,
                             aDate,
@@ -107,17 +97,17 @@ ptests.push({
         var visit_date_microsec = Date.now() * 1000;
         var day_counter = 0;
         
         var start = Date.now();
         for (var i = 0; i < days; i++) {
           visit_date_microsec -= 86400 * 1000 * 1000; // remove a day
           var spec = "http://example.com/" + visit_date_microsec;
           for (var j = 0; j < visits_per_day; j++) {
-            var uri = ios.newURI(spec + j, null, null);
+            var uri = Services.io.newURI(spec + j, null, null);
             add_visit(uri, visit_date_microsec);
           }
         }
         var duration = Date.now() - start;
         var report = make_test_report("add_visits", duration);
         ok(true, report);
 
         // add bookmarks
@@ -127,17 +117,17 @@ ptests.push({
         // reset visit date counter
         visit_date_microsec = Date.now() * 1000;
         var bookmark_counter = 0;
         start = Date.now();
         for (var i = 0; i < days; i++) {
           visit_date_microsec -= 86400 * 1000 * 1000; // remove a day
           var spec = "http://example.com/" + visit_date_microsec;
           for (var j = 0; j < visits_per_day; j++) {
-            var uri = ios.newURI(spec + j, null, null);
+            var uri = Services.io.newURI(spec + j, null, null);
             if (bookmark_counter < bookmarks_per_day) {
               add_bookmark(uri);
               bookmark_counter++;
             }
             else
               bookmark_counter = 0;
           }
         }
--- a/browser/components/places/tests/perf/browser_ui_bookmarks_sidebar.js
+++ b/browser/components/places/tests/perf/browser_ui_bookmarks_sidebar.js
@@ -42,26 +42,16 @@ Tests the performance of opening the boo
 */
 
 /*********************** begin header **********************/
 waitForExplicitFinish();
 
 const TEST_IDENTIFIER = "ui-perf-test";
 const TEST_SUITE = "places";
 
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const Cr = Components.results;
-
-var wm = Cc["@mozilla.org/appshell/window-mediator;1"].
-         getService(Ci.nsIWindowMediator);
-var win = wm.getMostRecentWindow("navigator:browser");
-
-var ios = Cc["@mozilla.org/network/io-service;1"].
-          getService(Ci.nsIIOService);
 var hs = Cc["@mozilla.org/browser/nav-history-service;1"].
          getService(Ci.nsINavHistoryService);
 var bs = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
          getService(Ci.nsINavBookmarksService);
 
 function add_visit(aURI, aDate) {
   var visitId = hs.addVisit(aURI,
                             aDate,
--- a/browser/components/places/tests/perf/browser_ui_history_menu.js
+++ b/browser/components/places/tests/perf/browser_ui_history_menu.js
@@ -39,26 +39,16 @@
 /*
 Tests the performance of opening the history menu.
 */
 
 /*********************** begin header **********************/
 const TEST_IDENTIFIER = "ui-perf-test";
 const TEST_SUITE = "places";
 
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const Cr = Components.results;
-
-var wm = Cc["@mozilla.org/appshell/window-mediator;1"].
-         getService(Ci.nsIWindowMediator);
-var win = wm.getMostRecentWindow("navigator:browser");
-
-var ios = Cc["@mozilla.org/network/io-service;1"].
-          getService(Ci.nsIIOService);
 var hs = Cc["@mozilla.org/browser/nav-history-service;1"].
          getService(Ci.nsINavHistoryService);
 var bs = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
          getService(Ci.nsINavBookmarksService);
 
 var historyMenu = document.getElementById("history-menu");
 var historyPopup = document.getElementById("goPopup");
 
--- a/browser/components/places/tests/perf/browser_ui_history_sidebar.js
+++ b/browser/components/places/tests/perf/browser_ui_history_sidebar.js
@@ -42,25 +42,16 @@ sidebar in all the available views.
 */
 
 /*********************** begin header **********************/
 waitForExplicitFinish();
 
 const TEST_IDENTIFIER = "ui-perf-test";
 const TEST_SUITE = "places";
 
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const Cr = Components.results;
-
-var wm = Cc["@mozilla.org/appshell/window-mediator;1"].
-         getService(Ci.nsIWindowMediator);
-var win = wm.getMostRecentWindow("navigator:browser");
-var ios = Cc["@mozilla.org/network/io-service;1"].
-          getService(Ci.nsIIOService);
 var hs = Cc["@mozilla.org/browser/nav-history-service;1"].
          getService(Ci.nsINavHistoryService);
 var bs = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
          getService(Ci.nsINavBookmarksService);
 
 var sidebar = document.getElementById("sidebar");
 
 function add_visit(aURI, aDate) {
--- a/browser/components/places/tests/perf/browser_ui_history_sidebar_2.js
+++ b/browser/components/places/tests/perf/browser_ui_history_sidebar_2.js
@@ -42,25 +42,16 @@ sidebar in all the available views.
 */
 
 /*********************** begin header **********************/
 waitForExplicitFinish();
 
 const TEST_IDENTIFIER = "ui-perf-test";
 const TEST_SUITE = "places";
 
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const Cr = Components.results;
-
-var wm = Cc["@mozilla.org/appshell/window-mediator;1"].
-         getService(Ci.nsIWindowMediator);
-var win = wm.getMostRecentWindow("navigator:browser");
-var ios = Cc["@mozilla.org/network/io-service;1"].
-          getService(Ci.nsIIOService);
 var hs = Cc["@mozilla.org/browser/nav-history-service;1"].
          getService(Ci.nsINavHistoryService);
 var bs = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
          getService(Ci.nsINavBookmarksService);
 
 var sidebar = document.getElementById("sidebar");
 
 function add_visit(aURI, aDate) {
--- a/browser/components/places/tests/perf/browser_ui_history_sidebar_3.js
+++ b/browser/components/places/tests/perf/browser_ui_history_sidebar_3.js
@@ -42,25 +42,16 @@ sidebar in all the available views.
 */
 
 /*********************** begin header **********************/
 waitForExplicitFinish();
 
 const TEST_IDENTIFIER = "ui-perf-test";
 const TEST_SUITE = "places";
 
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const Cr = Components.results;
-
-var wm = Cc["@mozilla.org/appshell/window-mediator;1"].
-         getService(Ci.nsIWindowMediator);
-var win = wm.getMostRecentWindow("navigator:browser");
-var ios = Cc["@mozilla.org/network/io-service;1"].
-          getService(Ci.nsIIOService);
 var hs = Cc["@mozilla.org/browser/nav-history-service;1"].
          getService(Ci.nsINavHistoryService);
 var bs = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
          getService(Ci.nsINavBookmarksService);
 
 var sidebar = document.getElementById("sidebar");
 
 function add_visit(aURI, aDate) {
--- a/browser/components/places/tests/perf/browser_ui_locationbar.js
+++ b/browser/components/places/tests/perf/browser_ui_locationbar.js
@@ -41,34 +41,22 @@ Tests the performance of opening the loc
 */
 
 /*********************** begin header **********************/
 waitForExplicitFinish();
 
 const TEST_IDENTIFIER = "ui-perf-test";
 const TEST_SUITE = "places";
 
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const Cr = Components.results;
-
-var wm = Cc["@mozilla.org/appshell/window-mediator;1"].
-         getService(Ci.nsIWindowMediator);
-var win = wm.getMostRecentWindow("navigator:browser");
-
-var ios = Cc["@mozilla.org/network/io-service;1"].
-          getService(Ci.nsIIOService);
 var hs = Cc["@mozilla.org/browser/nav-history-service;1"].
          getService(Ci.nsINavHistoryService);
 var bs = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
          getService(Ci.nsINavBookmarksService);
-var prefs = Cc["@mozilla.org/preferences-service;1"].
-            getService(Ci.nsIPrefBranch);
 
-var maxResults = prefs.getIntPref("browser.urlbar.maxRichResults");
+var maxResults = Services.prefs.getIntPref("browser.urlbar.maxRichResults");
 var onSearchComplete = gURLBar.onSearchComplete;
 
 function add_visit(aURI, aDate) {
   var visitId = hs.addVisit(aURI,
                             aDate,
                             null, // no referrer
                             hs.TRANSITION_TYPED, // user typed in URL bar
                             false, // not redirect
--- a/docshell/test/navigation/browser_bug343515.js
+++ b/docshell/test/navigation/browser_bug343515.js
@@ -1,14 +1,12 @@
 // Test for bug 343515 - Need API for tabbrowsers to tell docshells they're visible/hidden
 
 // Globals
 var testPath = "http://mochi.test:8888/browser/docshell/test/navigation/";
-var Ci = Components.interfaces;
-var Cc = Components.classes;
 var ctx = {};
 
 // Helper function to check if a window is active
 function isActive(aWindow) {
   var docshell = aWindow.QueryInterface(Ci.nsIInterfaceRequestor)
                         .getInterface(Ci.nsIWebNavigation)
                         .QueryInterface(Ci.nsIDocShell);
   return docshell.isActive;
@@ -209,15 +207,14 @@ function step7() {
 
   // That's probably enough
   allDone();
 }
 
 function allDone() {
 
   // Close the tabs we made
-  gBrowser.removeCurrentTab();
-  gBrowser.tabContainer.advanceSelectedTab(1, true);
-  gBrowser.removeCurrentTab();
+  gBrowser.removeTab(ctx.tab1);
+  gBrowser.removeTab(ctx.tab2);
 
   // Tell the framework we're done
   finish();
 }
--- a/toolkit/components/downloads/test/browser/browser_nsIDownloadManagerUI.js
+++ b/toolkit/components/downloads/test/browser/browser_nsIDownloadManagerUI.js
@@ -29,19 +29,16 @@
  * under the terms of either the GPL or the LGPL, and not to allow others to
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  * 
  * ***** END LICENSE BLOCK ***** */
-
-let Cc = Components.classes;
-let Ci = Components.interfaces;
 let Cr = Components.results;
 
 function test_visibility_open()
 {
   var dmui = Cc["@mozilla.org/download-manager-ui;1"].
              getService(Ci.nsIDownloadManagerUI);
   is(dmui.visible, true,
      "nsIDownloadManagerUI indicates that the UI is visible");
--- a/toolkit/mozapps/extensions/test/browser/head.js
+++ b/toolkit/mozapps/extensions/test/browser/head.js
@@ -1,13 +1,12 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
-Components.utils.import("resource://gre/modules/AddonManager.jsm");
 Components.utils.import("resource://gre/modules/NetUtil.jsm");
 
 var pathParts = gTestPath.split("/");
 // Drop the test filename
 pathParts.splice(pathParts.length - 1);
 
 var gTestInWindow = /-window$/.test(pathParts[pathParts.length - 1]);
 
--- a/toolkit/mozapps/extensions/test/xpinstall/head.js
+++ b/toolkit/mozapps/extensions/test/xpinstall/head.js
@@ -21,18 +21,16 @@ function extractChromeRoot(path) {
   var jar = getJar(chromeRootPath);
   if (jar) {
     var tmpdir = extractJarToTmp(jar);
     return "file://" + tmpdir.path + "/";
   }
   return chromeRootPath;
 }
 
-Components.utils.import("resource://gre/modules/AddonManager.jsm");
-
 /**
  * This is a test harness designed to handle responding to UI during the process
  * of installing an XPI. A test can set callbacks to hear about specific parts
  * of the sequence.
  * Before use setup must be called and finish must be called afterwards.
  */
 var Harness = {
   // If set then the callback is called when an install is attempted and
@@ -357,17 +355,12 @@ var Harness = {
            "Completed installs should be in the right state");
 
         this.runningInstalls.splice(this.runningInstalls.indexOf(aInstall), 1);
       }, this);
       break;
     }
   },
 
-  QueryInterface: function(iid) {
-    if (iid.equals(Components.interfaces.nsIObserver) ||
-        iid.equals(Components.interfaces.nsIWindowMediatorListener) ||
-        iid.equals(Components.interfaces.nsISupports))
-      return this;
-
-    throw Components.results.NS_ERROR_NO_INTERFACE;
-  }
+  QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver,
+                                         Ci.nsIWindowMediatorListener,
+                                         Ci.nsISupports])
 }