Bug 675245 - cleanup pluginutils and SimpleTest.executeSoon() to utilize specialpowers. r=ted
authorJoel Maher <jmaher@mozilla.com>
Wed, 19 Oct 2011 05:35:05 -0400
changeset 78933 c4aca24c69c82bd49b77b10d24a44f0a8a29256c
parent 78931 6d6fdd47ee1bf134c1c0d38c3170a4d4979421a1
child 78934 2c4eccfeceede5fc31ae4701a098a9f6a04c8082
push id21351
push usermak77@bonardo.net
push dateThu, 20 Oct 2011 09:35:01 +0000
treeherdermozilla-central@67673422f7d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs675245
milestone10.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 675245 - cleanup pluginutils and SimpleTest.executeSoon() to utilize specialpowers. r=ted
content/base/test/chrome/test_bug391728.html
dom/plugins/test/mochitest/test_clear_site_data.html
testing/mochitest/chrome/Makefile.in
testing/mochitest/chrome/test_sanityPluginUtils.html
testing/mochitest/jar.mn
testing/mochitest/tests/Makefile.in
testing/mochitest/tests/SimpleTest/ChromeUtils.js
testing/mochitest/tests/SimpleTest/Makefile.in
testing/mochitest/tests/SimpleTest/PluginUtils.js
testing/mochitest/tests/test_sanityPluginUtils.html
--- a/content/base/test/chrome/test_bug391728.html
+++ b/content/base/test/chrome/test_bug391728.html
@@ -1,17 +1,17 @@
 <!DOCTYPE HTML>
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=391728
 -->
 <head>
   <title>Test for Bug 391728</title>
   <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/PluginUtils.js"></script>
+  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/ChromeUtils.js"></script>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=391728">Mozilla Bug 391728</a>
 <p id="display"></p>
 <div id="content">
   <iframe id="testframe" width="150" height="250" src="about:blank"></iframe>
 </div>
--- a/dom/plugins/test/mochitest/test_clear_site_data.html
+++ b/dom/plugins/test/mochitest/test_clear_site_data.html
@@ -1,13 +1,13 @@
 <html>
 <head>
   <title>NPAPI ClearSiteData/GetSitesWithData Functionality</title>
   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/PluginUtils.js"></script>
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/ChromeUtils.js"></script>
 </head>
 <body>
   <embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
 
   <script class="testbody" type="application/javascript">
     SimpleTest.waitForExplicitFinish();
 
     const pluginHostIface = Components.interfaces.nsIPluginHost;
--- a/testing/mochitest/chrome/Makefile.in
+++ b/testing/mochitest/chrome/Makefile.in
@@ -41,15 +41,16 @@ srcdir		= @srcdir@
 VPATH		= @srcdir@
 relativesrcdir  = testing/mochitest/chrome
 
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
 _STATIC_FILES = test_sample.xul \
 		test_sanityChromeUtils.xul \
+		test_sanityPluginUtils.html \
 # Disabled until bug 652494 is resolved.
 #		test_sanityException.xul \
 #		test_sanityException2.xul \
 		$(NULL)
 
 libs:: $(_STATIC_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/$(relativesrcdir)
new file mode 100644
--- /dev/null
+++ b/testing/mochitest/chrome/test_sanityPluginUtils.html
@@ -0,0 +1,38 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <script type="text/javascript">
+  var start = new Date();
+  </script>
+  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/ChromeUtils.js"></script>
+  <script type="text/javascript">
+  var loadTime = new Date();
+  </script>
+  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
+</head>
+<body onload="starttest()">
+<!-- load the test plugin defined at $(DIST)/bin/plugins/Test.plugin/ -->
+<embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
+<script class="testbody" type="text/javascript">
+SimpleTest.info("\nProfile::PluginUtilsLoadTime: " + (loadTime - start) + "\n");
+function starttest() {
+  SimpleTest.waitForExplicitFinish();
+  var startTime = new Date();
+  //increase the runtime of the test so it is detectible, otherwise we get 0-1ms
+  runtimes = 100;
+  function runTest(plugin) {
+    is(plugin.version, "1.0.0.0", "Make sure version is correct");
+    is(plugin.name, "Test Plug-in");
+  };
+  while (runtimes > 0) {
+    ok(PluginUtils.withTestPlugin(runTest), "Test plugin should be found");
+    --runtimes;
+  }
+  var endTime = new Date();
+  SimpleTest.info("\nProfile::PluginUtilsRunTime: " + (endTime-startTime) + "\n");
+  SimpleTest.finish();
+};
+</script>
+</body>
+</html>
--- a/testing/mochitest/jar.mn
+++ b/testing/mochitest/jar.mn
@@ -13,17 +13,16 @@ mochikit.jar:
   content/static/harness.css (static/harness.css)
   content/tests/SimpleTest/ChromePowers.js (tests/SimpleTest/ChromePowers.js)
   content/tests/SimpleTest/specialpowersAPI.js (tests/SimpleTest/specialpowersAPI.js)
   content/tests/SimpleTest/SpecialPowersObserverAPI.js (tests/SimpleTest/SpecialPowersObserverAPI.js)
   content/tests/SimpleTest/EventUtils.js (tests/SimpleTest/EventUtils.js)
   content/tests/SimpleTest/ChromeUtils.js (tests/SimpleTest/ChromeUtils.js)
   content/tests/SimpleTest/MozillaLogger.js (tests/SimpleTest/MozillaLogger.js)
   content/tests/SimpleTest/LogController.js (tests/SimpleTest/LogController.js)
-  content/tests/SimpleTest/PluginUtils.js (tests/SimpleTest/PluginUtils.js)
   content/tests/SimpleTest/setup.js (tests/SimpleTest/setup.js)
   content/tests/SimpleTest/SimpleTest.js (tests/SimpleTest/SimpleTest.js)
   content/tests/SimpleTest/test.css (tests/SimpleTest/test.css)
   content/tests/SimpleTest/TestRunner.js (tests/SimpleTest/TestRunner.js)
   content/tests/SimpleTest/WindowSnapshot.js (tests/SimpleTest/WindowSnapshot.js)
   content/tests/SimpleTest/mockObjects.js (../../toolkit/content/tests/browser/common/mockObjects.js)
   content/tests/SimpleTest/docshell_helpers.js (../..//docshell/test/chrome/docshell_helpers.js)
 
--- a/testing/mochitest/tests/Makefile.in
+++ b/testing/mochitest/tests/Makefile.in
@@ -59,16 +59,16 @@ include $(topsrcdir)/config/rules.mk
   test_sanityWindowSnapshot.html \
   test_SpecialPowersExtension.html \
   test_SpecialPowersExtension2.html \
   file_SpecialPowersFrame1.html \
   $(NULL)
 
 ifneq ($(OS_TARGET),Android)
 # Disabled on Android for permaorange, see bug 688052
-  _TEST_FILES += test_sanityPluginUtils.html \
+  _TEST_FILES += \
   test_sanityEventUtils.html \
   test_sanitySimpletest.html
 endif
 # Copy the sanity tests into a subdirectory, so the top level is all dirs
 # in the test screen.
 libs:: $(_TEST_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/$(relativesrcdir)/Harness_sanity
--- a/testing/mochitest/tests/SimpleTest/ChromeUtils.js
+++ b/testing/mochitest/tests/SimpleTest/ChromeUtils.js
@@ -270,9 +270,37 @@ function synthesizeDrop(srcElement, dest
     }
 
     synthesizeMouseAtCenter(destElement, { type: "mouseup" }, aWindow);
 
     return dataTransfer.dropEffect;
   } finally {
     ds.endDragSession(true);
   }
-}
+};
+
+var PluginUtils =
+{
+  withTestPlugin : function(callback)
+  {
+    if (typeof Components == "undefined")
+    {
+      todo(false, "Not a Mozilla-based browser");
+      return false;
+    }
+
+    var ph = Components.classes["@mozilla.org/plugin/host;1"]
+                       .getService(Components.interfaces.nsIPluginHost);
+    var tags = ph.getPluginTags();
+
+    // Find the test plugin
+    for (var i = 0; i < tags.length; i++)
+    {
+      if (tags[i].name == "Test Plug-in")
+      {
+        callback(tags[i]);
+        return true;
+      }
+    }
+    todo(false, "Need a test plugin on this platform");
+    return false;
+  }
+};
--- a/testing/mochitest/tests/SimpleTest/Makefile.in
+++ b/testing/mochitest/tests/SimpleTest/Makefile.in
@@ -46,17 +46,16 @@ include $(topsrcdir)/config/rules.mk
 			LogController.js \
 			SimpleTest.js \
 			test.css \
 			TestRunner.js \
 			setup.js \
 			EventUtils.js \
 			ChromeUtils.js \
 			WindowSnapshot.js \
-			PluginUtils.js \
 			specialpowersAPI.js \
 			SpecialPowersObserverAPI.js \
 			$(DEPTH)/toolkit/content/tests/browser/common/mockObjects.js \
                         $(DEPTH)/docshell/test/chrome/docshell_helpers.js \
 			$(NULL)
 
 libs:: $(_SIMPLETEST_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/$(relativesrcdir)
deleted file mode 100644
--- a/testing/mochitest/tests/SimpleTest/PluginUtils.js
+++ /dev/null
@@ -1,28 +0,0 @@
-var PluginUtils =
-{
-  withTestPlugin : function(callback)
-  {
-    if (typeof Components == "undefined")
-    {
-      todo(false, "Not a Mozilla-based browser");
-      return false;
-    }
-
-    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-    var ph = Components.classes["@mozilla.org/plugin/host;1"]
-                       .getService(Components.interfaces.nsIPluginHost);
-    var tags = ph.getPluginTags();
-
-    // Find the test plugin
-    for (var i = 0; i < tags.length; i++)
-    {
-      if (tags[i].name == "Test Plug-in")
-      {
-        callback(tags[i]);
-        return true;
-      }
-    }
-    todo(false, "Need a test plugin on this platform");
-    return false;
-  }
-};
deleted file mode 100644
--- a/testing/mochitest/tests/test_sanityPluginUtils.html
+++ /dev/null
@@ -1,39 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>Profiling test suite for PluginUtils</title>
-  <script type="text/javascript">
-  var start = new Date();
-  </script>
-  <script type="text/javascript" src="/tests/SimpleTest/PluginUtils.js"></script>
-  <script type="text/javascript">
-  var loadTime = new Date();
-  </script>
-  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
-</head>
-<body onload="starttest()">
-<!-- load the test plugin defined at $(DIST)/bin/plugins/Test.plugin/ -->
-<embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
-<script class="testbody" type="text/javascript">
-SimpleTest.info("\nProfile::PluginUtilsLoadTime: " + (loadTime - start) + "\n");
-function starttest() {
-  SimpleTest.waitForExplicitFinish();
-  var startTime = new Date();
-  //increase the runtime of the test so it is detectible, otherwise we get 0-1ms
-  runtimes = 100;
-  function runTest(plugin) {
-    is(plugin.version, "1.0.0.0", "Make sure version is correct");
-    is(plugin.name, "Test Plug-in");
-  };
-  while (runtimes > 0) {
-    ok(PluginUtils.withTestPlugin(runTest), "Test plugin should be found");
-    --runtimes;
-  }
-  var endTime = new Date();
-  SimpleTest.info("\nProfile::PluginUtilsRunTime: " + (endTime-startTime) + "\n");
-  SimpleTest.finish();
-};
-</script>
-</body>
-</html>