Bug 943152 - Tests. r=jgriffin
authorBobby Holley <bobbyholley@gmail.com>
Wed, 04 Dec 2013 19:15:40 -0800
changeset 173533 1ae80631738afab72c91ffd7c6d1ebd741a8beb3
parent 173532 e63758ec19f8b86db758a284afad31e1a8064810
child 173534 997ec8454c145822d7ef2becd568637092df6414
push id3224
push userlsblakk@mozilla.com
push dateTue, 04 Feb 2014 01:06:49 +0000
treeherdermozilla-beta@60c04d0987f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgriffin
bugs943152
milestone28.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 943152 - Tests. r=jgriffin
js/xpconnect/tests/chrome/test_bug361111.xul
js/xpconnect/tests/chrome/test_bug448587.xul
testing/mochitest/tests/test_SpecialPowersExtension.html
testing/mochitest/tests/test_SpecialPowersExtension2.html
--- a/js/xpconnect/tests/chrome/test_bug361111.xul
+++ b/js/xpconnect/tests/chrome/test_bug361111.xul
@@ -17,12 +17,17 @@ https://bugzilla.mozilla.org/show_bug.cg
   <!-- test code goes here -->
   <script type="application/javascript"><![CDATA[
 
     /** Test for Bug 361111 **/
     window.onerror = null;
     SimpleTest.waitForExplicitFinish();
     document.documentElement.setAttribute("onclick", "%");
     is(1, 1, "Good, setting a bogus onclick did not throw.");
-    SimpleTest.finish();
+
+    // Bonus test - make sure that flushPrefEnv is appropriately
+    // called at the end of the test. It would be nice if there were
+    // somewhere in the harness that this could live, but there isn't.
+    SpecialPowers.pushPrefEnv({set: [['testing.some_arbitrary_pref', true]]},
+                              function() { SimpleTest.finish(); });
 
   ]]></script>
 </window>
--- a/js/xpconnect/tests/chrome/test_bug448587.xul
+++ b/js/xpconnect/tests/chrome/test_bug448587.xul
@@ -14,16 +14,22 @@ https://bugzilla.mozilla.org/show_bug.cg
   <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=448587"
      target="_blank">Mozilla Bug 448587</a>
   </body>
 
   <!-- test code goes here -->
   <script type="application/javascript">
   <![CDATA[
 
+  // Bonus test - collaborate with test_bug361111.xul to make sure that
+  // flushPrefEnv is appropriately called.
+  ok(!SpecialPowers.Services.prefs.prefHasUserValue('testing.some_arbitrary_pref'),
+     "Pref shouldn't carry over from previous test!");
+
+
   /** Test for Bug 448587 **/
   const Cu = Components.utils;
   var sandbox = new Cu.Sandbox("about:blank");
   var fwrapper = Cu.evalInSandbox("function f() {} f", sandbox);
   is(fwrapper.prototype, Cu.evalInSandbox("f.prototype", sandbox),
      "we don't censor .prototype through .wrappedJSObject");
   ]]>
   </script>
--- a/testing/mochitest/tests/test_SpecialPowersExtension.html
+++ b/testing/mochitest/tests/test_SpecialPowersExtension.html
@@ -156,15 +156,20 @@ function starttest(){
   SpecialPowers.wrap(document).title = "foo";
   is(document.title, "foo", "Set property correctly on Xray-wrapped DOM object");
   is(SpecialPowers.wrap(document).URI, document.URI, "Got property correctly on Xray-wrapped DOM object");
 
   info("\nProfile::SpecialPowersRunTime: " + (new Date() - startTime) + "\n");
 
   // bug 855192
   ok(SpecialPowers.MockPermissionPrompt, "check mock permission prompt");
-  SimpleTest.finish();
+
+  // Set a pref using pushPrefEnv to make sure that flushPrefEnv is
+  // automatically called before we invoke
+  // test_SpecialPowersExtension2.html.
+  SpecialPowers.pushPrefEnv({set: [['testing.some_arbitrary_pref', true]]},
+                            function() { SimpleTest.finish(); });
 }
 </script>
 </pre>
 </body>
 </html>
 
--- a/testing/mochitest/tests/test_SpecialPowersExtension2.html
+++ b/testing/mochitest/tests/test_SpecialPowersExtension2.html
@@ -6,14 +6,16 @@
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 
 <div id="content" class="testbody">
   <script type="text/javascript">
     dump("\nSPECIALPTEST2:::Loading test2 file now " + (new Date).getTime() + "\n");
     is(SpecialPowers.sanityCheck(), "foo", "Special Powers top level");
+    ok(!SpecialPowers.Services.prefs.prefHasUserValue('testing.some_arbitrary_pref'),
+       "should not retain pref from previous test");
   </script>
   <iframe id="frame1" src="file_SpecialPowersFrame1.html">
   </iframe>
 </div>
 </body>
 </html>