Bug 984497 - Use SpecialPowers more and change SpecialPower usage to deal with Window on WebIDL bindings. r=bz.
☠☠ backed out by a201e70b790e ☠ ☠
authorPeter Van der Beken <peterv@propagandism.org>
Sat, 15 Feb 2014 22:12:34 +0100
changeset 195821 75c95dac7fe006430e20f527c93387e2ddb1a66d
parent 195820 c65cceb8ce46134cb57621401765fcb7e32d4bb3
child 195822 f1b0d3d13755f04d3f52a6a9244ecc6224907428
push id3624
push userasasaki@mozilla.com
push dateMon, 09 Jun 2014 21:49:01 +0000
treeherdermozilla-beta@b1a5da15899a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs984497
milestone31.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 984497 - Use SpecialPowers more and change SpecialPower usage to deal with Window on WebIDL bindings. r=bz.
content/html/document/test/test_bug512367.html
content/media/webspeech/synth/test/common.js
content/media/webspeech/synth/test/file_setup.html
content/media/webspeech/synth/test/file_speech_queue.html
content/media/webspeech/synth/test/file_speech_simple.html
content/media/webspeech/synth/test/mochitest.ini
content/media/webspeech/synth/test/test_setup.html
content/media/webspeech/synth/test/test_speech_queue.html
content/media/webspeech/synth/test/test_speech_simple.html
dom/events/test/test_bug508479.html
dom/tests/browser/browser_ConsoleStorageAPITests.js
dom/tests/mochitest/bugs/test_bug346659.html
dom/tests/mochitest/bugs/test_bug397571.html
editor/composer/test/test_bug519928.html
editor/libeditor/html/tests/test_bug432225.html
editor/libeditor/html/tests/test_bug468353.html
gfx/tests/mochitest/test_bug513439.html
js/xpconnect/tests/chrome/test_doublewrappedcompartments.xul
js/xpconnect/tests/mochitest/file_doublewrappedcompartments.html
security/manager/ssl/tests/mochitest/mixedcontent/backward.html
toolkit/components/passwordmgr/test/pwmgr_common.js
--- a/content/html/document/test/test_bug512367.html
+++ b/content/html/document/test/test_bug512367.html
@@ -20,18 +20,18 @@ https://bugzilla.mozilla.org/show_bug.cg
 <pre id="test">
 <script type="application/javascript">
 
 var frame = document.getElementById("i");
 
 SimpleTest.waitForExplicitFinish();
 addLoadEvent(function() {
   var viewer =
-    SpecialPowers.wrap(frame.contentWindow
-                 .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor))
+    SpecialPowers.wrap(frame.contentWindow)
+                 .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
                  .getInterface(SpecialPowers.Ci.nsIWebNavigation)
                  .QueryInterface(SpecialPowers.Ci.nsIDocShell)
                  .contentViewer
                  .QueryInterface(SpecialPowers.Ci.nsIMarkupDocumentViewer);
 
   viewer.fullZoom = 1.5;
 
   setTimeout(function() {
--- a/content/media/webspeech/synth/test/common.js
+++ b/content/media/webspeech/synth/test/common.js
@@ -1,10 +1,8 @@
-SpecialPowers.setBoolPref("media.webspeech.synth.enabled", true);
-
 var gSpeechRegistry = SpecialPowers.Cc["@mozilla.org/synth-voice-registry;1"]
   .getService(SpecialPowers.Ci.nsISynthVoiceRegistry);
 
 var gAddedVoices = [];
 
 function SpeechTaskCallback(onpause, onresume, oncancel) {
   this.onpause = onpause;
   this.onresume = onresume;
@@ -165,17 +163,16 @@ function synthCleanup() {
     is(voicesAfter, voicesBefore - toRemove, "Successfully removed test voices");
   } else {
     // XXX: It would be nice to check here that the child gets the voice
     // removed update, but alas, it is aynchronous.
     var mm = SpecialPowers.Cc["@mozilla.org/childprocessmessagemanager;1"]
       .getService(SpecialPowers.Ci.nsISyncMessageSender);
     mm.sendSyncMessage('test:SpeechSynthesis:ipcSynthCleanup');
   }
-  SpecialPowers.clearUserPref("media.webspeech.synth.enabled");
 }
 
 function synthTestQueue(aTestArgs, aEndFunc) {
   var utterances = [];
   for (var i in aTestArgs) {
     var uargs = aTestArgs[i][0];
     var u = new SpeechSynthesisUtterance(uargs.text);
 
copy from content/media/webspeech/synth/test/test_setup.html
copy to content/media/webspeech/synth/test/file_setup.html
--- a/content/media/webspeech/synth/test/test_setup.html
+++ b/content/media/webspeech/synth/test/file_setup.html
@@ -1,19 +1,23 @@
 <!DOCTYPE HTML>
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=525444
 -->
 <head>
   <meta charset="utf-8">
   <title>Test for Bug 525444: Web Speech API check all classes are present</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript">
+    window.SimpleTest = parent.SimpleTest;
+    window.is = parent.is;
+    window.isnot = parent.isnot;
+    window.ok = parent.ok;
+  </script>
   <script type="application/javascript" src="common.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=650295">Mozilla Bug 650295</a>
 <p id="display"></p>
 <div id="content" style="display: none">
   
 </div>
 <pre id="test">
@@ -67,12 +71,14 @@ var voices2 = speechSynthesis.getVoices(
 
 ok(voices1.length == voices2.length, "Voice count matches");
 
 for (var i in voices1) {
   ok(voices1[i] == voices2[i], "Voice instance matches");
 }
 
 synthCleanup();
+
+SimpleTest.finish();
 </script>
 </pre>
 </body>
 </html>
copy from content/media/webspeech/synth/test/test_speech_queue.html
copy to content/media/webspeech/synth/test/file_speech_queue.html
--- a/content/media/webspeech/synth/test/test_speech_queue.html
+++ b/content/media/webspeech/synth/test/file_speech_queue.html
@@ -1,33 +1,35 @@
 <!DOCTYPE HTML>
 <html lang="en-US">
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=525444
 -->
 <head>
   <meta charset="utf-8">
   <title>Test for Bug 525444: Web Speech API, check speech synth queue</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript">
+    window.SimpleTest = parent.SimpleTest;
+    window.is = parent.is;
+    window.isnot = parent.isnot;
+    window.ok = parent.ok;
+  </script>
   <script type="application/javascript" src="common.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=525444">Mozilla Bug 525444</a>
 <p id="display"></p>
 <div id="content" style="display: none">
   
 </div>
 <pre id="test">
 <script type="application/javascript">
 
 /** Test for Bug 525444 **/
 
-SimpleTest.waitForExplicitFinish();
-
 var englishJamaican = synthAddVoice('TestSpeechServiceNoAudio',
                                     'Bob Marley', 'en-JM', true);
 var englishBritish = synthAddVoice('TestSpeechServiceNoAudio',
                                    'Amy Winehouse', 'en-GB', true);
 var englishCanadian = synthAddVoice('TestSpeechServiceNoAudio',
                                     'Leonard Cohen', 'en-CA', true);
 var frenchCanadian = synthAddVoice('TestSpeechServiceNoAudio',
                                    'Celine Dion', 'fr-CA', true);
copy from content/media/webspeech/synth/test/test_speech_simple.html
copy to content/media/webspeech/synth/test/file_speech_simple.html
--- a/content/media/webspeech/synth/test/test_speech_simple.html
+++ b/content/media/webspeech/synth/test/file_speech_simple.html
@@ -1,33 +1,36 @@
 <!DOCTYPE HTML>
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=650295
 -->
 <head>
   <meta charset="utf-8">
   <title>Test for Bug 650295: Web Speech API check all classes are present</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript">
+    window.SimpleTest = parent.SimpleTest;
+    window.info = parent.info;
+    window.is = parent.is;
+    window.isnot = parent.isnot;
+    window.ok = parent.ok;
+  </script>
   <script type="application/javascript" src="common.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=650295">Mozilla Bug 650295</a>
 <p id="display"></p>
 <div id="content" style="display: none">
   
 </div>
 <pre id="test">
 <script type="application/javascript">
 
 /** Test for Bug 525444 **/
 
-SimpleTest.waitForExplicitFinish();
-
 synthAddVoice('TestSpeechServiceWithAudio', 'Male 1', 'en-GB', true);
 
 var gotStartEvent = false;
 var gotBoundaryEvent = false;
 var utterance = new SpeechSynthesisUtterance("Hello, world!");
 utterance.addEventListener('start', function(e) {
   ok(speechSynthesis.speaking, "speechSynthesis is speaking.");
   ok(!speechSynthesis.pending, "speechSynthesis has no other utterances queued.");
--- a/content/media/webspeech/synth/test/mochitest.ini
+++ b/content/media/webspeech/synth/test/mochitest.ini
@@ -1,9 +1,13 @@
 [DEFAULT]
 skip-if = e10s
-support-files = common.js
+support-files =
+  common.js
+  file_setup.html
+  file_speech_queue.html
+  file_speech_simple.html
 
 [test_setup.html]
 [test_speech_queue.html]
 skip-if = buildapp == 'b2g' # b2g(Test timed out) b2g-debug(Test timed out) b2g-desktop(Test timed out)
 [test_speech_simple.html]
 skip-if = buildapp == 'b2g' # b2g(Test timed out) b2g-debug(Test timed out) b2g-desktop(Test timed out)
--- a/content/media/webspeech/synth/test/test_setup.html
+++ b/content/media/webspeech/synth/test/test_setup.html
@@ -2,77 +2,31 @@
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=525444
 -->
 <head>
   <meta charset="utf-8">
   <title>Test for Bug 525444: Web Speech API check all classes are present</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="common.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=650295">Mozilla Bug 650295</a>
 <p id="display"></p>
+<iframe id="testFrame"></iframe>
 <div id="content" style="display: none">
   
 </div>
 <pre id="test">
 <script type="application/javascript">
 
 /** Test for Bug 525444 **/
 
-synthAddVoice('TestSpeechServiceNoAudio', 'Bob Marley', 'en-JM', true);
-synthAddVoice('TestSpeechServiceNoAudio', 'Amy Winehouse', 'en-GB', true);
-synthAddVoice('TestSpeechServiceNoAudio', 'Leonard Cohen', 'en-CA', true);
-synthAddVoice('TestSpeechServiceNoAudio', 'Celine Dion', 'fr-CA', true);
-synthAddVoice('TestSpeechServiceNoAudio', 'Julieta Venegas', 'es-MX', true);
-
-ok(SpeechSynthesis, "SpeechSynthesis exists in global scope");
-ok(SpeechSynthesisVoice, "SpeechSynthesisVoice exists in global scope");
-ok(SpeechSynthesisEvent, "SpeechSynthesisEvent exists in global scope");
+SimpleTest.waitForExplicitFinish();
 
-// SpeechSynthesisUtterance is the only type that has a constructor
-//  and writable properties
-ok(SpeechSynthesisUtterance, "SpeechSynthesisUtterance exists in global scope");
-var ssu = new SpeechSynthesisUtterance("hello world");
-is(typeof ssu, "object", "SpeechSynthesisUtterance instance is an object");
-is(ssu.text, "hello world", "SpeechSynthesisUtterance.text is correct");
-is(ssu.volume, 1, "SpeechSynthesisUtterance.volume default is correct");
-is(ssu.rate, 1, "SpeechSynthesisUtterance.rate default is correct");
-is(ssu.pitch, 1, "SpeechSynthesisUtterance.pitch default is correct");
-ssu.lang = "he-IL";
-ssu.volume = 0.5;
-ssu.rate = 2.0;
-ssu.pitch = 1.5;
-is(ssu.lang, "he-IL", "SpeechSynthesisUtterance.lang is correct");
-is(ssu.volume, 0.5,  "SpeechSynthesisUtterance.volume is correct");
-is(ssu.rate, 2.0,  "SpeechSynthesisUtterance.rate is correct");
-is(ssu.pitch, 1.5,  "SpeechSynthesisUtterance.pitch is correct");
+SpecialPowers.pushPrefEnv({ set: [['media.webspeech.synth.enabled', true]] },
+                          function() { document.getElementById("testFrame").src = "file_setup.html"; });
 
-// Test for singleton instance hanging off of window.
-ok(speechSynthesis, "speechSynthesis exists in global scope");
-is(typeof speechSynthesis, "object", "speechSynthesis instance is an object");
-is(typeof speechSynthesis.speak, "function", "speechSynthesis.speak is a function");
-is(typeof speechSynthesis.cancel, "function", "speechSynthesis.cancel is a function");
-is(typeof speechSynthesis.pause, "function", "speechSynthesis.pause is a function");
-is(typeof speechSynthesis.resume, "function", "speechSynthesis.resume is a function");
-is(typeof speechSynthesis.getVoices, "function", "speechSynthesis.getVoices is a function");
-
-is(typeof speechSynthesis.pending, "boolean", "speechSynthesis.pending is a boolean");
-is(typeof speechSynthesis.speaking, "boolean", "speechSynthesis.speaking is a boolean");
-is(typeof speechSynthesis.paused, "boolean", "speechSynthesis.paused is a boolean");
-
-var voices1 = speechSynthesis.getVoices();
-var voices2 = speechSynthesis.getVoices();
-
-ok(voices1.length == voices2.length, "Voice count matches");
-
-for (var i in voices1) {
-  ok(voices1[i] == voices2[i], "Voice instance matches");
-}
-
-synthCleanup();
 </script>
 </pre>
 </body>
 </html>
--- a/content/media/webspeech/synth/test/test_speech_queue.html
+++ b/content/media/webspeech/synth/test/test_speech_queue.html
@@ -8,63 +8,26 @@ https://bugzilla.mozilla.org/show_bug.cg
   <title>Test for Bug 525444: Web Speech API, check speech synth queue</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript" src="common.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=525444">Mozilla Bug 525444</a>
 <p id="display"></p>
+<iframe id="testFrame"></iframe>
 <div id="content" style="display: none">
   
 </div>
 <pre id="test">
 <script type="application/javascript">
 
 /** Test for Bug 525444 **/
 
 SimpleTest.waitForExplicitFinish();
 
-var englishJamaican = synthAddVoice('TestSpeechServiceNoAudio',
-                                    'Bob Marley', 'en-JM', true);
-var englishBritish = synthAddVoice('TestSpeechServiceNoAudio',
-                                   'Amy Winehouse', 'en-GB', true);
-var englishCanadian = synthAddVoice('TestSpeechServiceNoAudio',
-                                    'Leonard Cohen', 'en-CA', true);
-var frenchCanadian = synthAddVoice('TestSpeechServiceNoAudio',
-                                   'Celine Dion', 'fr-CA', true);
-var spanishMexican = synthAddVoice('TestSpeechServiceNoAudio',
-                                   'Julieta Venegas', 'es-MX', true);
-
-synthSetDefault(englishBritish, true);
-
-synthTestQueue(
-  [[{text: "Hello, world."},
-    { uri: englishBritish }],
-   [{text: "Bonjour tout le monde .", lang: "fr", rate: 0.5, pitch: 0.75},
-    { uri: frenchCanadian, rate: 0.5, pitch: 0.75}],
-   [{text: "How are you doing?", lang: "en-GB"},
-    { rate: 1, pitch: 1, uri: englishBritish}],
-   [{text: "¡hasta mañana", lang: "es-ES"},
-    { uri: spanishMexican }]],
-  function () {
-    synthSetDefault(englishJamaican, true);
-    var test_data = [[{text: "I shot the  sheriff."},
-                      { uri: englishJamaican }]];
-    var voices = speechSynthesis.getVoices();
-    for (var i in voices) {
-      test_data.push([{text: "Hello world", voice: voices[i]},
-                      {uri: voices[i].voiceURI}]);
-    }
-
-    synthTestQueue(test_data,
-                   function () {
-                     synthCleanup();
-                     SimpleTest.finish();
-                   });
-  });
-
-
+SpecialPowers.pushPrefEnv({ set: [['media.webspeech.synth.enabled', true]] },
+                          function() { document.getElementById("testFrame").src = "file_speech_queue.html"; });
 
 </script>
 </pre>
 </body>
 </html>
--- a/content/media/webspeech/synth/test/test_speech_simple.html
+++ b/content/media/webspeech/synth/test/test_speech_simple.html
@@ -8,46 +8,26 @@ https://bugzilla.mozilla.org/show_bug.cg
   <title>Test for Bug 650295: Web Speech API check all classes are present</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript" src="common.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=650295">Mozilla Bug 650295</a>
 <p id="display"></p>
+<iframe id="testFrame"></iframe>
 <div id="content" style="display: none">
   
 </div>
 <pre id="test">
 <script type="application/javascript">
 
 /** Test for Bug 525444 **/
 
 SimpleTest.waitForExplicitFinish();
 
-synthAddVoice('TestSpeechServiceWithAudio', 'Male 1', 'en-GB', true);
-
-var gotStartEvent = false;
-var gotBoundaryEvent = false;
-var utterance = new SpeechSynthesisUtterance("Hello, world!");
-utterance.addEventListener('start', function(e) {
-  ok(speechSynthesis.speaking, "speechSynthesis is speaking.");
-  ok(!speechSynthesis.pending, "speechSynthesis has no other utterances queued.");
-  gotStartEvent = true;
-});
-
-utterance.addEventListener('end', function(e) {
-  ok(!speechSynthesis.speaking, "speechSynthesis is not speaking.");
-  ok(!speechSynthesis.pending, "speechSynthesis has no other utterances queued.");
-  ok(gotStartEvent, "Got 'start' event.");
-  info('end ' + e.elapsedTime);
-  synthCleanup();
-  SimpleTest.finish();
-});
-
-speechSynthesis.speak(utterance);
-ok(!speechSynthesis.speaking, "speechSynthesis is not speaking yet.");
-ok(speechSynthesis.pending, "speechSynthesis has an utterance queued.");
+SpecialPowers.pushPrefEnv({ set: [['media.webspeech.synth.enabled', true]] },
+                          function() { document.getElementById("testFrame").src = "file_speech_simple.html"; });
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/events/test/test_bug508479.html
+++ b/dom/events/test/test_bug508479.html
@@ -8,20 +8,17 @@
 <script>
   
 var gGotHandlingDrop = false;
 var gGotNotHandlingDrop = false;
 
 SimpleTest.waitForExplicitFinish();
 
 function fireEvent(target, event) {
-  var utils =
-    window.QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor).
-           getInterface(SpecialPowers.Ci.nsIDOMWindowUtils);
-  SpecialPowers.wrap(utils).dispatchDOMEventViaPresShell(target, event, true);
+  SpecialPowers.DOMWindowUtils.dispatchDOMEventViaPresShell(target, event, true);
 }
 
 function fireDrop(element, shouldAllowDrop, shouldAllowOnlyChromeDrop) {
   var ds = SpecialPowers.Cc["@mozilla.org/widget/dragservice;1"].
     getService(SpecialPowers.Ci.nsIDragService);
 
   var dataTransfer;
   var trapDrag = function(event) {
--- a/dom/tests/browser/browser_ConsoleStorageAPITests.js
+++ b/dom/tests/browser/browser_ConsoleStorageAPITests.js
@@ -38,18 +38,17 @@ var ConsoleObserver = {
         is(messages.length, 0, "Cleared Storage");
 
         // make sure a closed window's events are in fact removed from the
         // storage cache
         win.console.log("adding a new event");
         // Close the window.
         gBrowser.removeTab(tab, {animate: false});
         // Ensure actual window destruction is not delayed (too long).
-        window.QueryInterface(Ci.nsIInterfaceRequestor)
-              .getInterface(Ci.nsIDOMWindowUtils).garbageCollect();
+        SpecialPowers.DOMWindowUtils.garbageCollect();
         // Ensure "inner-window-destroyed" event is processed,
         // so the storage cache is cleared.
         executeSoon(function () {
           // use the old windowID again to see if we have any stray cached messages
           messages = ConsoleAPIStorage.getEvents(windowID);
           is(messages.length, 0, "tab close is clearing the cache");
           finish();
         });
--- a/dom/tests/mochitest/bugs/test_bug346659.html
+++ b/dom/tests/mochitest/bugs/test_bug346659.html
@@ -130,20 +130,17 @@ function messageReceiver(evt) {
       ok(0, "unexpected test number (" + testNumber + ") when data is " + evt.data);
   }
 
   handleTestEnd();
 }
 
 function handleTestEnd() {
   function gc() {
-    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-    window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
-          .getInterface(Components.interfaces.nsIDOMWindowUtils)
-          .garbageCollect();
+    SpecialPowers.DOMWindowUtils.garbageCollect();
   }
   if (numTestsSet1) {
     if (!--numTestsSet1) {
       // gc to get rid of all the old windows
       gc(); gc(); gc();
       setTimeout(startSecondBatch, 0);
     }
   } else if (numTestsSet2) {
--- a/dom/tests/mochitest/bugs/test_bug397571.html
+++ b/dom/tests/mochitest/bugs/test_bug397571.html
@@ -17,18 +17,17 @@ 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(SpecialPowers.Ci.nsIInterfaceRequestor).
-               getInterface(SpecialPowers.Ci.nsIDOMWindowUtils);
+var utils = SpecialPowers.DOMWindowUtils.SpecialPowers_wrappedObject;
 
 // Try to call functions without privileges
 var success = false;
 try {
   isForced = utils.docCharsetIsForced;
 }
 catch(e) {
   success = true;
--- a/editor/composer/test/test_bug519928.html
+++ b/editor/composer/test/test_bug519928.html
@@ -17,17 +17,18 @@ https://bugzilla.mozilla.org/show_bug.cg
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 var iframe = document.getElementById("load-frame");
 
 function enableJS() allowJS(true, iframe);
 function disableJS() allowJS(false, iframe);
 function allowJS(allow, frame) {
-  SpecialPowers.wrap(frame.contentWindow.QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor))
+  SpecialPowers.wrap(frame.contentWindow)
+               .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
                .getInterface(SpecialPowers.Ci.nsIWebNavigation)
                .QueryInterface(SpecialPowers.Ci.nsIDocShell)
                .allowJavascript = allow;
 }
 function expectJSAllowed(allowed, testCondition, callback) {
   window.ICanRunMyJS = false;
   var self_ = window;
   testCondition();
--- a/editor/libeditor/html/tests/test_bug432225.html
+++ b/editor/libeditor/html/tests/test_bug432225.html
@@ -31,17 +31,18 @@ function getEdit() {
 
 function editDoc() {
   return getEdit().contentDocument;
 }
 
 function getSpellCheckSelection() {
   var Ci = SpecialPowers.Ci;
   var win = editDoc().defaultView;
-  var editingSession = SpecialPowers.wrap(win.QueryInterface(Ci.nsIInterfaceRequestor))
+  var editingSession = SpecialPowers.wrap(win)
+                                    .QueryInterface(Ci.nsIInterfaceRequestor)
                                     .getInterface(Ci.nsIWebNavigation)
                                     .QueryInterface(Ci.nsIInterfaceRequestor)
                                     .getInterface(Ci.nsIEditingSession);
   var editor = editingSession.getEditorForWindow(win);
   var selcon = editor.selectionController;
   return selcon.getSelection(selcon.SELECTION_SPELLCHECK);  
 }
 
--- a/editor/libeditor/html/tests/test_bug468353.html
+++ b/editor/libeditor/html/tests/test_bug468353.html
@@ -48,17 +48,18 @@ function runTest() {
   var editdoc = editframe.document;
   var editor = null;
   editdoc.write('');
   editdoc.close();
 
   editdoc.designMode='on';
 
   // Hold the reference to the editor
-  editor = SpecialPowers.wrap(editframe.QueryInterface(Ci.nsIInterfaceRequestor))
+  editor = SpecialPowers.wrap(editframe)
+                        .QueryInterface(Ci.nsIInterfaceRequestor)
                         .getInterface(Ci.nsIWebNavigation)
                         .QueryInterface(Ci.nsIInterfaceRequestor)
                         .getInterface(Ci.nsIEditingSession)
                         .getEditorForWindow(editframe);
 
   styleSheets = editor.QueryInterface(Ci.nsIEditorStyleSheets);
 
   editdoc.designMode='off';
@@ -67,34 +68,36 @@ function runTest() {
   
   // Let go
   editor = null;
   styleSheets = null;
   
   editdoc.body.contentEditable = true;
   
   // Hold the reference to the editor
-  editor = SpecialPowers.wrap(editframe.QueryInterface(Ci.nsIInterfaceRequestor))
+  editor = SpecialPowers.wrap(editframe)
+                        .QueryInterface(Ci.nsIInterfaceRequestor)
                         .getInterface(Ci.nsIWebNavigation)
                         .QueryInterface(Ci.nsIInterfaceRequestor)
                         .getInterface(Ci.nsIEditingSession)
                         .getEditorForWindow(editframe);
 
   styleSheets = editor.QueryInterface(Ci.nsIEditorStyleSheets);
   
   editdoc.body.contentEditable = false;
   
   checkStylesheets();
 
   editdoc.designMode = "on";
   editdoc.body.contentEditable = true;
   editdoc.designMode = "off";
 
   // Hold the reference to the editor
-  editor = SpecialPowers.wrap(editframe.QueryInterface(Ci.nsIInterfaceRequestor))
+  editor = SpecialPowers.wrap(editframe)
+                        .QueryInterface(Ci.nsIInterfaceRequestor)
                         .getInterface(Ci.nsIWebNavigation)
                         .QueryInterface(Ci.nsIInterfaceRequestor)
                         .getInterface(Ci.nsIEditingSession)
                         .getEditorForWindow(editframe);
 
   styleSheets = editor.QueryInterface(Ci.nsIEditorStyleSheets);
 
   editdoc.body.contentEditable = false;
--- a/gfx/tests/mochitest/test_bug513439.html
+++ b/gfx/tests/mochitest/test_bug513439.html
@@ -20,18 +20,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 /** Test for Bug 513439 **/
 
 var prefService = SpecialPowers.Cc["@mozilla.org/preferences-service;1"]
                                .getService(SpecialPowers.Ci.nsIPrefService);
 var layoutCSSBranch = prefService.getBranch("layout.css.");
 var oldVal = layoutCSSBranch.getCharPref("devPixelsPerPx");
 
 try {
-  var domWindowUtils = window.QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
-                             .getInterface(SpecialPowers.Ci.nsIDOMWindowUtils);
+  var domWindowUtils = SpecialPowers.DOMWindowUtils;
   var devPxPerCSSPx = domWindowUtils.screenPixelsPerCSSPixel;
 
   layoutCSSBranch.setCharPref("devPixelsPerPx", "2");
   is(domWindowUtils.screenPixelsPerCSSPixel, 2, "devPixelsPerPx wasn't set correctly");
 
   layoutCSSBranch.setCharPref("devPixelsPerPx", "1.5");
   is(domWindowUtils.screenPixelsPerCSSPixel, 1.5, "devPixelsPerPx wasn't set correctly");
 
--- a/js/xpconnect/tests/chrome/test_doublewrappedcompartments.xul
+++ b/js/xpconnect/tests/chrome/test_doublewrappedcompartments.xul
@@ -17,19 +17,17 @@ https://bugzilla.mozilla.org/show_bug.cg
           src="http://example.org/tests/js/xpconnect/tests/mochitest/file_doublewrappedcompartments.html"
           onload="go()"
           id="ifr">
   </iframe>
   </body>
 
   <!-- test code goes here -->
   <script type="application/javascript"><![CDATA[
-      const Ci = Components.interfaces;
-      const utils = window.QueryInterface(Ci.nsIInterfaceRequestor)
-                          .getInterface(Ci.nsIDOMWindowUtils);
+      const utils = SpecialPowers.DOMWindowUtils;
 
       function go() {
         var wrappedWin = $('ifr').contentWindow;
         is(typeof wrappedWin.expando, 'undefined', "Shouldn't be able to see the expando");
 
         var unwrapped = wrappedWin.wrappedJSObject;
 
         var expando = unwrapped.expando;
--- a/js/xpconnect/tests/mochitest/file_doublewrappedcompartments.html
+++ b/js/xpconnect/tests/mochitest/file_doublewrappedcompartments.html
@@ -3,18 +3,15 @@
         <script>
             // We want to put an expando on the object, but we want this object
             // to be wrapped in other compartments. This means that the expando
             // must implement precreate, which happens (in general) for nodes.
             // So we just do a cyclic reference to the document body.
             window.expando = document.documentElement;
 
             function testme(obj) {
-                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-                const Ci = Components.interfaces;
-                const utils = window.QueryInterface(Ci.nsIInterfaceRequestor)
-                                    .getInterface(Ci.nsIDOMWindowUtils);
+                const utils = SpecialPowers.DOMWindowUtils;
 
                 return utils.getClassName(obj) != "Proxy" &&
                        typeof obj.querySelector == 'function';
             }
         </script>
     </head>
--- a/security/manager/ssl/tests/mochitest/mixedcontent/backward.html
+++ b/security/manager/ssl/tests/mochitest/mixedcontent/backward.html
@@ -2,19 +2,17 @@
 <html>
 <head>
   <script type="text/javascript">
 
   window.onload = function()
   {
     window.setTimeout(function()
     {
-      netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-
-      window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
-        .getInterface(Components.interfaces.nsIWebNavigation)
+      SpecialPowers.wrap(window).QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
+        .getInterface(SpecialPowers.Ci.nsIWebNavigation)
         .goBack();
     }, 100);
   }
   
   </script>
 </head>
 </html>
--- a/toolkit/components/passwordmgr/test/pwmgr_common.js
+++ b/toolkit/components/passwordmgr/test/pwmgr_common.js
@@ -112,19 +112,19 @@ function doKey(aKey, modifier) {
     var keyName = "DOM_VK_" + aKey.toUpperCase();
     var key = KeyEvent[keyName];
 
     // undefined --> null
     if (!modifier)
         modifier = null;
 
     // Window utils for sending fake sey events.
-    var wutils = window.QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor).
+    var wutils = SpecialPowers.wrap(window).
+                          QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor).
                           getInterface(SpecialPowers.Ci.nsIDOMWindowUtils);
-    wutils = SpecialPowers.wrap(wutils);
 
     if (wutils.sendKeyEvent("keydown",  key, 0, modifier)) {
       wutils.sendKeyEvent("keypress", key, 0, modifier);
     }
     wutils.sendKeyEvent("keyup",    key, 0, modifier);
 }
 
 // Init with a common login