Bug 792036 - Fix up tests to avoid relying on the existence of window.Components (MANUAL). r=mccr8
authorBobby Holley <bobbyholley@gmail.com>
Mon, 24 Sep 2012 14:46:28 +0200
changeset 111503 a8583bee3c377dd9878dca774d3ff01adcbea3c5
parent 111502 d3f7731dd39ce2bf65f9fe0043a1bed84114c975
child 111504 1f7c4fae49c0d80075e7b0380c4b841a5ed30ab0
push idunknown
push userunknown
push dateunknown
reviewersmccr8
bugs792036
milestone18.0a1
Bug 792036 - Fix up tests to avoid relying on the existence of window.Components (MANUAL). r=mccr8 These are the manual fixes that the ensuing auto-generation can't deal with. Some of them just fix up formatting (such as Components.\nFoo, so that subsequent auto-generation can work better).
build/bloatcycle.html
build/pgo/index.html
content/base/test/file_mixed_content_main.html
content/base/test/test_bug353334.html
content/base/test/test_bug422537.html
content/base/test/test_bug435425.html
content/base/test/test_xhr_forbidden_headers.html
content/events/test/test_bug409604.html
content/html/content/test/forms/test_max_attribute.html
content/html/content/test/forms/test_min_attribute.html
content/html/content/test/forms/test_required_attribute.html
content/html/content/test/forms/test_step_attribute.html
content/html/content/test/test_bug143220.html
content/html/content/test/test_bug389797.html
content/html/content/test/test_bug523771.html
content/html/content/test/test_bug590353-2.html
content/html/content/test/test_bug598643.html
content/xml/document/test/test_bug392338.html
docshell/test/test_bug369814.html
dom/browser-element/mochitest/browserElement_Auth.js
dom/tests/mochitest/bugs/test_bug317448.html
dom/tests/mochitest/bugs/test_bug397571.html
dom/tests/mochitest/webapps/cross_origin.html
dom/tests/mochitest/webapps/head.js
editor/libeditor/html/tests/test_CF_HTML_clipboard.html
editor/libeditor/text/tests/test_bug596333.html
gfx/tests/mochitest/test_acceleration.html
image/test/mochitest/imgutils.js
image/test/mochitest/test_bug601470.html
js/xpconnect/tests/mochitest/file_bug650273.html
js/xpconnect/tests/mochitest/test_lookupMethod.html
security/manager/ssl/tests/mochitest/mixedcontent/mixedContentTest.js
testing/mochitest/tests/test_SpecialPowersExtension.html
testing/mochitest/tests/test_sanityEventUtils.html
toolkit/components/passwordmgr/test/test_basic_form_autocomplete.html
toolkit/components/passwordmgr/test/test_prompt_async.html
toolkit/components/passwordmgr/test/test_xml_load.html
toolkit/components/places/tests/mochitest/test_bug_461710.html
toolkit/components/satchel/test/test_bug_787624.html
toolkit/identity/tests/chrome/sandbox_content_perms.html
--- a/build/bloatcycle.html
+++ b/build/bloatcycle.html
@@ -84,18 +84,17 @@ function goQuitApplication()
       getService(Components.interfaces.nsIAppShellService);
     forceQuit = Components.interfaces.nsIAppShellService.eForceQuit;
   }
   else
   {
     throw 'goQuitApplication: no AppStartup/appShell';
   }
 
-  var windowManager = Components.
-    classes['@mozilla.org/appshell/window-mediator;1'].getService();
+  var windowManager = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService();
 
   var windowManagerInterface = windowManager.
     QueryInterface(Components.interfaces.nsIWindowMediator);
 
   var enumerator = windowManagerInterface.getEnumerator(null);
 
   while (enumerator.hasMoreElements())
   {
--- a/build/pgo/index.html
+++ b/build/pgo/index.html
@@ -79,18 +79,17 @@
        getService(Components.interfaces.nsIAppShellService);
      forceQuit = Components.interfaces.nsIAppShellService.eForceQuit;
    }
    else
    {
      throw 'goQuitApplication: no AppStartup/appShell';
    }
  
-   var windowManager = Components.
-     classes['@mozilla.org/appshell/window-mediator;1'].getService();
+   var windowManager = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService();
  
    var windowManagerInterface = windowManager.
      QueryInterface(Components.interfaces.nsIWindowMediator);
  
    var enumerator = windowManagerInterface.getEnumerator(null);
  
    while (enumerator.hasMoreElements())
    {
--- a/content/base/test/file_mixed_content_main.html
+++ b/content/base/test/file_mixed_content_main.html
@@ -52,19 +52,19 @@ https://bugzilla.mozilla.org/show_bug.cg
   object.width = "200";
   object.height = "200";
 
   testContent.appendChild(object);
 
   var objectCount = 0;
 
   function objectStatus(object) {
-    object instanceof Components.interfaces.nsIObjectLoadingContent;
+    object instanceof SpecialPowers.Ci.nsIObjectLoadingContent;
 
-    if (object.displayedType != Components.interfaces.nsIObjectLoadingContent.TYPE_NULL) {
+    if (object.displayedType != SpecialPowers.Ci.nsIObjectLoadingContent.TYPE_NULL) {
       //object loaded
       parent.postMessage({"test": "object", "msg": "insecure object loaded"}, "http://mochi.test:8888");
     }
     else {
       if(objectCount < MAX_COUNT) {
         objectCount++;
         setTimeout(objectStatus, TIMEOUT_INTERVAL, object);
       }
--- a/content/base/test/test_bug353334.html
+++ b/content/base/test/test_bug353334.html
@@ -26,31 +26,30 @@ https://bugzilla.mozilla.org/show_bug.cg
 <script class="testbody" type="text/javascript">
 
 /** Test for Bug 353334 **/
 SimpleTest.waitForExplicitFinish();
 
 function doPrincipalTest(id) {
   var doc = $(id).contentDocument;
 
-  netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
   isnot(SpecialPowers.getNodePrincipal(doc), undefined, "Should have a principal");
   isnot(SpecialPowers.getNodePrincipal(doc), null, "Should have a non-null principal");
   is(SpecialPowers.getNodePrincipal(doc),
      SpecialPowers.getNodePrincipal(document),
      "Wrong principal for document in node with id='" + id + "'");
 }
 
 function doContentTest(id) {
   is($(id).contentDocument.documentElement.textContent, "PASS",
      "Script executed in wrong context in node with id='" + id + "'");
 }
 
 function checkPrincipal() {
-  is(SpecialPowers.getNodePrincipal(document) instanceof Components.interfaces.nsIPrincipal,
+  is(SpecialPowers.getNodePrincipal(document) instanceof SpecialPowers.Ci.nsIPrincipal,
      true,
      "Should be a principal");
 }
 
 addLoadEvent(function() {
   checkPrincipal();
 
   for each (var i in [ "one", "two", "three", "four" ]) {
--- a/content/base/test/test_bug422537.html
+++ b/content/base/test/test_bug422537.html
@@ -14,18 +14,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 <p id="display"></p>
 <div id="content" style="display: none">
   
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 /** Test for Bug 422537 **/
-var isupports_string = SpecialPowers.wrap(Components)
-                                    .classes["@mozilla.org/supports-string;1"]
+var isupports_string = SpecialPowers.wrap(Components).classes["@mozilla.org/supports-string;1"]
                                     .createInstance(Components.interfaces.nsISupportsString);
 isupports_string.data = "foo";
 
 const url = "http://mochi.test:8888";
 var body = [
   document,
   "foo",
   isupports_string
--- a/content/base/test/test_bug435425.html
+++ b/content/base/test/test_bug435425.html
@@ -57,24 +57,20 @@ function hasPendingNonOptionalEvent(ev) 
 
 function maybeStop(evt) {
   logEvent(evt);
   if (!hasPendingNonOptionalEvent("loadend"))
     nextTest();
 }
 
 function openXHR(xhr, method, url, privileged) {
-  try {
-    if (privileged) {
-      netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-    }
-  } catch (ex) {
-    ok(false, ex);
-  }
-  xhr.open(method, url);
+  if (privileged)
+    SpecialPowers.wrap(xhr).open(method, url);
+  else
+    xhr.open(method, url);
 }
 
 function start(obj) {
   xhr = new XMLHttpRequest();
   upload = xhr.upload;
   currentEvents = obj.expectedEvents;
   expectedResponseText = obj.withUpload;
   xhr.onload =
@@ -170,18 +166,18 @@ for (var smallLength = 0; smallLength < 
 for (var midLength = 0; midLength < (0x00000FFF + 2); ++midLength) {
   mid += "A";
 }
 
 for (var largeLength = 0; largeLength < (0x0000FFFF + 2); ++largeLength) {
   large += "A";
 }
 
-const XHR = Components.interfaces.nsIXMLHttpRequest;
-const UPLOAD = Components.interfaces.nsIXMLHttpRequestUpload;
+const XHR = SpecialPowers.Ci.nsIXMLHttpRequest;
+const UPLOAD = SpecialPowers.Ci.nsIXMLHttpRequestUpload;
 
 var tests = 
   [
     { method: "GET", withUpload: none, testAbort: false, testRedirectError: false, testNetworkError: false,
       expectedEvents: [{target: XHR, type: "loadstart", optional: false},
                        {target: XHR, type: "progress", optional: true},
                        {target: XHR, type: "load", optional: false},
                        {target: XHR, type: "loadend", optional: false}]},
--- a/content/base/test/test_xhr_forbidden_headers.html
+++ b/content/base/test/test_xhr_forbidden_headers.html
@@ -51,37 +51,36 @@ var i, request;
 
 // Try setting headers in unprivileged context
 request = new XMLHttpRequest();
 request.open("GET", window.location.href);
 for (i = 0; i < headers.length; i++)
   request.setRequestHeader(headers[i], "test" + i);
 
 // Read out headers
-var channel = SpecialPowers.wrap(request).channel.QueryInterface(Components.interfaces.nsIHttpChannel);
+var channel = SpecialPowers.wrap(request).channel.QueryInterface(SpecialPowers.Ci.nsIHttpChannel);
 for (i = 0; i < headers.length; i++) {
   // Retrieving Content-Length will throw an exception
   var value = null;
   try {
     value = channel.getRequestHeader(headers[i]);
   }
   catch(e) {}
 
   isnot(value, "test" + i, "Setting " + headers[i] + " header in unprivileged context");
 }
 
 // Try setting headers in privileged context
-netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-request = new XMLHttpRequest();
+request = SpecialPowers.wrap(new XMLHttpRequest());
 request.open("GET", window.location.href);
 for (i = 0; i < headers.length; i++)
   request.setRequestHeader(headers[i], "test" + i);
 
 // Read out headers
-var channel = SpecialPowers.wrap(request).channel.QueryInterface(Components.interfaces.nsIHttpChannel);
+var channel = request.channel.QueryInterface(SpecialPowers.Ci.nsIHttpChannel);
 for (i = 0; i < headers.length; i++) {
   var value = channel.getRequestHeader(headers[i]);
   is(value, "test" + i, "Setting " + headers[i] + " header in privileged context");
 }
 </script>
 </pre>
 </body>
 </html>
--- a/content/events/test/test_bug409604.html
+++ b/content/events/test/test_bug409604.html
@@ -14,18 +14,18 @@ https://bugzilla.mozilla.org/show_bug.cg
 <div id="content" style="display: none">
   
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
   /** Test for Bug 409604 **/
 
-  var modifier = Components.interfaces.nsIDOMEvent.ALT_MASK |
-                 Components.interfaces.nsIDOMEvent.SHIFT_MASK;
+  var modifier = SpecialPowers.Ci.nsIDOMEvent.ALT_MASK |
+                 SpecialPowers.Ci.nsIDOMEvent.SHIFT_MASK;
   var expectedFocus = "a,c,d,e,f,g,h,i,j,k,l,m,n,p,x,y";
   // XXX the "map" test is causing trouble, see bug 433089
   var focusArray = expectedFocus.split(",");
   var unfocusableElementId = "invalid";
   var unfocusableTags = [
       {tag: "abbr", content: "text", attribs: {title: "something"}},
       {tag: "acronym", content: "text", attribs: {title: "something"}},
       {tag: "address", content: "text"},
--- a/content/html/content/test/forms/test_max_attribute.html
+++ b/content/html/content/test/forms/test_max_attribute.html
@@ -102,18 +102,17 @@ for each (var data in types) {
   } else if (input.type == 'file') {
     // Need privileges to set a filename with .value.
     netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
 
     var dirSvc = Components.classes["@mozilla.org/file/directory_service;1"]
                            .getService(Components.interfaces.nsIProperties);
     var file = dirSvc.get("ProfD", Components.interfaces.nsIFile);
     file.append('635499_file');
-    var outStream = Components.
-                    classes["@mozilla.org/network/file-output-stream;1"].
+    var outStream = Components.classes["@mozilla.org/network/file-output-stream;1"].
                     createInstance(Components.interfaces.nsIFileOutputStream);
     outStream.init(file, 0x02 | 0x08 | 0x20, // write, create, truncate
                    0666, 0);
     outStream.write("foo", 3);
     outStream.close();
 
     input.value = file.path;
     checkValidity(input, true, apply, apply);
--- a/content/html/content/test/forms/test_min_attribute.html
+++ b/content/html/content/test/forms/test_min_attribute.html
@@ -102,18 +102,17 @@ for each (var data in types) {
   } else if (input.type == 'file') {
     // Need privileges to set a filename with .value.
     netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
 
     var dirSvc = Components.classes["@mozilla.org/file/directory_service;1"]
                            .getService(Components.interfaces.nsIProperties);
     var file = dirSvc.get("ProfD", Components.interfaces.nsIFile);
     file.append('635499_file');
-    var outStream = Components.
-                    classes["@mozilla.org/network/file-output-stream;1"].
+    var outStream = Components.classes["@mozilla.org/network/file-output-stream;1"].
                     createInstance(Components.interfaces.nsIFileOutputStream);
     outStream.init(file, 0x02 | 0x08 | 0x20, // write, create, truncate
                    0666, 0);
     outStream.write("foo", 3);
     outStream.close();
 
     input.value = file.path;
     checkValidity(input, true, apply, apply);
--- a/content/html/content/test/forms/test_required_attribute.html
+++ b/content/html/content/test/forms/test_required_attribute.html
@@ -302,18 +302,17 @@ function checkInputRequiredValidityForFi
   element.type = 'file'
   document.forms[0].appendChild(element);
 
   function createFileWithData(fileName, fileData) {
     var dirSvc = Components.classes["@mozilla.org/file/directory_service;1"]
                            .getService(Components.interfaces.nsIProperties);
     var testFile = dirSvc.get("ProfD", Components.interfaces.nsIFile);
     testFile.append(fileName);
-    var outStream = Components.
-                    classes["@mozilla.org/network/file-output-stream;1"].
+    var outStream = Components.classes["@mozilla.org/network/file-output-stream;1"].
                     createInstance(Components.interfaces.nsIFileOutputStream);
     outStream.init(testFile, 0x02 | 0x08 | 0x20, // write, create, truncate
                    0666, 0);
     outStream.write(fileData, fileData.length);
     outStream.close();
 
     return testFile;
   }
--- a/content/html/content/test/forms/test_step_attribute.html
+++ b/content/html/content/test/forms/test_step_attribute.html
@@ -96,18 +96,17 @@ for each (var data in types) {
   } else if (input.type == 'file') {
     // Need privileges to set a filename with .value.
     netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
 
     var dirSvc = Components.classes["@mozilla.org/file/directory_service;1"]
                            .getService(Components.interfaces.nsIProperties);
     var file = dirSvc.get("ProfD", Components.interfaces.nsIFile);
     file.append('635499_file');
-    var outStream = Components.
-                    classes["@mozilla.org/network/file-output-stream;1"].
+    var outStream = Components.classes["@mozilla.org/network/file-output-stream;1"].
                     createInstance(Components.interfaces.nsIFileOutputStream);
     outStream.init(file, 0x02 | 0x08 | 0x20, // write, create, truncate
                    0666, 0);
     outStream.write("foo", 3);
     outStream.close();
 
     input.value = file.path;
     checkValidity(input, true, apply);
--- a/content/html/content/test/test_bug143220.html
+++ b/content/html/content/test/test_bug143220.html
@@ -21,18 +21,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 <script class="testbody" type="text/javascript">
 
 /** Test for Bug 143220 **/
 var leafName;
 var fullPath;
 
 
 function initVals() {
-  var dirSvc = SpecialPowers.wrap(Components)
-                            .classes["@mozilla.org/file/directory_service;1"]
+  var dirSvc = SpecialPowers.wrap(Components).classes["@mozilla.org/file/directory_service;1"]
                             .getService(Components.interfaces.nsIProperties);
   var file = dirSvc.get("XpcomLib", Components.interfaces.nsILocalFile);
   isnot(file, null, "Must have file here");
 
   leafName = file.leafName;
   fullPath = file.path;
 }
 
--- a/content/html/content/test/test_bug389797.html
+++ b/content/html/content/test/test_bug389797.html
@@ -40,26 +40,26 @@ function HTML_TAG(aTagName, aImplClass) 
   // Some interfaces don't appear in classinfo because other interfaces that
   // inherit from them do.
   interfacesNonClassinfo[aTagName] =
     [ "nsIDOMNode",
       "nsIDOMElement",
       "nsISupportsWeakReference" ];
 
   var interfaceName = "nsIDOM" + getClassName(aTagName);
-  if (interfaceName in Components.interfaces) {  // no nsIDOMHTMLSpanElement
+  if (interfaceName in SpecialPowers.Ci) {  // no nsIDOMHTMLSpanElement
     interfaces[aTagName].push(interfaceName);
     interfacesNonClassinfo[aTagName].push("nsIDOMHTMLElement");
   } else {
     // Inherits directly from nsIDOMHTMLElement.
     interfaces[aTagName].push("nsIDOMHTMLElement");
   }
 
   var interfaceNameNS = "nsIDOMNS" + getClassName(aTagName);
-  if (interfaceNameNS in Components.interfaces) {
+  if (interfaceNameNS in SpecialPowers.Ci) {
     interfaces[aTagName].push(interfaceNameNS);
   }
 
   if (arguments.length > 2) {
     for (var i = 0; i < arguments[2].length; ++i) {
       interfaces[aTagName].push(arguments[2][i]);
     }
   }
@@ -240,34 +240,34 @@ for each (var tag in allTags) {
 
   var classInfoString = getClassName(tag);
   is(nodeString, "[object " + classInfoString,
      "Unexpected classname for " + tagName(tag));
   is(node instanceof window[classInfoString], true,
      tagName(tag) + " not an instance of " + classInfos[tag]);
   is(node instanceof HTMLUnknownElement, false,
      tagName(tag) + " is an instance of HTMLUnknownElement");
-  is(node instanceof Components.interfaces.nsIDOMHTMLUnknownElement, false,
+  is(node instanceof SpecialPowers.Ci.nsIDOMHTMLUnknownElement, false,
      tagName(tag) + " is an instance of nsIDOMHTMLUnknownElement");
 
   // Check that each node QIs to all the things we expect it to QI to
   for each (var iface in interfaces[tag].concat(interfacesNonClassinfo[tag])) {
-    is(iface in Components.interfaces, true,
+    is(iface in SpecialPowers.Ci, true,
        iface + " not in Components.interfaces");
-    is(node instanceof Components.interfaces[iface], true,
+    is(node instanceof SpecialPowers.Ci[iface], true,
        tagName(tag) + " does not QI to " + iface);
   }
 
   // Now see what classinfo reports
   netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-  var nodeClassInfo = node.QueryInterface(Components.interfaces.nsIClassInfo);
+  var nodeClassInfo = SpecialPowers.wrap(node).QueryInterface(SpecialPowers.Ci.nsIClassInfo);
   var count = {};
   var classInfoInterfaces =
     nodeClassInfo.getInterfaces(count).
-    map(function(id) { return Components.interfacesByID[id].toString(); });
+    map(function(id) { return SpecialPowers.Components.interfacesByID[id].toString(); });
 
   // Make sure that we know about all the things classinfo claims
   for each (var classInfoInterface in classInfoInterfaces) {
     isnot(interfaces[tag].indexOf(classInfoInterface), -1,
           "Should know about " + tagName(tag) + " implementing " +
           classInfoInterface);
   }
 
--- a/content/html/content/test/test_bug523771.html
+++ b/content/html/content/test/test_bug523771.html
@@ -43,18 +43,17 @@ function setFileInputs () {
   SpecialPowers.wrap(multiFileInput).mozSetFileNameArray(input2FileNames, input2FileNames.length);
 }
 
 function createFileWithData(fileName, fileData) {
   var dirSvc = SpecialPowers.wrap(Components).classes["@mozilla.org/file/directory_service;1"]
                             .getService(Components.interfaces.nsIProperties);
   var testFile = dirSvc.get("ProfD", Components.interfaces.nsIFile);
   testFile.append(fileName);
-  var outStream = SpecialPowers.wrap(Components).
-                    classes["@mozilla.org/network/file-output-stream;1"].
+  var outStream = SpecialPowers.wrap(Components).classes["@mozilla.org/network/file-output-stream;1"].
                     createInstance(Components.interfaces.nsIFileOutputStream);
   outStream.init(testFile, 0x02 | 0x08 | 0x20, // write, create, truncate
                  0666, 0);
   outStream.write(fileData, fileData.length);
   outStream.close();
 
   filesToKill.push(testFile);
 
--- a/content/html/content/test/test_bug590353-2.html
+++ b/content/html/content/test/test_bug590353-2.html
@@ -34,18 +34,17 @@ var testData = [
   [ "file", "590353_file", "" ],
 ];
 
 function createFileWithData(fileName, fileData) {
   var dirSvc = Components.classes["@mozilla.org/file/directory_service;1"]
                          .getService(Components.interfaces.nsIProperties);
   var testFile = dirSvc.get("ProfD", Components.interfaces.nsIFile);
   testFile.append(fileName);
-  var outStream = Components.
-                  classes["@mozilla.org/network/file-output-stream;1"].
+  var outStream = Components.classes["@mozilla.org/network/file-output-stream;1"].
                   createInstance(Components.interfaces.nsIFileOutputStream);
   outStream.init(testFile, 0x02 | 0x08 | 0x20, // write, create, truncate
                  0666, 0);
   outStream.write(fileData, fileData.length);
   outStream.close();
 
   return testFile;
 }
--- a/content/html/content/test/test_bug598643.html
+++ b/content/html/content/test/test_bug598643.html
@@ -17,18 +17,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 /** Test for Bug 598643 **/
 
 function createFileWithData(fileName, fileData)
 {
   var dirSvc = Components.classes["@mozilla.org/file/directory_service;1"]
                          .getService(Components.interfaces.nsIProperties);
   var testFile = dirSvc.get("ProfD", Components.interfaces.nsIFile);
   testFile.append(fileName);
-  var outStream = Components.
-                  classes["@mozilla.org/network/file-output-stream;1"].
+  var outStream = Components.classes["@mozilla.org/network/file-output-stream;1"].
                   createInstance(Components.interfaces.nsIFileOutputStream);
   outStream.init(testFile, 0x02 | 0x08 | 0x20, // write, create, truncate
                  0666, 0);
   outStream.write(fileData, fileData.length);
   outStream.close();
 
   return testFile;
 }
--- a/content/xml/document/test/test_bug392338.html
+++ b/content/xml/document/test/test_bug392338.html
@@ -43,22 +43,20 @@ obs.prototype = {
 
       this.window.is(ir instanceof
                        this.window.Components.interfaces.nsIInterfaceRequestor,
                      true, "Must be an interface requestor");
 
       if (ir instanceof this.window.Components.interfaces.nsIClassInfo) {
         var count = {};
         var interfaces = ir.
-                     QueryInterface(this.window.Components
-                                        .interfaces.nsIClassInfo).
+                     QueryInterface(this.window.Components.interfaces.nsIClassInfo).
                      getInterfaces(count).
                      map(function(id) {
-                                return this.window.Components
-                                                  .interfacesByID[id].toString();
+                                return this.window.Components.interfacesByID[id].toString();
                          });
         this.window.isnot(interfaces.indexOf("nsIInterfaceRequestor"), -1,
                           "Must have interface requestor classinfo");
       }
     } catch(ex) {
       this.window.is(true, false, "Exception thrown " + ex);
     } finally {
       if (this.timeToFinish) {
--- a/docshell/test/test_bug369814.html
+++ b/docshell/test/test_bug369814.html
@@ -181,18 +181,17 @@ var gTests = [
     "func" : loadErrorTest
   },
 ];
 
 var gNextTest = 0;
 
 function runNextTest()
 {
-  var prefs = SpecialPowers.wrap(Components)
-                           .classes["@mozilla.org/preferences-service;1"]
+  var prefs = SpecialPowers.wrap(Components).classes["@mozilla.org/preferences-service;1"]
                            .getService(Components.interfaces.nsIPrefBranch);
 
   if (gNextTest < gTests.length) {
     gCurrentTest = gTests[gNextTest++];
     gNumPokes = 0;
 
     prefs.setBoolPref("network.jar.open-unsafe-types", gCurrentTest['pref']);
 
@@ -209,32 +208,30 @@ function runNextTest()
     // Put back the pref value we had at test start
     prefs.setBoolPref("network.jar.open-unsafe-types", gPrefValue);
     SimpleTest.finish();
   }
 }
 
 function finishTest()
 {
-    var prefs = SpecialPowers.wrap(Components)
-                             .classes["@mozilla.org/preferences-service;1"]
+    var prefs = SpecialPowers.wrap(Components).classes["@mozilla.org/preferences-service;1"]
                              .getService(Components.interfaces.nsIPrefBranch);
     prefs.setBoolPref("network.jar.open-unsafe-types", false);
 
   if (gNumPokes == 0) {
     ok(true, gCurrentTest["name"] + ": no unexpected pokes");
   }
 
   runNextTest();
 }
 
 function startTests()
 {
-  var prefs = SpecialPowers.wrap(Components)
-                           .classes["@mozilla.org/preferences-service;1"]
+  var prefs = SpecialPowers.wrap(Components).classes["@mozilla.org/preferences-service;1"]
                            .getService(Components.interfaces.nsIPrefBranch);
   gPrefValue = prefs.getBoolPref("network.jar.open-unsafe-types");
 }
 
 addLoadEvent(runNextTest);
 
 </script>
 </pre>
--- a/dom/browser-element/mochitest/browserElement_Auth.js
+++ b/dom/browser-element/mochitest/browserElement_Auth.js
@@ -76,22 +76,20 @@ function testHttpAuth(e) {
 
   SimpleTest.executeSoon(function() {
     e.detail.authenticate("httpuser", "httppass");
   });
 }
 
 function testFinish() {
   // Clear login information stored in password manager.
-  var authMgr = SpecialPowers.wrap(Components)
-    .classes['@mozilla.org/network/http-auth-manager;1']
+  var authMgr = SpecialPowers.wrap(Components).classes['@mozilla.org/network/http-auth-manager;1']
     .getService(Components.interfaces.nsIHttpAuthManager);
   authMgr.clearAll();
 
-  var pwmgr = SpecialPowers.wrap(Components)
-    .classes["@mozilla.org/login-manager;1"]
+  var pwmgr = SpecialPowers.wrap(Components).classes["@mozilla.org/login-manager;1"]
     .getService(Components.interfaces.nsILoginManager);
   pwmgr.removeAllLogins();
 
   SimpleTest.finish();
 }
 
 runTest();
--- a/dom/tests/mochitest/bugs/test_bug317448.html
+++ b/dom/tests/mochitest/bugs/test_bug317448.html
@@ -25,17 +25,17 @@ is(x instanceof Components.interfaces.ns
    true, "Must be interface requestor");
 
 var count = {};
 var interfaces = SpecialPowers.wrap(x).
                  QueryInterface(Components.interfaces.nsIClassInfo).
                  getInterfaces(count).
                  map(function(id) {
                             id = SpecialPowers.wrap(id);
-                            return SpecialPowers.wrap(Components).interfacesByID[id].toString();
+                            return SpecialPowers.wrap(SpecialPowers.Components).interfacesByID[id].toString();
                      });
 isnot(interfaces.indexOf("nsIInterfaceRequestor"), "-1",
       "Must have interface requestor classinfo");
 </script>
 </pre>
 </body>
 </html>
 
--- a/dom/tests/mochitest/bugs/test_bug397571.html
+++ b/dom/tests/mochitest/bugs/test_bug397571.html
@@ -17,18 +17,18 @@ https://bugzilla.mozilla.org/show_bug.cg
   
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 /** Test for Bug 397571 **/
 
 // Get the interface
-var utils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
-               getInterface(Components.interfaces.nsIDOMWindowUtils);
+var utils = window.QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor).
+               getInterface(SpecialPowers.Ci.nsIDOMWindowUtils);
 
 // Try to call functions without privileges
 var success = false;
 try {
   isForced = utils.docCharsetIsForced;
 }
 catch(e) {
   success = true;
@@ -67,17 +67,17 @@ try {
   utils.focus(null);
 }
 catch(e) {
   success = true;
 }
 ok(success, "should throw");
 
 // Get privilege
-netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
+utils = SpecialPowers.wrap(utils);
 
 // Try again
 var success = true;
 try {
   isForced = utils.docCharsetIsForced;
 }
 catch(e) {
   success = false;
--- a/dom/tests/mochitest/webapps/cross_origin.html
+++ b/dom/tests/mochitest/webapps/cross_origin.html
@@ -21,17 +21,17 @@ var parent = SpecialPowers.wrap(window).
 
 confirmNextInstall();
 navigator.mozApps.install(parent.url2, null).onsuccess = function onInstall() {
   // Give the test page a reference to the installed app, so it can uninstall it
   // after it finishes the tests.
   parent.app2 = this.result;
 
   navigator.mozApps.getSelf().onsuccess = function onGetSelf() {
-    parent.ok(this.result instanceof Components.interfaces.mozIDOMApplication,
+    parent.ok(this.result instanceof SpecialPowers.Ci.mozIDOMApplication,
               "getSelf() from app's origin returns mozIDOMApplication");
     parent.is(this.result.manifestURL, parent.url2,
               "getSelf() from app's origin returns origin's app");
 
     // Tell the test page to continue the tests.
     parent.postMessage("next", "*");
   }
 }
--- a/dom/tests/mochitest/webapps/head.js
+++ b/dom/tests/mochitest/webapps/head.js
@@ -40,17 +40,17 @@ function runAll(steps) {
     else {
       SimpleTest.finish();
     }
   }
   next();
 }
 
 function confirmNextInstall() {
-  var Ci = Components.interfaces;
+  var Ci = SpecialPowers.Ci;
 
   var popupPanel = SpecialPowers.wrap(window).top.
                    QueryInterface(Ci.nsIInterfaceRequestor).
                    getInterface(Ci.nsIWebNavigation).
                    QueryInterface(Ci.nsIDocShell).
                    chromeEventHandler.ownerDocument.defaultView.
                    PopupNotifications.panel;
 
--- a/editor/libeditor/html/tests/test_CF_HTML_clipboard.html
+++ b/editor/libeditor/html/tests/test_CF_HTML_clipboard.html
@@ -141,17 +141,17 @@ function runTest() {
         }, false);
         win.focus();
       }, 0);
     }, false);
     iframe.src = "data:text/html,";
   }, SimpleTest.finish);
 }
 
-var isMac = ("nsILocalFileMac" in Components.interfaces);
+var isMac = ("nsILocalFileMac" in SpecialPowers.Ci);
 if (isMac)
   SimpleTest.waitForFocus(runTest);
 else {
   // This test is not yet supported on non-Mac platforms, see bug 574005.
   todo(false, "Test not supported on this platform");
   SimpleTest.finish();
 }
 
--- a/editor/libeditor/text/tests/test_bug596333.html
+++ b/editor/libeditor/text/tests/test_bug596333.html
@@ -14,17 +14,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 <p id="display"></p>
 <div id="content" style="display: none">
 
 </div>
 <pre id="test">
 <script type="application/javascript">
 
 /** Test for Bug 596333 **/
-const Ci = Components.interfaces;
+const Ci = SpecialPowers.Ci;
 
 SimpleTest.waitForExplicitFinish();
 addLoadEvent(function() SimpleTest.executeSoon(runTest));
 
 var gMisspeltWords;
 
 function getEditor() {
   return document.getElementById("edit")
--- a/gfx/tests/mochitest/test_acceleration.html
+++ b/gfx/tests/mochitest/test_acceleration.html
@@ -17,18 +17,18 @@ https://bugzilla.mozilla.org/show_bug.cg
 <pre id="test">
 <script type="application/javascript">
 
 // Make sure that acceleration is enabled/disabled the way we expect it to be
 // based on platform.
 
 var importObj = {};
 
-var Cc = SpecialPowers.wrap(Components).classes;
-var Ci = Components.interfaces;
+var Cc = SpecialPowers.Cc;
+var Ci = SpecialPowers.Ci;
 
 var sysInfo = Cc["@mozilla.org/system-info;1"].getService(Ci.nsIPropertyBag2);
 
 var windows = SpecialPowers.Services.ww.getWindowEnumerator();
 var windowutils;
 var acceleratedWindows = 0;
 while (windows.hasMoreElements()) {
   windowutils = windows.getNext().QueryInterface(Ci.nsIInterfaceRequestor)
--- a/image/test/mochitest/imgutils.js
+++ b/image/test/mochitest/imgutils.js
@@ -2,53 +2,52 @@
 // Helper file for shared image functionality
 // 
 // Note that this is use by tests elsewhere in the source tree. When in doubt,
 // check mxr before removing or changing functionality.
 
 // Helper function to clear the image cache of content images
 function clearImageCache()
 {
-  var tools = SpecialPowers.wrap(Components)
-                             .classes["@mozilla.org/image/tools;1"]
-                             .getService(Components.interfaces.imgITools);
+  var tools = SpecialPowers.Cc["@mozilla.org/image/tools;1"]
+                             .getService(SpecialPowers.Ci.imgITools);
   var imageCache = tools.getImgCacheForDocument(window.document);
   imageCache.clearCache(false); // true=chrome, false=content
 }
 
 // Helper function to determine if the frame is decoded for a given image id
 function isFrameDecoded(id)
 {
   return (getImageStatus(id) &
-          Components.interfaces.imgIRequest.STATUS_FRAME_COMPLETE)
+          SpecialPowers.Ci.imgIRequest.STATUS_FRAME_COMPLETE)
          ? true : false;
 }
 
 // Helper function to determine if the image is loaded for a given image id
 function isImageLoaded(id)
 {
   return (getImageStatus(id) &
-          Components.interfaces.imgIRequest.STATUS_LOAD_COMPLETE)
+          SpecialPowers.Ci.imgIRequest.STATUS_LOAD_COMPLETE)
          ? true : false;
 }
 
 // Helper function to get the status flags of an image
 function getImageStatus(id)
 {
   // Escalate
   netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
 
   // Get the image
   var img = document.getElementById(id);
 
   // QI the image to nsImageLoadingContent
-  img.QueryInterface(Components.interfaces.nsIImageLoadingContent);
+  img.QueryInterface(SpecialPowers.Ci.nsIImageLoadingContent);
 
   // Get the request
-  var request = img.getRequest(Components.interfaces
+  var request = img.getRequest(SpecialPowers.Ci
                                          .nsIImageLoadingContent
                                          .CURRENT_REQUEST);
 
   // Return the status
   return request.imageStatus;
 }
 
 // Forces a synchronous decode of an image by drawing it to a canvas. Only
--- a/image/test/mochitest/test_bug601470.html
+++ b/image/test/mochitest/test_bug601470.html
@@ -18,18 +18,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 <pre id="test">
 <script type="application/javascript">
 /** Test for Bug 601470 **/
 
 SimpleTest.waitForExplicitFinish();
 
 window.onload = function() {
   netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-  var mgr = Components
-    .classes["@mozilla.org/memory-reporter-manager;1"]
+  var mgr = Components.classes["@mozilla.org/memory-reporter-manager;1"]
     .getService(Components.interfaces.nsIMemoryReporterManager);
 
   var e = mgr.enumerateReporters();
   var memoryCounter = 0;
   while (e.hasMoreElements()) {
     var mr =
       e.getNext().QueryInterface(Components.interfaces.nsIMemoryReporter);
     memoryCounter += mr.amount;
--- a/js/xpconnect/tests/mochitest/file_bug650273.html
+++ b/js/xpconnect/tests/mochitest/file_bug650273.html
@@ -5,17 +5,17 @@ var targetUrl = "http://example.com/";
 var l;
 
 function a() {
         var o = {};
         o.toString = function() {
                 l();
                 return "a";
         };
-        var f = Components.lookupMethod(document, "title");
+        var f = SpecialPowers.Components.lookupMethod(document, "title");
         setTimeout(f, 0, o);
 }
 
 function l() {
         var l = false;
         onunload = function() {
                 l = true;
         };
--- a/js/xpconnect/tests/mochitest/test_lookupMethod.html
+++ b/js/xpconnect/tests/mochitest/test_lookupMethod.html
@@ -15,58 +15,63 @@ https://bugzilla.mozilla.org/show_bug.cg
 <div id="content" style="display: none">
 </div>
 <pre id="test">
 <script type="application/javascript">
 
 /** Test for Components.lookupMethod in content scope. **/
 SimpleTest.waitForExplicitFinish();
 
+// We're testing things from an unprivileged perspective, so don't use
+// SpecialPowers.Cu and friends, since those are SpecialPowers-wrapped versions
+// that allow unprivileged tests to do privileged things.
+var SC = SpecialPowers.Components;
+
 var gLoaded = 0;
 function loaded() {
   if (++gLoaded == 2)
     go();
 }
 
 var sameOriginWin;
 var crossOriginWin;
 function go() {
   // Grab references to the content windows.
   sameOriginWin = document.getElementById('ifr-same').contentWindow;
   crossOriginWin = document.getElementById('ifr-cross').contentWindow;
 
   // Test same-compartment.
   document.getElementsByTagName = function() { ok(false, "dont call me"); };
-  var result = Components.lookupMethod(document, 'getElementsByTagName')('iframe');
+  var result = SC.lookupMethod(document, 'getElementsByTagName')('iframe');
   is(result.length, 2, "same-origin lookupMethod works");
 
   // Test that the method is bound.
-  var gebtn = Components.lookupMethod(document, 'getElementsByTagName');
+  var gebtn = SC.lookupMethod(document, 'getElementsByTagName');
   is(Function.call.apply(gebtn, [window, 'iframe']).length, 2, "method is bound");
 
   // Test that we throw for location objects. Location objects already use same-
   // compartment Xrays, so callers shouldn't need to use lookupMethod there. And
   // making it work would involve complicating the security surounding the
   // implementation.
   try {
-    Components.lookupMethod(location, 'href');
+    SC.lookupMethod(location, 'href');
     ok(false, "Didn't throw when we should have!");
   } catch(e) {
     ok(true, "Correctly threw when trying to lookupMethod on location object");
   }
 
   // Test cross-compartment same-origin.
   sameOriginWin.setTimeout = function() { ok(false, "dont call me either"); };
-  Components.lookupMethod(sameOriginWin, 'setTimeout')(continueTest, 0);
+  SC.lookupMethod(sameOriginWin, 'setTimeout')(continueTest, 0);
 }
 
 function continueTest() {
   // Test that cross-origin fails.
   try {
-    Components.lookupMethod(crossOriginWin, 'top');
+    SC.lookupMethod(crossOriginWin, 'top');
     ok(false, "Should have thrown");
   } catch (e) {
     ok(true, "Threw appropriately");
   }
 
   SimpleTest.finish();
 }
 
--- a/security/manager/ssl/tests/mochitest/mixedcontent/mixedContentTest.js
+++ b/security/manager/ssl/tests/mochitest/mixedcontent/mixedContentTest.js
@@ -159,27 +159,27 @@ function todoSecurityState(expectedState
 
 function isSecurityState(expectedState, message, test)
 {
   if (!test)
     test = ok;
 
   // Quit nasty but working :)
   var ui = SpecialPowers.wrap(window)
-    .QueryInterface(Components.interfaces.nsIInterfaceRequestor)
-    .getInterface(Components.interfaces.nsIWebNavigation)
-    .QueryInterface(Components.interfaces.nsIDocShell)
+    .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
+    .getInterface(SpecialPowers.Ci.nsIWebNavigation)
+    .QueryInterface(SpecialPowers.Ci.nsIDocShell)
     .securityUI;
 
   var isInsecure = !ui ||
-    (ui.state & Components.interfaces.nsIWebProgressListener.STATE_IS_INSECURE);
+    (ui.state & SpecialPowers.Ci.nsIWebProgressListener.STATE_IS_INSECURE);
   var isBroken = ui &&
-    (ui.state & Components.interfaces.nsIWebProgressListener.STATE_IS_BROKEN);
+    (ui.state & SpecialPowers.Ci.nsIWebProgressListener.STATE_IS_BROKEN);
   var isEV = ui &&
-    (ui.state & Components.interfaces.nsIWebProgressListener.STATE_IDENTITY_EV_TOPLEVEL);
+    (ui.state & SpecialPowers.Ci.nsIWebProgressListener.STATE_IDENTITY_EV_TOPLEVEL);
 
   var gotState;
   if (isInsecure)
     gotState = "insecure";
   else if (isBroken)
     gotState = "broken";
   else if (isEV)
     gotState = "EV";
--- a/testing/mochitest/tests/test_SpecialPowersExtension.html
+++ b/testing/mochitest/tests/test_SpecialPowersExtension.html
@@ -90,41 +90,41 @@ function starttest(){
   //try to run garbage collection
   SpecialPowers.gc();
 
   //
   // Test the SpecialPowers wrapper.
   //
 
   // Try some basic stuff with XHR.
-  var xhr2 = SpecialPowers.wrap(Components).classes["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Components.interfaces.nsIXMLHttpRequest);
+  var xhr2 = SpecialPowers.Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(SpecialPowers.Ci.nsIXMLHttpRequest);
   is(xhr.readyState, XMLHttpRequest.UNSENT, "Should be able to get props off privileged objects");
-  var testURI = SpecialPowers.wrap(Components).classes['@mozilla.org/network/standard-url;1']
-                                              .createInstance(Components.interfaces.nsIURI);
+  var testURI = SpecialPowers.Cc['@mozilla.org/network/standard-url;1']
+                                              .createInstance(SpecialPowers.Ci.nsIURI);
   testURI.spec = "http://www.foobar.org/";
   is(testURI.spec, "http://www.foobar.org/", "Getters/Setters should work correctly");
   is(SpecialPowers.wrap(document).getElementsByTagName('details').length, 0, "Should work with proxy-based DOM bindings.");
 
   // Play with the window object.
-  var webnav = SpecialPowers.wrap(window).QueryInterface(Components.interfaces.nsIInterfaceRequestor)
-                                         .getInterface(Components.interfaces.nsIWebNavigation);
-  webnav.QueryInterface(Components.interfaces.nsIDocShell);
+  var webnav = SpecialPowers.wrap(window).QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
+                                         .getInterface(SpecialPowers.Ci.nsIWebNavigation);
+  webnav.QueryInterface(SpecialPowers.Ci.nsIDocShell);
   ok(webnav.allowJavascript, "Able to pull properties off of docshell!");
 
   // Make sure Xray-wrapped functions work.
   try {
-    SpecialPowers.wrap(Components).ID('{00000000-0000-0000-0000-000000000000}');
+    SpecialPowers.wrap(SpecialPowers.Components).ID('{00000000-0000-0000-0000-000000000000}');
     ok(true, "Didn't throw");
   }
   catch (e) {
     ok(false, "Threw while trying to call Xray-wrapped function.");
   }
 
   // Check constructors.
-  var BinaryInputStream = SpecialPowers.wrap(Components).Constructor("@mozilla.org/binaryinputstream;1");
+  var BinaryInputStream = SpecialPowers.wrap(SpecialPowers.Components).Constructor("@mozilla.org/binaryinputstream;1");
   var bis = new BinaryInputStream();
   ok(/nsISupports/.exec(bis.toString()), "Should get the proper object out of the constructor");
   function TestConstructor() {
     SpecialPowers.wrap(this).foo = 2;
   }
   var WrappedConstructor = SpecialPowers.wrap(TestConstructor);
   is((new WrappedConstructor()).foo, 2, "JS constructors work properly when wrapped");
 
--- a/testing/mochitest/tests/test_sanityEventUtils.html
+++ b/testing/mochitest/tests/test_sanityEventUtils.html
@@ -127,17 +127,17 @@ function starttest() {
     
       check = false;
       window.addEventListener("compositionend", function() { check = true; }, false);
       synthesizeComposition({ type: "compositionend" });
       is(check, true, 'synthesizeComposition() should dispatch compositionend');
       check = false;
     
       $("textBoxB").focus();
-      const nsIDOMWindowUtils = Components.interfaces.nsIDOMWindowUtils;
+      const nsIDOMWindowUtils = SpecialPowers.Ci.nsIDOMWindowUtils;
       synthesizeText(
         { "composition":
           { "string": "a",
             "clauses":
             [
               { "length": 1, "attr": nsIDOMWindowUtils.COMPOSITION_ATTR_RAWINPUT }
             ]
           },
--- a/toolkit/components/passwordmgr/test/test_basic_form_autocomplete.html
+++ b/toolkit/components/passwordmgr/test/test_basic_form_autocomplete.html
@@ -82,25 +82,23 @@ Login Manager test: multiple login autoc
 
 commonInit();
 
 var uname = $_(1, "uname");
 var pword = $_(1, "pword");
 const shiftModifier = Components.interfaces.nsIDOMEvent.SHIFT_MASK;
 
 // Get the pwmgr service
-var pwmgr = SpecialPowers.wrap(Components)
-                         .classes["@mozilla.org/login-manager;1"]
+var pwmgr = SpecialPowers.wrap(Components).classes["@mozilla.org/login-manager;1"]
                          .getService(Components.interfaces.nsILoginManager);
 ok(pwmgr != null, "nsLoginManager service");
 
 // Create some logins just for this form, since we'll be deleting them.
 var nsLoginInfo =
-SpecialPowers.wrap(Components)
-             .Constructor("@mozilla.org/login-manager/loginInfo;1",
+SpecialPowers.wrap(Components).Constructor("@mozilla.org/login-manager/loginInfo;1",
                           Components.interfaces.nsILoginInfo, "init");
 ok(nsLoginInfo != null, "nsLoginInfo constructor");
 
 
 // login0 has no username, so should be filtered out from the autocomplete list.
 var login0 = new nsLoginInfo(
     "http://mochi.test:8888", "http://autocomplete:8888", null,
     "", "user0pass", "", "pword");
--- a/toolkit/components/passwordmgr/test/test_prompt_async.html
+++ b/toolkit/components/passwordmgr/test/test_prompt_async.html
@@ -8,18 +8,17 @@
     <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 
     <script class="testbody" type="text/javascript">
         SimpleTest.waitForExplicitFinish();
 
         // Class monitoring number of open dialog windows
         // It checks there is always open just a single dialog per application
         function dialogMonitor() {
-            var observerService = SpecialPowers.wrap(Components)
-                                               .classes["@mozilla.org/observer-service;1"]
+            var observerService = SpecialPowers.wrap(Components).classes["@mozilla.org/observer-service;1"]
                                                .getService(Ci.nsIObserverService);
             observerService.addObserver(this, "domwindowopened", false);
             observerService.addObserver(this, "domwindowclosed", false);
         }
 
         /*
          * As documented in Bug 718543, checking equality of objects pulled
          * from SpecialPowers-wrapped objects is unreliable.  Because of that,
@@ -47,41 +46,38 @@
                 }
                 if (topic === "domwindowclosed") {
                     this.windowsOpen--;
                     return;
                 }
             },
 
             shutdown: function() {
-                var observerService = SpecialPowers.wrap(Components)
-                                               .classes["@mozilla.org/observer-service;1"]
+                var observerService = SpecialPowers.wrap(Components).classes["@mozilla.org/observer-service;1"]
                                                .getService(Ci.nsIObserverService);
                 observerService.removeObserver(this, "domwindowopened");
                 observerService.removeObserver(this, "domwindowclosed");
             },
 
             reset: function() {
                 this.windowsOpen = 0;
                 this.windowsRegistered = 0;
             }
         }
 
         var monitor = new dialogMonitor();
 
         var pwmgr, logins = [];
 
         function initLogins() {
-            pwmgr = SpecialPowers.wrap(Components)
-                                 .classes["@mozilla.org/login-manager;1"]
+            pwmgr = SpecialPowers.wrap(Components).classes["@mozilla.org/login-manager;1"]
                                  .getService(Ci.nsILoginManager);
 
             function addLogin(host, realm, user, pass) {
-                var login = SpecialPowers.wrap(Components)
-                                         .classes["@mozilla.org/login-manager/loginInfo;1"]
+                var login = SpecialPowers.wrap(Components).classes["@mozilla.org/login-manager/loginInfo;1"]
                                          .createInstance(Ci.nsILoginInfo);
                 login.init(host, null, realm, user, pass, "", "");
                 pwmgr.addLogin(login);
                 logins.push(login);
             }
 
             //need to allow for arbitrary network servers defined in PAC instead of a hardcoded moz-proxy.
             var ios = SpecialPowers.wrap(Components)
@@ -120,18 +116,17 @@
                      "user6name", "user6pass");
         }
 
         function finishTest() {
             ok(true, "finishTest removing testing logins...");
             for (i in logins)
                 pwmgr.removeLogin(logins[i]);
 
-            var authMgr = SpecialPowers.wrap(Components)
-                                       .classes['@mozilla.org/network/http-auth-manager;1']
+            var authMgr = SpecialPowers.wrap(Components).classes['@mozilla.org/network/http-auth-manager;1']
                                        .getService(Ci.nsIHttpAuthManager);
             authMgr.clearAll();
 
             monitor.shutdown();
             SimpleTest.finish();
         }
 
 
--- a/toolkit/components/passwordmgr/test/test_xml_load.html
+++ b/toolkit/components/passwordmgr/test/test_xml_load.html
@@ -17,25 +17,22 @@ Login Manager test: XML prompt
 
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 /** Test for Login Manager: XML prompts. **/
 var pwmgr, login1, login2;
 
 function initLogins() {
-  pwmgr = SpecialPowers.wrap(Components)
-                       .classes["@mozilla.org/login-manager;1"]
+  pwmgr = SpecialPowers.wrap(Components).classes["@mozilla.org/login-manager;1"]
                        .getService(Ci.nsILoginManager);
 
-  login1 = SpecialPowers.wrap(Components)
-                        .classes["@mozilla.org/login-manager/loginInfo;1"]
+  login1 = SpecialPowers.wrap(Components).classes["@mozilla.org/login-manager/loginInfo;1"]
                         .createInstance(Ci.nsILoginInfo);
-  login2 = SpecialPowers.wrap(Components)
-                        .classes["@mozilla.org/login-manager/loginInfo;1"]
+  login2 = SpecialPowers.wrap(Components).classes["@mozilla.org/login-manager/loginInfo;1"]
                         .createInstance(Ci.nsILoginInfo);
 
   login1.init("http://mochi.test:8888", null, "xml",
                "xmluser1", "xmlpass1", "", "");
   login2.init("http://mochi.test:8888", null, "xml2",
                "xmluser2", "xmlpass2", "", "");
 
   pwmgr.addLogin(login1);
@@ -162,18 +159,17 @@ function makeRequest(uri) {
   xmlDoc.load(uri);
 }
 
 
 initLogins();
 
 // clear plain HTTP auth sessions before the test, to allow
 // running them more than once.
-var authMgr = SpecialPowers.wrap(Components)
-                           .classes['@mozilla.org/network/http-auth-manager;1']
+var authMgr = SpecialPowers.wrap(Components).classes['@mozilla.org/network/http-auth-manager;1']
                            .getService(Components.interfaces.nsIHttpAuthManager);
 authMgr.clearAll();
 
 // start the tests
 testNum = 0;
 doTest();
 
 SimpleTest.waitForExplicitFinish();
--- a/toolkit/components/places/tests/mochitest/test_bug_461710.html
+++ b/toolkit/components/places/tests/mochitest/test_bug_461710.html
@@ -14,21 +14,21 @@ https://bugzilla.mozilla.org/show_bug.cg
 <iframe id="iframe"></iframe>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 /** Test for Bug 461710 **/
 
 SimpleTest.waitForExplicitFinish();
 
-const Ci = Components.interfaces;
-const Cc = SpecialPowers.wrap(Components).classes;
-const Cr = SpecialPowers.wrap(Components).results;
+const Ci = SpecialPowers.Ci;
+const Cc = SpecialPowers.Cc;
+const Cr = SpecialPowers.Cr;
 
-SpecialPowers.wrap(Components).utils.import("resource://gre/modules/NetUtil.jsm", window);
+SpecialPowers.Cu.import("resource://gre/modules/NetUtil.jsm", window);
 var Services = SpecialPowers.Services;
 
 var gIframe = document.getElementById("iframe");
 
 /**
  * Helper function which waits until another function returns true, and
  * then notifies a callback.
  *
--- a/toolkit/components/satchel/test/test_bug_787624.html
+++ b/toolkit/components/satchel/test/test_bug_787624.html
@@ -60,18 +60,18 @@ Form History Layout test: form field aut
 
 var autocompletePopup = getAutocompletePopup();
 autocompletePopup.style.direction = "ltr";
 
 var input = $_(1, "field1");
 var rect = input.getBoundingClientRect();
 
 // Get the form history service
-var fh = SpecialPowers.wrap(Components).classes["@mozilla.org/satchel/form-history;1"].
-         getService(Components.interfaces.nsIFormHistory2);
+var fh = SpecialPowers.Cc["@mozilla.org/satchel/form-history;1"].
+         getService(SpecialPowers.Ci.nsIFormHistory2);
 ok(fh != null, "got form history service");
 
 fh.removeAllEntries();
 fh.addEntry("field1", "value1");
 fh.addEntry("field1", "value2");
 
 function checkForm(expectedValue) {
   var formID = input.parentNode.id;
--- a/toolkit/identity/tests/chrome/sandbox_content_perms.html
+++ b/toolkit/identity/tests/chrome/sandbox_content_perms.html
@@ -2,17 +2,17 @@
 <html>
   <!-- Any copyright is dedicated to the Public Domain.
      - http://creativecommons.org/publicdomain/zero/1.0/ -->
   <head>
     <meta charset="utf-8">
     <title>Page testing content in the Sandbox can't escape</title>
     <script type="application/javascript;version=1.8">
       const TEST_BASE = "http://mochi.test:8888/chrome/toolkit/identity/tests/chrome/"
-      const Ci = Components.interfaces;
+      const Ci = SpecialPowers.Ci;
 
       function expectException(aFunc) {
         try {
           aFunc();
         } catch (ex) {
           return true;
         }
         return false;
@@ -23,17 +23,17 @@
         windowTop: window.top == window,
 
         qiWindow: expectException(function() {
           let isForced = window.QueryInterface(Ci.nsIInterfaceRequestor)
                                .getInterface(Ci.nsIDOMWindowUtils)
                                .docCharsetIsForced;
         }),
 
-        ccAccess: Components.classes == null,
+        ccAccess: SpecialPowers.Components.classes == null,
       };
 
       let resultsJSON = JSON.stringify(results);
 
       // Send the results to the mochitest server so the test file can retrieve them.
       let stateURL = TEST_BASE + "sandbox_content.sjs"
       let xhr = new XMLHttpRequest();
       xhr.open("GET", stateURL + "?" + encodeURIComponent(resultsJSON), true);