Bug 899080 - Test fixup part 2 - dom/plugins. r=bsmedberg
authorGeorg Fritzsche <georg.fritzsche@googlemail.com>
Wed, 04 Sep 2013 16:05:40 +0200
changeset 145518 3bcbfbc9591bda8c4de01d18371bc70cbe9a763f
parent 145517 46a5c7cf1ec40ee749f2c1c913d3f45902759bd9
child 145519 4b9221731b0e413c9b0bf55336823833b55f196c
push id33305
push usergeorg.fritzsche@googlemail.com
push dateWed, 04 Sep 2013 21:10:31 +0000
treeherdermozilla-inbound@1e63861a73d9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs899080
milestone26.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 899080 - Test fixup part 2 - dom/plugins. r=bsmedberg
dom/plugins/test/mochitest/test_GCrace.html
dom/plugins/test/mochitest/test_NPNVdocumentOrigin.html
dom/plugins/test/mochitest/test_NPPVpluginWantsAllNetworkStreams.html
dom/plugins/test/mochitest/test_bug479979.xul
dom/plugins/test/mochitest/test_bug532208.html
dom/plugins/test/mochitest/test_bug539565-1.html
dom/plugins/test/mochitest/test_bug539565-2.html
dom/plugins/test/mochitest/test_bug751809.html
dom/plugins/test/mochitest/test_bug771202.html
dom/plugins/test/mochitest/test_bug777098.html
dom/plugins/test/mochitest/test_bug784131.html
dom/plugins/test/mochitest/test_bug813906.html
dom/plugins/test/mochitest/test_bug854082.html
dom/plugins/test/mochitest/test_bug863792.html
dom/plugins/test/mochitest/test_busy_hang.xul
dom/plugins/test/mochitest/test_clear_site_data.html
dom/plugins/test/mochitest/test_cocoa_focus.html
dom/plugins/test/mochitest/test_cocoa_window_focus.html
dom/plugins/test/mochitest/test_convertpoint.xul
dom/plugins/test/mochitest/test_cookies.html
dom/plugins/test/mochitest/test_copyText.html
dom/plugins/test/mochitest/test_crash_nested_loop.html
dom/plugins/test/mochitest/test_crash_notify.xul
dom/plugins/test/mochitest/test_crash_notify_no_report.xul
dom/plugins/test/mochitest/test_crash_submit.xul
dom/plugins/test/mochitest/test_crashing.html
dom/plugins/test/mochitest/test_crashing2.html
dom/plugins/test/mochitest/test_defaultValue.html
dom/plugins/test/mochitest/test_enumerate.html
dom/plugins/test/mochitest/test_fullpage.html
dom/plugins/test/mochitest/test_getauthenticationinfo.html
dom/plugins/test/mochitest/test_hang_submit.xul
dom/plugins/test/mochitest/test_hanging.html
dom/plugins/test/mochitest/test_idle_hang.xul
dom/plugins/test/mochitest/test_instance_re-parent.html
dom/plugins/test/mochitest/test_instance_unparent1.html
dom/plugins/test/mochitest/test_instance_unparent2.html
dom/plugins/test/mochitest/test_instance_unparent3.html
dom/plugins/test/mochitest/test_instantiation.html
dom/plugins/test/mochitest/test_multipleinstanceobjects.html
dom/plugins/test/mochitest/test_newstreamondestroy.html
dom/plugins/test/mochitest/test_npn_asynccall.html
dom/plugins/test/mochitest/test_npn_timers.html
dom/plugins/test/mochitest/test_npobject_getters.html
dom/plugins/test/mochitest/test_npruntime.xul
dom/plugins/test/mochitest/test_npruntime_construct.html
dom/plugins/test/mochitest/test_npruntime_identifiers.html
dom/plugins/test/mochitest/test_npruntime_npnevaluate.html
dom/plugins/test/mochitest/test_npruntime_npninvoke.html
dom/plugins/test/mochitest/test_npruntime_npninvokedefault.html
dom/plugins/test/mochitest/test_npruntime_npnsetexception.html
dom/plugins/test/mochitest/test_painting.html
dom/plugins/test/mochitest/test_plugin_scroll_painting.html
dom/plugins/test/mochitest/test_plugin_tag_clicktoplay.html
dom/plugins/test/mochitest/test_pluginstream_asfile.html
dom/plugins/test/mochitest/test_pluginstream_asfileonly.html
dom/plugins/test/mochitest/test_pluginstream_err.html
dom/plugins/test/mochitest/test_pluginstream_geturl.html
dom/plugins/test/mochitest/test_pluginstream_geturlnotify.html
dom/plugins/test/mochitest/test_pluginstream_newstream.html
dom/plugins/test/mochitest/test_pluginstream_post.html
dom/plugins/test/mochitest/test_pluginstream_poststream.html
dom/plugins/test/mochitest/test_pluginstream_referer.html
dom/plugins/test/mochitest/test_pluginstream_seek.html
dom/plugins/test/mochitest/test_pluginstream_seek_close.html
dom/plugins/test/mochitest/test_pluginstream_src.html
dom/plugins/test/mochitest/test_pluginstream_src_dynamic.html
dom/plugins/test/mochitest/test_pluginstream_src_referer.html
dom/plugins/test/mochitest/test_positioning.html
dom/plugins/test/mochitest/test_privatemode_perwindowpb.xul
dom/plugins/test/mochitest/test_propertyAndMethod.html
dom/plugins/test/mochitest/test_queryContentsScaleFactor.html
dom/plugins/test/mochitest/test_redirect_handling.html
dom/plugins/test/mochitest/test_refresh_navigator_plugins.html
dom/plugins/test/mochitest/test_secondPlugin.html
dom/plugins/test/mochitest/test_src_url_change.html
dom/plugins/test/mochitest/test_streamNotify.html
dom/plugins/test/mochitest/test_streamatclose.html
dom/plugins/test/mochitest/test_twostreams.html
dom/plugins/test/mochitest/test_visibility.html
dom/plugins/test/mochitest/test_windowed_invalidate.html
dom/plugins/test/mochitest/test_wmode.xul
dom/plugins/test/mochitest/test_xulbrowser_plugin_visibility.xul
dom/plugins/test/mochitest/test_zero_opacity.html
dom/plugins/test/mochitest/utils.js
--- a/dom/plugins/test/mochitest/test_GCrace.html
+++ b/dom/plugins/test/mochitest/test_GCrace.html
@@ -1,22 +1,22 @@
 <head>
   <title>GC race with actors on the parent</title>
 
   <script type="text/javascript"
 	  src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="utils.js"></script>
   <link rel="stylesheet" type="text/css"
 	href="/tests/SimpleTest/test.css" />
 <body onload="start()">
   <p id="display"></p>
 
-  <embed id="p" type="application/x-test" wmode="window"></embed>
-
   <script class="testbody" type="application/javascript">
     SimpleTest.waitForExplicitFinish();
+    setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
     function start() {
       if (!SimpleTest.testPluginIsOOP()) {
         ok(true, "Skipping this test when test plugin is not OOP.");
         SimpleTest.finish();
         return;
       }
       else {
@@ -63,8 +63,10 @@
 
       nested = false;
 
       setTimeout(function() {
         SpecialPowers.Cu.forceGC();
       }, 2000);
     }
   </script>
+
+  <embed id="p" type="application/x-test" wmode="window"></embed>
--- a/dom/plugins/test/mochitest/test_NPNVdocumentOrigin.html
+++ b/dom/plugins/test/mochitest/test_NPNVdocumentOrigin.html
@@ -1,18 +1,18 @@
 <html>
 <head>
   <title>Test NPNVdocumentOrigin</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="utils.js"></script>
 </head>
 <body onload="runTest()">
-  <embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
-
   <script class="testbody" type="application/javascript">
     SimpleTest.waitForExplicitFinish();
+    setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
     function runTest() {
       "use strict";
       var p1 = document.getElementById("plugin1");
       var realOrigin = "http://mochi.test:8888";
 
       // Test with no modifications
       is(p1.getNPNVdocumentOrigin(), realOrigin, "Checking for expected origin.");
@@ -34,10 +34,12 @@
       newWindow.document.writeln('<embed id="plugin2" type="application/x-test" width="200" height="200"></embed>');
       var p2 = newWindow.document.getElementById("plugin2");
       is(p2.getNPNVdocumentOrigin(), realOrigin, "Checking for expected origin of plugin in new about:blank window.");
       newWindow.close();
 
       SimpleTest.finish();
     }
   </script>
+
+  <embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
 </body>
 </html>
--- a/dom/plugins/test/mochitest/test_NPPVpluginWantsAllNetworkStreams.html
+++ b/dom/plugins/test/mochitest/test_NPPVpluginWantsAllNetworkStreams.html
@@ -1,20 +1,20 @@
 <html>
 <head>
   <title>Test NPPVpluginWantsAllNetworkStreams</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="utils.js"></script>
 </head>
-<body onload="runNextTest()">
-  <embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
-
+<body onload="runTests()">
   <script class="testbody" type="application/javascript">
     SimpleTest.waitForExplicitFinish();
+    setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
-    var p = document.getElementById("plugin1");
+    var p = null;
 
     var missingDoc = "not-found.html";
 
     var expectedWriteURL = "";
     var expectedNotifyStatus = -1;
 
     var writeHappened = false;
     var expectedWrite = false;
@@ -60,11 +60,18 @@
     function runNextTest() {
       currentTest++;
       if (currentTest < tests.length) {
         tests[currentTest]();
       } else {
         SimpleTest.finish();
       }
     }
+
+    function runTests() {
+      p = document.getElementById("plugin1");
+      runNextTest();
+    }
   </script>
+
+  <embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
 </body>
 </html>
--- a/dom/plugins/test/mochitest/test_bug479979.xul
+++ b/dom/plugins/test/mochitest/test_bug479979.xul
@@ -3,22 +3,22 @@
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 <window title="NPAPI Set Undefined Value Test"
   xmlns:html="http://www.w3.org/1999/xhtml"
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <title>NPAPI Set Undefined Value Test</title>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
+  <script type="application/javascript" src="utils.js"></script>
 <body xmlns="http://www.w3.org/1999/xhtml" onload="runTests()">
-<embed id="plugin1" type="application/x-test" width="300" height="300"></embed>
-</body>
 <script class="testbody" type="application/javascript">
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
+setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
 function runTests() {
   var pluginElement1 = document.getElementById("plugin1");
 
   var rv = true; // we want !true from the test plugin
   var exceptionThrown = false;
   try {
     rv = pluginElement1.setUndefinedValueTest();
@@ -27,9 +27,11 @@ function runTests() {
   }
   is(exceptionThrown, false, "Exception thrown setting undefined variable.");
   is(rv, false, "Setting undefined variable succeeded.");
 
   SimpleTest.finish();
 }
 ]]>
 </script>
+<embed id="plugin1" type="application/x-test" width="300" height="300"></embed>
+</body>
 </window>
--- a/dom/plugins/test/mochitest/test_bug532208.html
+++ b/dom/plugins/test/mochitest/test_bug532208.html
@@ -1,25 +1,28 @@
 <head>
 <title>Test for correct async delivery of large streams, bug
 532208</title>
 
 <script type="application/javascript"
 src="/tests/SimpleTest/SimpleTest.js"></script>
+<script type="application/javascript" src="utils.js"></script>
 
 <body onload="setTimeout(runTests, 2000)">
-  <embed id="plugin1" type="application/x-test" width="400"
-  height="400" src="large-pic.jpg" functiontofail="npp_write_rpc" streammode="normal"></embed>
 
 <script class="testbody" type="application/javascript">
 SimpleTest.waitForExplicitFinish();
+setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
 function runTests() {
   try {
     document.getElementById('plugin1').getPaintCount();
     ok(true, "Data delivery didn't crash");
   }
   catch (e) {
     ok(false, "Data delivery crashed");
   }
   SimpleTest.finish();
 }
 </script>
+
+<embed id="plugin1" type="application/x-test" width="400"
+  height="400" src="large-pic.jpg" functiontofail="npp_write_rpc" streammode="normal"></embed>
--- a/dom/plugins/test/mochitest/test_bug539565-1.html
+++ b/dom/plugins/test/mochitest/test_bug539565-1.html
@@ -2,16 +2,17 @@
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=539565
 -->
 <head>
   <title>Test #1 for Bug 539565</title>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
+  <script type="application/javascript" src="utils.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 
   <script class="testbody" type="text/javascript">
 function runTests() {
   netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
   viewer = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
                  .getInterface(Components.interfaces.nsIWebNavigation)
                  .QueryInterface(Components.interfaces.nsIDocShell)
@@ -80,16 +81,17 @@ function runTests() {
     zoom(1);
     SimpleTest.finish();
   }
 
   setTimeout(function(){waitForPaint(test1)},1000);
 }
 
 SimpleTest.waitForExplicitFinish();
+setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
   </script>
 </head>
 
 <body onload="runTests()">
  <div id="container" style="position:relative;top: 0px; left: 0px; width: 640px; height: 480px;"> 
   <div id="abs" style="position:absolute; left:90px; top:90px; width:20px; height:20px; background:blue; pointer-events:none;"></div>
   <embed id="plugin1" type="application/x-test" wmode="transparent" width="200" height="200"></embed>
--- a/dom/plugins/test/mochitest/test_bug539565-2.html
+++ b/dom/plugins/test/mochitest/test_bug539565-2.html
@@ -2,16 +2,17 @@
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=539565
 -->
 <head>
   <title>Test #2 for Bug 539565</title>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
+  <script type="application/javascript" src="utils.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 
   <script class="testbody" type="text/javascript">
 function runTests() {
   netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
   viewer = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
                  .getInterface(Components.interfaces.nsIWebNavigation)
                  .QueryInterface(Components.interfaces.nsIDocShell)
@@ -100,16 +101,17 @@ function runTests() {
     zoom(1);
     SimpleTest.finish();
   }
 
   setTimeout(function(){waitForPaint(test3)},1000);
 }
 
 SimpleTest.waitForExplicitFinish();
+setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
   </script>
 </head>
 
 <body onload="runTests()">
  <div id="container" style="position:relative;top: 0px; left: 0px; width: 640px; height: 480px; -moz-transform:scale(2); -moz-transform-origin:0px 0px;"> 
   <div id="abs" style="position:absolute; left:90px; top:90px; width:20px; height:20px; background:blue; pointer-events:none;"></div>
   <embed id="plugin1" type="application/x-test" wmode="transparent" width="200" height="200"></embed>
--- a/dom/plugins/test/mochitest/test_bug751809.html
+++ b/dom/plugins/test/mochitest/test_bug751809.html
@@ -1,33 +1,19 @@
 <html>
 <head>
   <title>Bug 751809</title>
   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/paint_listener.js"></script>
+  <script type="application/javascript" src="utils.js"></script>
   <script type="application/javascript;version=1.7">
-  function getTestPlugin() {
-    let ph = Components.classes["@mozilla.org/plugin/host;1"]
-               .getService(Components.interfaces.nsIPluginHost);
-    let tags = ph.getPluginTags();
-
-    // Find the test plugin
-    for (let i = 0; i < tags.length; i++) {
-      if (tags[i].name == "Test Plug-in")
-        return tags[i];
-    }
-      ok(false, "Unable to find plugin");
-      return null;
-    }
-
   Components.utils.import("resource://gre/modules/Services.jsm");
   Services.prefs.setBoolPref("plugins.click_to_play", true);
-  let plugin = getTestPlugin();
-  plugin.enabledState = Components.interfaces.nsIPluginTag.STATE_CLICKTOPLAY;
+  setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_CLICKTOPLAY);
   </script>
 </head>
 
 <body onload="go();">
   <embed id="plugin" type="application/x-test" width="400" height="400" drawmode="solid" color="FF00FFFF"></embed>
 
   <script type="application/javascript;version=1.7">
 
@@ -99,16 +85,14 @@
     var plugin = document.getElementById('plugin');
     try {
       is(plugin.getMouseUpEventCount(), 1, "Plugin should have received 1 mouse up event.");
     } catch(e) {
       ok(false, "plugin.getMouseUpEventCount() shouldn't throw");
     }
 
     Services.prefs.clearUserPref("plugins.click_to_play");
-    let plugin = getTestPlugin();
-    plugin.enabledState = Components.interfaces.nsIPluginTag.STATE_ENABLED;
     SimpleTest.finish();
   }
 
   </script>
 </body>
 </html>
--- a/dom/plugins/test/mochitest/test_bug771202.html
+++ b/dom/plugins/test/mochitest/test_bug771202.html
@@ -2,25 +2,27 @@
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=771202
 -->
 <head>
   <meta charset="utf-8">
   <title>Test for Bug 771202</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="utils.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=771202">Mozilla Bug 771202</a>
 <pre id="test">
 <script type="application/javascript">
 
 /** Test for recreating spliced plugin prototype chains after tranplant. **/
 SimpleTest.waitForExplicitFinish();
+setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
 function go() {
   // Set things up.
   var win = document.getElementById('ifr').contentWindow;
   var plugin = win.document.getElementById('pluginElement');
   var testValue = plugin.getObjectValue();
 
   function checkPlugin() {
--- a/dom/plugins/test/mochitest/test_bug777098.html
+++ b/dom/plugins/test/mochitest/test_bug777098.html
@@ -2,25 +2,27 @@
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=777098
 -->
 <head>
   <meta charset="utf-8">
   <title>Test for Bug 777098</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="utils.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 </head>
 <body onload="go();">
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=777098">Mozilla Bug 777098</a>
 <pre id="test">
 <script type="application/javascript">
 
 /** Test for passing dead NPObjects back into plugins. **/
 SimpleTest.waitForExplicitFinish();
+setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
 function go() {
   var plugin = document.getElementById('plugin');
 
   // Get wrapped npobject from plugin (plugin.__proto__)
   var val = plugin.getObjectValue();
 
   // Force a re-instantiate by re-setting dummy uri,
--- a/dom/plugins/test/mochitest/test_bug784131.html
+++ b/dom/plugins/test/mochitest/test_bug784131.html
@@ -1,24 +1,30 @@
 <!doctype html>
 <html>
 <head>
   <title>Test for Bug 784131</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="utils.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 
   <meta http-equiv="content-type" content="text/html; charset=utf-8">
   <base href="chrome://browser/content/">
 </head>
 <body>
 
+<script type="text/javascript">
+  setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
+</script>
+
 <embed id="body" type="application/x-test">
 <div>
   <embed id="nested" type="application/x-test">
 </div>
+
 <script type="application/javascript">
   function getObjectValue(obj) {
     try {
       return obj.getObjectValue();
     } catch (e) {
       return null;
     }
   }
--- a/dom/plugins/test/mochitest/test_bug813906.html
+++ b/dom/plugins/test/mochitest/test_bug813906.html
@@ -1,37 +1,30 @@
 <!doctype html>
 <html>
 <head>
   <title>Test for Bug 813906</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="utils.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 
   <meta http-equiv="content-type" content="text/html; charset=utf-8">
   <base href="chrome://browser/content/">
 </head>
 <body>
 
 <script type="application/javascript">
 function f() {
   document.getElementsByTagName("base")[0].href = "http://www.safe.com/";
 }
 </script>
 
-<svg>
-  <symbol id="a">
-    <foreignObject>
-      <object bugmode="813906" frame="frame1"></object>
-    </foreignObject>
-  </symbol>
-  <use />
-</svg>
-
 <script type="application/javascript">
 SimpleTest.waitForExplicitFinish();
+setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
 // When the document is torn down or <svg> is removed, we hit bug 621618
 SimpleTest.expectAssertions(1);
 
 var frameLoadCount = 0;
 function frameLoaded() {
   frameLoadCount++;
   if (frameLoadCount == 1) {
@@ -44,11 +37,20 @@ function frameLoaded() {
     // Make sure we trigger bug 621618 before the test finishes so the assertion
     // is attributed to this test.
     document.body.removeChild(document.querySelector("svg"));
     SimpleTest.executeSoon(function() { SimpleTest.finish(); });
   }
 }
 </script>
 
+<svg>
+  <symbol id="a">
+    <foreignObject>
+      <object bugmode="813906" frame="frame1"></object>
+    </foreignObject>
+  </symbol>
+  <use />
+</svg>
+
 <iframe name="frame1" onload="frameLoaded()"></iframe>
 </body>
 </html>
--- a/dom/plugins/test/mochitest/test_bug854082.html
+++ b/dom/plugins/test/mochitest/test_bug854082.html
@@ -1,24 +1,26 @@
 <!doctype html>
 <html>
 <head>
   <title>Test for Bug 854082</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="utils.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 
   <meta http-equiv="content-type" content="text/html; charset=utf-8">
   <base href="chrome://browser/content/">
 </head>
 <body>
 <script type="application/javascript">
   // Tests that destroying the plugin's frame inside NPP_New does not cause a
   // crash
 
   SimpleTest.waitForExplicitFinish();
+  setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
   // Create an object that will spawn asynchronously
   var o = document.createElement("object");
   o.type = "application/x-test";
 
   // The test plugin sets pluginFoundElement on its element inside NPP_New,
   // abuse this to run arbitrary script.
   var setterCalled;
--- a/dom/plugins/test/mochitest/test_bug863792.html
+++ b/dom/plugins/test/mochitest/test_bug863792.html
@@ -1,24 +1,26 @@
 <!doctype html>
 <html>
 <head>
   <title>Test for Bug 863792</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="utils.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 
   <meta http-equiv="content-type" content="text/html; charset=utf-8">
 </head>
 <body>
 <script type="application/javascript">
 
 // A plugin that removes itself from the document and inactivates said document
 // inside NPP_New. We should not leak the instance. See also test_bug854082
 
 SimpleTest.waitForExplicitFinish();
+setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
 var i = document.createElement("iframe");
 i.src = "file_bug863792.html";
 i.width = 500;
 i.height = 500;
 document.body.appendChild(i);
 
 i.addEventListener("load", function() {
--- a/dom/plugins/test/mochitest/test_busy_hang.xul
+++ b/dom/plugins/test/mochitest/test_busy_hang.xul
@@ -5,16 +5,20 @@
 <window title="Basic Plugin Tests"
   xmlns:html="http://www.w3.org/1999/xhtml"
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <title>Plugin Busy Hang Test</title>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
   <script type="application/javascript"
           src="http://mochi.test:8888/chrome/dom/plugins/test/mochitest/hang_test.js" />
+  <script type="application/javascript" src="utils.js"></script>
+  <script type="application/javascript">
+    setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
+  </script>
   <body xmlns="http://www.w3.org/1999/xhtml" onload="runTests()">
     <embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
   </body>
   <script class="testbody" type="application/javascript">
     <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 function runTests() {
--- a/dom/plugins/test/mochitest/test_clear_site_data.html
+++ b/dom/plugins/test/mochitest/test_clear_site_data.html
@@ -1,15 +1,20 @@
 <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/ChromeUtils.js"></script>
+  <script type="application/javascript" src="utils.js"></script>
 </head>
 <body>
+  <script type="application/javascript">
+    setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
+  </script>
+
   <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;
     var pluginHost = Components.classes["@mozilla.org/plugin/host;1"].
                      getService(pluginHostIface);
--- a/dom/plugins/test/mochitest/test_cocoa_focus.html
+++ b/dom/plugins/test/mochitest/test_cocoa_focus.html
@@ -1,17 +1,19 @@
 <html>
 <head>
   <title>NPCocoaEventFocusChanged Tests</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="utils.js"></script>
 </head>
 
 <body onload="runTests()">
   <script class="testbody" type="application/javascript">
     SimpleTest.waitForExplicitFinish();
+    setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
     var gOtherWindow;
 
     function runTests() {
       // We have to have two top-level windows in play in order to run these tests.
       gOtherWindow = window.open("cocoa_focus.html", "", "width=250,height=250");
     }
 
--- a/dom/plugins/test/mochitest/test_cocoa_window_focus.html
+++ b/dom/plugins/test/mochitest/test_cocoa_window_focus.html
@@ -1,17 +1,19 @@
 <html>
 <head>
   <title>NPCocoaEventWindowFocusChanged Tests</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="utils.js"></script>
 </head>
 
 <body onload="runTests()">
   <script class="testbody" type="application/javascript">
     SimpleTest.waitForExplicitFinish();
+    setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
     var gOtherWindow;
 
     function runTests() {
       // We have to have two top-level windows in play in order to run these tests.
       gOtherWindow = window.open("cocoa_window_focus.html", "", "width=200,height=200");
     }
 
--- a/dom/plugins/test/mochitest/test_convertpoint.xul
+++ b/dom/plugins/test/mochitest/test_convertpoint.xul
@@ -3,16 +3,20 @@
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 <window title="Basic Plugin Tests"
   xmlns:html="http://www.w3.org/1999/xhtml"
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <title>NPN_ConvertPoint Tests</title>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
+  <script type="application/javascript" src="utils.js"></script>
+  <script type="application/javascript">
+    setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
+  </script>
 <body xmlns="http://www.w3.org/1999/xhtml" onload="runTests()">
 <embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
 </body>
 <script class="testbody" type="application/javascript">
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 function runTests() {
--- a/dom/plugins/test/mochitest/test_cookies.html
+++ b/dom/plugins/test/mochitest/test_cookies.html
@@ -1,19 +1,23 @@
 <html>
 <head>
   <title>NPAPI Cookie Tests</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="utils.js"></script>
 </head>
 
 <body onload="runTests()">
-  <embed id="plugin1" type="application/x-test" width="400" height="400"></embed>
   <script class="testbody" type="application/javascript">
     SimpleTest.waitForExplicitFinish();
+    setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
+
     function runTests() {
       var pluginElement = document.getElementById("plugin1");
       pluginElement.setCookie("foo");
       is(pluginElement.getCookie(), "foo", "Cookie was set and retrieved correctly via NPAPI.");
       SimpleTest.finish();
     }
   </script>
+
+  <embed id="plugin1" type="application/x-test" width="400" height="400"></embed>
 </body>
 </html>
--- a/dom/plugins/test/mochitest/test_copyText.html
+++ b/dom/plugins/test/mochitest/test_copyText.html
@@ -1,13 +1,14 @@
 <!DOCTYPE HTML>
 <html>
 <head>
   <title>Test copying text from browser to plugin</title>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="utils.js"></script>
 
   <script class="testbody" type="text/javascript">
 function runTests() {
   netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
 
   var text = " some text \n to copy 'n paste "
   var textElt = document.getElementById("input");
   var plugin = document.getElementById("plugin1");
@@ -18,16 +19,17 @@ function runTests() {
   SpecialPowers.wrap(textElt).editor.copy();
 
   is(plugin.getClipboardText(), text);
 
   SimpleTest.finish();
 }
 
 SimpleTest.waitForExplicitFinish();
+setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
   </script>
 </head>
 
 <body onload="runTests()">
   <embed id="plugin1" type="application/x-test" width="400" height="400"></embed>
   <textarea id="input"></textarea>
 
--- a/dom/plugins/test/mochitest/test_crash_nested_loop.html
+++ b/dom/plugins/test/mochitest/test_crash_nested_loop.html
@@ -1,15 +1,17 @@
 <head>
   <title>Plugin crashing in nested loop</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="utils.js"></script>
 
 <body>
   <script class="testbody" type="application/javascript">
   SimpleTest.waitForExplicitFinish();
+  setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
   window.frameLoaded = function frameLoaded_toCrash() {
     if (!SimpleTest.testPluginIsOOP()) {
       ok(true, "Skipping this test when test plugin is not OOP.");
       SimpleTest.finish();
       return;
     }
 
--- a/dom/plugins/test/mochitest/test_crash_notify.xul
+++ b/dom/plugins/test/mochitest/test_crash_notify.xul
@@ -3,16 +3,20 @@
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 <window title="Basic Plugin Tests"
   xmlns:html="http://www.w3.org/1999/xhtml"
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <title>Plugin Crash Notification Test</title>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
+  <script type="application/javascript" src="utils.js"></script>
+  <script type="application/javascript">
+    setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
+  </script>
 <body xmlns="http://www.w3.org/1999/xhtml" onload="runTests()">
 <embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
 </body>
 <script class="testbody" type="application/javascript">
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var success = false;
--- a/dom/plugins/test/mochitest/test_crash_notify_no_report.xul
+++ b/dom/plugins/test/mochitest/test_crash_notify_no_report.xul
@@ -3,16 +3,20 @@
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 <window title="Basic Plugin Tests"
   xmlns:html="http://www.w3.org/1999/xhtml"
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <title>Plugin Crash Notification Test</title>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
+  <script type="application/javascript" src="utils.js"></script>
+  <script type="application/javascript">
+    setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
+  </script>
 <body xmlns="http://www.w3.org/1999/xhtml" onload="runTests()">
 <embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
 </body>
 <script class="testbody" type="application/javascript">
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var success = false;
--- a/dom/plugins/test/mochitest/test_crash_submit.xul
+++ b/dom/plugins/test/mochitest/test_crash_submit.xul
@@ -5,16 +5,20 @@
 <window title="Basic Plugin Tests"
   xmlns:html="http://www.w3.org/1999/xhtml"
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <title>Plugin Crash Notification Test</title>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js" />
+  <script type="application/javascript" src="utils.js"></script>
+  <script type="application/javascript">
+    setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
+  </script>
 <body xmlns="http://www.w3.org/1999/xhtml" onload="runTests()">
 <embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
 </body>
 <script class="testbody" type="application/javascript">
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 SimpleTest.ignoreAllUncaughtExceptions();
 
--- a/dom/plugins/test/mochitest/test_crashing.html
+++ b/dom/plugins/test/mochitest/test_crashing.html
@@ -1,15 +1,17 @@
 <head>
   <title>Plugin crashing</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="utils.js"></script>
 
 <body>
   <script class="testbody" type="application/javascript">
   SimpleTest.waitForExplicitFinish();
+  setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
   window.frameLoaded = function frameLoaded_toCrash() {
    if (!SimpleTest.testPluginIsOOP()) {
       ok(true, "Skipping this test when test plugin is not OOP.");
       SimpleTest.finish();
       return;
     }
 
--- a/dom/plugins/test/mochitest/test_crashing2.html
+++ b/dom/plugins/test/mochitest/test_crashing2.html
@@ -1,17 +1,19 @@
 <head>
   <title>Plugin crashing</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="utils.js"></script>
 
 <body onload="mainLoaded()">
   <iframe id="iframe1" src="about:blank" width="600" height="600"></iframe>
 
   <script class="testbody" type="application/javascript">
   SimpleTest.waitForExplicitFinish();
+  setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
   var iframe = document.getElementById('iframe1');
 
   function mainLoaded() {
     if (!SimpleTest.testPluginIsOOP()) {
       ok(true, "Skipping this test when test plugin is not OOP.");
       SimpleTest.finish();
       return;
--- a/dom/plugins/test/mochitest/test_defaultValue.html
+++ b/dom/plugins/test/mochitest/test_defaultValue.html
@@ -1,22 +1,22 @@
 <html>
   <head>
     <title>NPObject [[DefaultValue]] implementation</title>
 
     <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+    <script type="text/javascript" src="utils.js"></script>
     <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
   </head>
 
   <body onload="run()">
 
-    <embed id="plugin" type="application/x-test" wmode="window"></embed>
-
     <script class="testbody" type="application/javascript">
       SimpleTest.waitForExplicitFinish();
+      setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
       function run() {
         var plugin = document.getElementById("plugin");
         var pluginProto = Object.getPrototypeOf(plugin);
 
         plugin.propertyAndMethod = {};
         plugin.propertyAndMethod + "baz";
         ok(true, "|plugin.propertyAndMethod + \"baz\"| shouldn't assert");
@@ -27,10 +27,12 @@
         plugin + "foo";
         ok(true, "|plugin + \"foo\"| shouldn't assert");
         pluginProto + "bar";
         ok(true, "|pluginProto + \"bar\"| shouldn't assert");
 
         SimpleTest.finish();
       }
     </script>
+
+    <embed id="plugin" type="application/x-test" wmode="window"></embed>
   </body>
 </html>
--- a/dom/plugins/test/mochitest/test_enumerate.html
+++ b/dom/plugins/test/mochitest/test_enumerate.html
@@ -1,32 +1,36 @@
 <html>
 <head>
   <title>NPAPI Cookie Tests</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="utils.js"></script>
 
   <link rel="stylesheet" type="text/css" 
         href="/tests/SimpleTest/test.css" />
 </head>
 
 <body onload="runTests()">
-  <p id="display"></p>
-
-  <embed id="plugin1" type="application/x-test" width="400" height="400"></embed>
   <script class="testbody" type="application/javascript">
     SimpleTest.waitForExplicitFinish();
+    setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
+
     function runTests() {
       var pluginElement = document.getElementById("plugin1");
       var c = 0;
       var foundSetColor = false;
       for (var n in pluginElement) {
         ++c;
         ok(n in pluginElement, "Enumerated property which doesn't exist?");
         if (n == 'setColor')
           foundSetColor = true;
       }
       ok(c > 0, "Should have enumerated some properties");
       ok(foundSetColor, "Should have enumerated .setColor");
       SimpleTest.finish();
     }
   </script>
+
+  <p id="display"></p>
+
+  <embed id="plugin1" type="application/x-test" width="400" height="400"></embed>
 </body>
 </html>
--- a/dom/plugins/test/mochitest/test_fullpage.html
+++ b/dom/plugins/test/mochitest/test_fullpage.html
@@ -1,21 +1,23 @@
 <head>
   <title>Full-page seekable stream</title>
 
   <script type="text/javascript"
           src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="utils.js"></script>
   <link rel="stylesheet" type="text/css"
         href="/tests/SimpleTest/test.css">
 
 <body>
   <p id="display"></p>
 
   <script type="application/javascript">
     SimpleTest.waitForExplicitFinish();
+    setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
     function frameLoaded() {
       var testframe = document.getElementById('testframe');
       var content = testframe.contentDocument.body.innerHTML;
       if (!content.length)
         return;
 
       var req = new XMLHttpRequest();
--- a/dom/plugins/test/mochitest/test_getauthenticationinfo.html
+++ b/dom/plugins/test/mochitest/test_getauthenticationinfo.html
@@ -1,13 +1,14 @@
 <!DOCTYPE HTML>
 <html>
 <head>
   <title>Test for Login Manager</title>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>  
+  <script type="text/javascript" src="utils.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 Test for NPN_GetAuthenticationInfo
 <p id="display"></p>
 
 <div id="content">
   <iframe id="iframe"></iframe>
@@ -53,16 +54,18 @@ function iframeLoad() {
   }
   catch (err) {
     ok(true, "expected exception caught");
   }
   SimpleTest.finish();
 }
 
 SimpleTest.waitForExplicitFinish();
+setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
+
 var iframe = document.getElementById("iframe");
 var am = Cc["@mozilla.org/network/http-auth-manager;1"].
          getService(Ci.nsIHttpAuthManager);
 am.setAuthIdentity("http", "mochi.test", 8888, "basic", "testrealm", "", 
     "mochi.test", "user1", "password1");
 iframe.onload = iframeLoad;
 iframe.src = "http://mochi.test:8888/tests/toolkit/components/passwordmgr/" +
     "test/authenticate.sjs?user=user1&pass=password1&realm=testrealm&plugin=1";
--- a/dom/plugins/test/mochitest/test_hang_submit.xul
+++ b/dom/plugins/test/mochitest/test_hang_submit.xul
@@ -5,16 +5,20 @@
 <window title="Basic Plugin Tests"
   xmlns:html="http://www.w3.org/1999/xhtml"
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <title>Plugin Hang Submission Test</title>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js" />
+  <script type="application/javascript" src="utils.js"></script>
+  <script type="application/javascript">
+    setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
+  </script>
 <body xmlns="http://www.w3.org/1999/xhtml" onload="runTests()">
 <embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
 </body>
 <script class="testbody" type="application/javascript">
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 SimpleTest.ignoreAllUncaughtExceptions();
 
--- a/dom/plugins/test/mochitest/test_hanging.html
+++ b/dom/plugins/test/mochitest/test_hanging.html
@@ -1,15 +1,17 @@
 <head>
   <title>Plugin hanging</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="utils.js"></script>
 
 <body>
   <script class="testbody" type="application/javascript">
   SimpleTest.waitForExplicitFinish();
+  setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
   window.frameLoaded = function frameLoaded_toCrash() {
     if (!SimpleTest.testPluginIsOOP()) {
       ok(true, "Skipping this test when test plugin is not OOP.");
       SimpleTest.finish();
       return;
     }
 
--- a/dom/plugins/test/mochitest/test_idle_hang.xul
+++ b/dom/plugins/test/mochitest/test_idle_hang.xul
@@ -5,16 +5,20 @@
 <window title="Basic Plugin Tests"
   xmlns:html="http://www.w3.org/1999/xhtml"
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <title>Plugin Idle Hang Test</title>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
   <script type="application/javascript"
           src="http://mochi.test:8888/chrome/dom/plugins/test/mochitest/hang_test.js" />
+  <script type="application/javascript" src="utils.js"></script>
+  <script type="application/javascript">
+    getTestPlugin().enabledState = Ci.nsIPluginTag.STATE_ENABLED;
+  </script>
 <body xmlns="http://www.w3.org/1999/xhtml" onload="runTests()">
 <embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
 </body>
 <script class="testbody" type="application/javascript">
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 function runTests() {
--- a/dom/plugins/test/mochitest/test_instance_re-parent.html
+++ b/dom/plugins/test/mochitest/test_instance_re-parent.html
@@ -1,36 +1,26 @@
 <!DOCTYPE html>
 <html>
 <head>
   <title>Test re-parentinging an instance's DOM node</title>
   <script type="text/javascript" src="/MochiKit/packed.js"></script>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+  <script type="text/javascript" src="utils.js"></script>
 </head>
 <body onload="begin()">
-  <p id="display"></p>
-
-  <div id="div1">
-    <!-- This embed has to have a "src" attribute. Part of this test involves seeing if we
-         properly restart plugins that have been added back to a document without a change
-         in URL. Not re-loading an object when the URL hasn't changed is a shortcut used for
-         some object types. Without a URL, this won't be tested. -->
-    <embed id="plugin1" src="loremipsum.txt" type="application/x-test" width="200" height="200"></embed>
-  </div>
-  <div id="div2">
-  </div>
-
   <script type="application/javascript;version=1.8">
   SimpleTest.waitForExplicitFinish();
+  getTestPlugin().enabledState = SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED;
 
   var exceptionThrown = false;
-  var p = document.getElementById('plugin1');
-  var d1 = document.getElementById('div1');
-  var d2 = document.getElementById('div2');
+  var p = null;
+  var d1 = null;
+  var d2 = null;
 
   var destroyed = false;
 
   function begin() {
     runTests(function() {
       // Callback when finished - set plugin to windowed and repeat the tests
 
       info("Repeating tests with wmode=window");
@@ -44,16 +34,20 @@
       exceptionThrown = false;
       runTests(function () {
         SimpleTest.finish();
       });
     });
   }
 
   function runTests(callback) {
+    p = document.getElementById('plugin1');
+    d1 = document.getElementById('div1');
+    d2 = document.getElementById('div2');
+
     // First tests involve moving the instance from one div to another.
     p.startWatchingInstanceCount();
     p.callOnDestroy(function() {
       destroyed = true;
     });
 
     try {
       d1.removeChild(p);
@@ -91,10 +85,22 @@
 
           p.stopWatchingInstanceCount();
           callback.apply(null);
         });
       });
     });
   }
   </script>
+
+  <p id="display"></p>
+
+  <div id="div1">
+    <!-- This embed has to have a "src" attribute. Part of this test involves seeing if we
+         properly restart plugins that have been added back to a document without a change
+         in URL. Not re-loading an object when the URL hasn't changed is a shortcut used for
+         some object types. Without a URL, this won't be tested. -->
+    <embed id="plugin1" src="loremipsum.txt" type="application/x-test" width="200" height="200"></embed>
+  </div>
+  <div id="div2">
+  </div>
 </body>
 </html>
--- a/dom/plugins/test/mochitest/test_instance_unparent1.html
+++ b/dom/plugins/test/mochitest/test_instance_unparent1.html
@@ -1,25 +1,21 @@
 <!DOCTYPE html>
 <html>
 <head>
   <title>Test removing an instance's DOM node</title>
   <script type="text/javascript" src="/MochiKit/packed.js"></script>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="utils.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body onload="startTest()">
-  <p id="display"></p>
-
-  <div id="div1">
-    <embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
-  </div>
-
   <script type="application/javascript;version=1.8">
   SimpleTest.waitForExplicitFinish();
+  setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
   var destroyed = false;
   function onDestroy() {
     destroyed = true;
   }
 
   function checkPluginAlreadyDestroyed() {
     is(destroyed, true, "Plugin instance should have been destroyed.");
@@ -32,10 +28,16 @@
 
     p1.callOnDestroy(onDestroy);
 
     setTimeout(checkPluginAlreadyDestroyed, 0);
 
     d1.removeChild(p1);
   }
   </script>
+
+  <p id="display"></p>
+
+  <div id="div1">
+    <embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
+  </div>
 </body>
 </html>
--- a/dom/plugins/test/mochitest/test_instance_unparent2.html
+++ b/dom/plugins/test/mochitest/test_instance_unparent2.html
@@ -1,31 +1,21 @@
 <!DOCTYPE html>
 <html>
 <head>
   <title>Test removing an instance's DOM node</title>
   <script type="text/javascript" src="/MochiKit/packed.js"></script>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="utils.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body onload="startTest()">
-  <p id="display"></p>
-
-  <div id="div1">
-    <embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
-  </div>
-
-  <div id="div2">
-    <div id="div3">
-        <embed id="plugin2" type="application/x-test" width="200" height="200"></embed>
-    </div>
-  </div>
-
   <script type="application/javascript;version=1.8">
   SimpleTest.waitForExplicitFinish();
+  setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
   var destroyed = false;
   function onDestroy() {
     destroyed = true;
   }
 
   function checkPluginAlreadyDestroyed() {
     is(destroyed, true, "Plugin instance should have been destroyed.");
@@ -41,10 +31,22 @@
     setTimeout(checkPluginAlreadyDestroyed, 0);
 
     // Get two parent check events to run.
     d1.removeChild(p1);
     d1.appendChild(p1);
     d1.removeChild(p1);
   }
   </script>
+
+  <p id="display"></p>
+
+  <div id="div1">
+    <embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
+  </div>
+
+  <div id="div2">
+    <div id="div3">
+        <embed id="plugin2" type="application/x-test" width="200" height="200"></embed>
+    </div>
+  </div>
 </body>
 </html>
--- a/dom/plugins/test/mochitest/test_instance_unparent3.html
+++ b/dom/plugins/test/mochitest/test_instance_unparent3.html
@@ -1,27 +1,21 @@
 <!DOCTYPE html>
 <html>
 <head>
   <title>Test removing an instance's DOM node</title>
   <script type="text/javascript" src="/MochiKit/packed.js"></script>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="utils.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body onload="startTest()">
-  <p id="display"></p>
-
-  <div id="div1">
-    <div id="div2">
-      <embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
-    </div<
-  </div>
-
   <script type="application/javascript;version=1.8">
   SimpleTest.waitForExplicitFinish();
+  setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
   var destroyed = false;
   function onDestroy() {
     destroyed = true;
   }
 
   function checkPluginAlreadyDestroyed() {
     is(destroyed, true, "Plugin instance should have been destroyed.");
@@ -35,10 +29,18 @@
 
     p1.callOnDestroy(onDestroy);
 
     setTimeout(checkPluginAlreadyDestroyed, 0);
 
     d1.removeChild(d2);
   }
   </script>
+
+  <p id="display"></p>
+
+  <div id="div1">
+    <div id="div2">
+      <embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
+    </div<
+  </div>
 </body>
 </html>
--- a/dom/plugins/test/mochitest/test_instantiation.html
+++ b/dom/plugins/test/mochitest/test_instantiation.html
@@ -1,17 +1,19 @@
 <head>
   <title>Plugin instantiation</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="utils.js"></script>
 
 <body onload="mainLoaded()">
   <iframe id="iframe1" src="about:blank" width="600" height="600"></iframe>
 
   <script class="testbody" type="application/javascript">
   SimpleTest.waitForExplicitFinish();
+  setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
   var iframe = document.getElementById('iframe1');
 
   function mainLoaded() {
     var p = iframe.contentDocument.createElement('embed');
     p.setAttribute('id', 'plugin1');
     p.setAttribute('type', 'application/x-test');
     p.setAttribute('width', '400');
--- a/dom/plugins/test/mochitest/test_multipleinstanceobjects.html
+++ b/dom/plugins/test/mochitest/test_multipleinstanceobjects.html
@@ -1,22 +1,24 @@
 <head>
   <title>NPNV*NPObject accessibility tests</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="utils.js"></script>
 
 <body onload="runTests()">
-  <embed id="plugin1" type="application/x-test" width="400" height="400"></embed>
-  <embed id="plugin2" type="application/x-test" width="400" height="400"></embed>
-
   <script class="testbody" type="application/javascript">
   SimpleTest.waitForExplicitFinish();
+  setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
   function runTests() {
     var p1 = document.getElementById('plugin1');
     var p2 = document.getElementById('plugin2');
 
     var o = p1.getObjectValue();
     ok(p1.checkObjectValue(o), "Plugin objects passed to the same instance are identical.");
     ok(!p2.checkObjectValue(o), "Plugin objects passed to another instance are double-wrapped.");
 
     SimpleTest.finish();
   }
   </script>
+
+  <embed id="plugin1" type="application/x-test" width="400" height="400"></embed>
+  <embed id="plugin2" type="application/x-test" width="400" height="400"></embed>
--- a/dom/plugins/test/mochitest/test_newstreamondestroy.html
+++ b/dom/plugins/test/mochitest/test_newstreamondestroy.html
@@ -1,22 +1,20 @@
 <head>
   <title>NPN_GetURL called from NPP_Destroy</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="utils.js"></script>
 
   <link rel="stylesheet" type="text/css"
 	href="/tests/SimpleTest/test.css">
 
 <body onload="runTest()">
-  <p id="display"></p>
-
-  <embed id="plugin1" type="application/x-test"></embed>
-
   <script class="testbody" type="application/javascript">
   SimpleTest.waitForExplicitFinish();
+  setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
   function runTest() {
     var p = document.getElementById('plugin1');
     var destroyed = false;
     p.callOnDestroy(function() {
       destroyed = true;
       ok(!p.streamTest('loremipsum.txt', false, null, null,
                        function(r, t) {
@@ -26,8 +24,12 @@
     document.body.removeChild(p);
 
     setTimeout(function() {
       ok(destroyed, "callback was fired as expected");
       SimpleTest.finish();
     }, 1000);
   }
   </script>
+
+  <p id="display"></p>
+
+  <embed id="plugin1" type="application/x-test"></embed>
--- a/dom/plugins/test/mochitest/test_npn_asynccall.html
+++ b/dom/plugins/test/mochitest/test_npn_asynccall.html
@@ -1,31 +1,33 @@
 <html>
 <head>
   <title>NPN_AsyncCallback Tests</title>
   <script type="text/javascript" 
           src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="utils.js"></script>
   <link rel="stylesheet" type="text/css" 
         href="/tests/SimpleTest/test.css" />
 </head>
 <body onload="runTests()">
-  <p id="display"></p>
-
-  <embed id="plugin1" type="application/x-test" width="400" height="100">
-  </embed>
-
   <script class="testbody" type="application/javascript">
   
   SimpleTest.waitForExplicitFinish();
-  
+  setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
+
   function asyncTestsComplete(result) {
     ok(result, "asyncCallback tests completed");
     SimpleTest.finish();
   }
   
   function runTests() {
     var plugin = document.getElementById("plugin1");
     plugin.asyncCallbackTest("asyncTestsComplete");
   }
   </script>
-  
+
+  <p id="display"></p>
+
+  <embed id="plugin1" type="application/x-test" width="400" height="100">
+  </embed>
+
  </body>
  </html>
--- a/dom/plugins/test/mochitest/test_npn_timers.html
+++ b/dom/plugins/test/mochitest/test_npn_timers.html
@@ -1,31 +1,33 @@
 <html>
 <head>
   <title>NPN_Timer Tests</title>
   <script type="text/javascript" 
           src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="utils.js"></script>
   <link rel="stylesheet" type="text/css" 
         href="/tests/SimpleTest/test.css" />
 </head>
 <body onload="runTests()">
-  <p id="display"></p>
-
-  <embed id="plugin1" type="application/x-test" width="400" height="100">
-  </embed>
-
   <script class="testbody" type="application/javascript">
   
   SimpleTest.waitForExplicitFinish();
-  
+  setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
+
   function pluginTimerTestFinish(result) {
     ok(result, "timer tests completed");
     SimpleTest.finish();
   }
   
   function runTests() {
     var plugin = document.getElementById("plugin1");
     plugin.timerTest("pluginTimerTestFinish");
   }
   </script>
-  
+
+  <p id="display"></p>
+
+  <embed id="plugin1" type="application/x-test" width="400" height="100">
+  </embed>
+
  </body>
  </html>
--- a/dom/plugins/test/mochitest/test_npobject_getters.html
+++ b/dom/plugins/test/mochitest/test_npobject_getters.html
@@ -1,19 +1,21 @@
 <head>
   <title>NPNV*NPObject accessibility tests</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="utils.js"></script>
 
 <body onload="runTests()">
-  <embed id="plugin1" type="application/x-test" width="400" height="400"></embed>
-
   <script class="testbody" type="application/javascript">
   dump('lastScript');
 
   SimpleTest.waitForExplicitFinish();
+  setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
   function runTests() {
     ok(document.getElementById('plugin1').pluginFoundElement, "plugin1.pluginFoundElement (NPNVPluginElementNPObject)", document.getElementById('plugin1').pluginFoundElement);
     ok(window.pluginFoundWindow, "window.pluginFoundWindow (NPNVWindowNPObject)", window.pluginFoundWindow);
 
     SimpleTest.finish();
   }
   </script>
+
+  <embed id="plugin1" type="application/x-test" width="400" height="400"></embed>
--- a/dom/plugins/test/mochitest/test_npruntime.xul
+++ b/dom/plugins/test/mochitest/test_npruntime.xul
@@ -3,16 +3,20 @@
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 <window title="Basic Plugin Tests"
   xmlns:html="http://www.w3.org/1999/xhtml"
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <title>Basic Plugin Tests</title>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
+  <script type="application/javascript" src="utils.js"></script>
+  <script type="application/javascript">
+    setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
+  </script>
 <body xmlns="http://www.w3.org/1999/xhtml" onload="runTests()">
 <embed id="plugin1" type="application/x-test" width="400" height="400"></embed>
 </body>
 <script class="testbody" type="application/javascript">
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 function runTests() {
--- a/dom/plugins/test/mochitest/test_npruntime_construct.html
+++ b/dom/plugins/test/mochitest/test_npruntime_construct.html
@@ -1,16 +1,21 @@
 <!DOCTYPE html>
 <html>
 <head>
   <title>Test whether windowless plugins receive correct visible/invisible notifications.</title>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="utils.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 
 <body>
+  <script type="text/javascript">
+    setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
+  </script>
+
   <p id="display"></p>
 
   <embed id="theplugin" type="application/x-test"></embed>
 
   <script type="application/javascript">
     function MyFunc(arg) {
       is(arg, "hi", "Argument passed to constructor function");
       this.localProp = 'local';
--- a/dom/plugins/test/mochitest/test_npruntime_identifiers.html
+++ b/dom/plugins/test/mochitest/test_npruntime_identifiers.html
@@ -1,25 +1,27 @@
 <html>
 <head>
   <title>NPN_Invoke Tests</title>
   <script type="text/javascript" 
           src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="utils.js"></script>
   <link rel="stylesheet" type="text/css" 
         href="/tests/SimpleTest/test.css" />
 </head>
 <body>
   <p id="display"></p>
 
   <script class="testbody" type="application/javascript">
   ////
   // This test exercises NP identifiers by querying the reflector to make sure
   // that identifiers are translated to values correctly.
   
   SimpleTest.waitForExplicitFinish();
+  setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
   var testsRun = 0;
 
   function doTest() {
     SpecialPowers.gc();
 
     var reflector = document.getElementById("subframe").contentDocument.getElementById("plugin1").getReflector();
 
--- a/dom/plugins/test/mochitest/test_npruntime_npnevaluate.html
+++ b/dom/plugins/test/mochitest/test_npruntime_npnevaluate.html
@@ -1,25 +1,22 @@
 <html>
 <head>
   <title>NPN_Evaluate Tests</title>
   <script type="text/javascript" 
           src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="utils.js"></script>
   <link rel="stylesheet" type="text/css" 
         href="/tests/SimpleTest/test.css" />
 </head>
 <body onload="runTests()">
-  <p id="display"></p>
-
-  <embed id="plugin1" type="application/x-test" width="400" height="100">
-  </embed>
-
   <script class="testbody" type="application/javascript">
   
   SimpleTest.waitForExplicitFinish();
+  setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
   
   // global test function
   function testMe(arg) {
     var result = arg+arg;
     for (var i = 1; i < arguments.length; i++) {
       result += arguments[i] + arguments[i];
     }
     return result;
@@ -28,35 +25,36 @@
   ////
   // This test exercises NPN_Evaluate using the test plugin's
   // npnEvaluateTest method.  This method calls NPN_Evaluate on 
   // a string argument passed to it, and returns the eval result.
   // The array below drives the tests; each array member has two
   // members:  the first is a string to eval, and the second is 
   // the expected result of the eval.
   //
-  var tests = [
-    ["3", 3],
-    ["3 + 3", 6],
-    ["'3'", "3"],
-    ["function test() { return 3; } test();", 3],
-    ["testMe(3)", 6],
-    ["testMe(new Object(3))", 6],
-    ["new Object(3)", new Object(3)],
-    ["new Array(1, 2, 3, 4)", [1, 2, 3, 4]],
-    ["document.getElementById('display')", 
-        document.getElementById("display")],
-    ["encodeURI('a = b')", "a%20=%20b"],
-    ["document.getElementById('testdiv').innerHTML = 'Hello world!'", 
-        "Hello world!"],
-    ["function test2() { var x = {a: '1', b: '2'}; return x; } test2();", 
-        {a: '1', b: '2'}],
-  ];
- 
+
   function runTests() {
+    var tests = [
+      ["3", 3],
+      ["3 + 3", 6],
+      ["'3'", "3"],
+      ["function test() { return 3; } test();", 3],
+      ["testMe(3)", 6],
+      ["testMe(new Object(3))", 6],
+      ["new Object(3)", new Object(3)],
+      ["new Array(1, 2, 3, 4)", [1, 2, 3, 4]],
+      ["document.getElementById('display')", 
+          document.getElementById("display")],
+      ["encodeURI('a = b')", "a%20=%20b"],
+      ["document.getElementById('testdiv').innerHTML = 'Hello world!'", 
+          "Hello world!"],
+      ["function test2() { var x = {a: '1', b: '2'}; return x; } test2();", 
+          {a: '1', b: '2'}],
+    ];
+
     var plugin = document.getElementById("plugin1");
 
     // Test calling NPN_Evaluate from within plugin code.
     for (var test of tests) {
       var expected = test[1];
       var result = plugin.npnEvaluateTest(test[0]);
       // serialize the two values for easy comparison
       var json_expected = JSON.stringify(expected);
@@ -83,15 +81,20 @@
     }
     
     is(document.getElementById('testdiv').innerHTML, "Hello world!",
       "innerHTML not set correctly via NPN_Evaluate");
     
     SimpleTest.finish();
   }
   </script>
-  
+
+  <p id="display"></p>
+
+  <embed id="plugin1" type="application/x-test" width="400" height="100">
+  </embed>
+
   <div id="verbose">
   </div>
   <div id="testdiv">
   </div>
  </body>
  </html>
--- a/dom/plugins/test/mochitest/test_npruntime_npninvoke.html
+++ b/dom/plugins/test/mochitest/test_npruntime_npninvoke.html
@@ -1,32 +1,30 @@
 <html>
 <head>
   <title>NPN_Invoke Tests</title>
   <script type="text/javascript" 
           src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="utils.js"></script>
   <link rel="stylesheet" type="text/css" 
         href="/tests/SimpleTest/test.css" />
 </head>
 <body onload="runTests()">
-  <p id="display"></p>
-
-  <embed id="plugin1" type="application/x-test" width="400" height="100">
-  </embed>
 
   <script class="testbody" type="application/javascript">
   ////
   // This test exercises NPN_Invoke by calling the plugin's npnInvokeTest
   // method, which in turn invokes a script method with 1 or more parameters, 
   // and then compares the return vale with an expected value.  This is good
   // for verifying various NPVariant values and types moving between
   // the browser and the plugin.
   //
   
   SimpleTest.waitForExplicitFinish();
+  setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
   // This function returns all the arguments passed to it, either as a
   // single variable (in the caes of 1 argument), or as an array.
   function returnArgs() {
     if (arguments.length == 1)
       return arguments[0];
     var arr = new Array();
     for (i = 0; i < arguments.length; i++) {
@@ -147,13 +145,18 @@
       if (result != test[1])
         $("verbose").appendChild(createEl("span", null, (" " + plugin.getError())));
       $("verbose").appendChild(createEl('br'));
     }
             
     SimpleTest.finish();
   }
   </script>
-  
+
+  <p id="display"></p>
+
+  <embed id="plugin1" type="application/x-test" width="400" height="100">
+  </embed>
+
   <div id="verbose">
   </div>
  </body>
  </html>
--- a/dom/plugins/test/mochitest/test_npruntime_npninvokedefault.html
+++ b/dom/plugins/test/mochitest/test_npruntime_npninvokedefault.html
@@ -1,26 +1,23 @@
 <html>
 <head>
   <title>NPN_Invoke_Default Tests</title>
   <script type="text/javascript" 
           src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="utils.js"></script>
   <link rel="stylesheet" type="text/css" 
         href="/tests/SimpleTest/test.css" />
 </head>
 <body onload="runTests()">
-  <p id="display"></p>
-
-  <embed id="plugin1" type="application/x-test" width="400" height="100">
-  </embed>
-
   <script class="testbody" type="application/javascript">
   
   SimpleTest.waitForExplicitFinish();
-  
+  setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
+
   // global test function
   function testMe(arg) {
     var result = arg+arg;
     for (var i = 1; i < arguments.length; i++) {
       result += arguments[i] + arguments[i];
     }
     return result;
   }
@@ -139,13 +136,18 @@
     is(plugin("test"), "Test Plug-in;test", 
         "calling NPN_InvokeDefault on plugin-defined Object doesn't work");
     is(plugin(undefined, -1, null), "Test Plug-in;undefined;-1;null", 
         "calling NPN_InvokeDefault on plugin-defined Object doesn't work");
   
     SimpleTest.finish();
   }
   </script>
-  
+
+  <p id="display"></p>
+
+  <embed id="plugin1" type="application/x-test" width="400" height="100">
+  </embed>
+
   <div id="verbose">
   </div>
  </body>
  </html>
--- a/dom/plugins/test/mochitest/test_npruntime_npnsetexception.html
+++ b/dom/plugins/test/mochitest/test_npruntime_npnsetexception.html
@@ -1,24 +1,21 @@
 <html>
 <head>
   <title>NPN_SetException Tests</title>
   <script type="text/javascript" 
           src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="utils.js"></script>
   <link rel="stylesheet" type="text/css" 
         href="/tests/SimpleTest/test.css" />
 </head>
 <body onload="runTests()">
-  <p id="display"></p>
-
-  <embed id="plugin1" type="application/x-test" width="400" height="100">
-  </embed>
-
   <script class="testbody" type="application/javascript">
   SimpleTest.waitForExplicitFinish();
+  setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
   function runTests() {
     // test a single exception thrown in scriptable invoke
     var plugin = document.getElementById("plugin1");
     plugin.throwExceptionNextInvoke();
     try {
       plugin.npnInvokeTest("badFunction");
       ok(false, "exception not thrown");
@@ -45,13 +42,18 @@
     }
     catch (e) {
       is(e.message, "Error calling method on NPObject!", "wrong exception thrown");
     }    
 
     SimpleTest.finish();
   }
   </script>
-  
+
+  <p id="display"></p>
+
+  <embed id="plugin1" type="application/x-test" width="400" height="100">
+  </embed>
+
   <div id="verbose">
   </div>
  </body>
  </html>
--- a/dom/plugins/test/mochitest/test_painting.html
+++ b/dom/plugins/test/mochitest/test_painting.html
@@ -32,33 +32,21 @@
       left: -5.3px;
       top: -4.7px;
       width: 20px;
       height: 20px;
     }
   </style>
 </head>
 <body onload="initialize()">
-<p id="display"></p>
-<div id="container">
-  <embed id="paint-waiter" type="application/x-test"/>
-  <div id="clip">
-    <embed id="clipped" type="application/x-test"
-           drawmode="solid" color="FF808080"/>
-  </div>
-</div>
-<div id="content" style="display: none">
-
-</div>
-<pre id="test">
-</pre>
 
 <script type="application/javascript" src="utils.js"></script>
 <script type="application/javascript">
 SimpleTest.waitForExplicitFinish();
+setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
 var paint_waiter;
 var clip;
 var clipped;
 
 function initialize() {
   paint_waiter = document.getElementById("paint-waiter");
   clip = document.getElementById("clip");
@@ -108,10 +96,25 @@ function waitForPaintHelper(func) {
     paint_waiter.style.height = "0px";
     setTimeout(func, 0);
     return;
   }
   setTimeout(function() { waitForPaintHelper(func); }, 100);
 }
 
 </script>
+
+<p id="display"></p>
+<div id="container">
+  <embed id="paint-waiter" type="application/x-test"/>
+  <div id="clip">
+    <embed id="clipped" type="application/x-test"
+           drawmode="solid" color="FF808080"/>
+  </div>
+</div>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+</pre>
+
 </body>
 </html>
--- a/dom/plugins/test/mochitest/test_plugin_scroll_painting.html
+++ b/dom/plugins/test/mochitest/test_plugin_scroll_painting.html
@@ -1,13 +1,17 @@
 <!DOCTYPE HTML>
 <html>
 <head>
   <title>Test that scrolling a windowless plugin doesn't force us to repaint it</title>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="utils.js"></script>
+  <script type="text/javascript">
+    setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
+  </script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body onload="runTest()">
 <p id="display"></p>
   <embed id="plugin" type="application/x-test" style="width:50px; height:10px; margin-top:20px;"></embed>
 </div>
 <div id="content" style="display: none">
 
--- a/dom/plugins/test/mochitest/test_plugin_tag_clicktoplay.html
+++ b/dom/plugins/test/mochitest/test_plugin_tag_clicktoplay.html
@@ -1,36 +1,36 @@
 <!DOCTYPE html>
 <html>
   <head>
     <meta><charset="utf-8"/>
     <title>Test Modifying Plugin click-to-play Flag</title>
     <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
     <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/ChromeUtils.js"></script>
+    <script type="application/javascript" src="utils.js"></script>
   </head>
   <body>
     <script class="testbody" type="application/javascript">
       Components.utils.import("resource://gre/modules/Services.jsm");
+      Services.prefs.setBoolPref("plugins.click_to_play", true);
       var pluginHost = Components.classes["@mozilla.org/plugin/host;1"]
                        .getService(Components.interfaces.nsIPluginHost);
-      is(pluginHost.getStateForType("application/x-test"), Components.interfaces.nsIPluginTag.STATE_ENABLED, "click-to-play should be off to begin with");
-      Services.prefs.setBoolPref("plugins.click_to_play", true);
 
-      var pluginTags = pluginHost.getPluginTags();
-      var testPlugin = null;
-      for (var plugin of pluginTags) {
-        if (plugin.name == "Test Plug-in") {
-          testPlugin = plugin;
-          break;
-        }
-      }
+      var testPlugin = getTestPlugin();
+      var secondTestPlugin = getTestPlugin("Second Test Plug-in");
       ok(testPlugin, "Should have Test Plug-in");
-      testPlugin.enabledState = Components.interfaces.nsIPluginTag.STATE_CLICKTOPLAY;
-      is(pluginHost.getStateForType("application/x-test"), Components.interfaces.nsIPluginTag.STATE_CLICKTOPLAY, "click-to-play should be on for Test Plug-in now");
-      is(pluginHost.getStateForType("application/x-second-test"), Components.interfaces.nsIPluginTag.STATE_ENABLED, "click-to-play should still be off for the Second Test Plug-in");
+      ok(secondTestPlugin, "Should have Second Test Plug-in");
+
+      // make sure both start off as click-to-play
+      setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_CLICKTOPLAY);
+      setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Second Test Plug-in");
 
       testPlugin.enabledState = Components.interfaces.nsIPluginTag.STATE_ENABLED;
       is(pluginHost.getStateForType("application/x-test"), Components.interfaces.nsIPluginTag.STATE_ENABLED, "click-to-play should be off for Test Plug-in now");
+      is(pluginHost.getStateForType("application/x-second-test"), Components.interfaces.nsIPluginTag.STATE_CLICKTOPLAY, "click-to-play should still be on for the Second Test Plug-in");
+
+      testPlugin.enabledState = Components.interfaces.nsIPluginTag.STATE_CLICKTOPLAY;
+      is(pluginHost.getStateForType("application/x-test"), Components.interfaces.nsIPluginTag.STATE_CLICKTOPLAY, "click-to-play should be on for Test Plug-in now");
 
       Services.prefs.clearUserPref("plugins.click_to_play");
     </script>
   </body>
 </html>
--- a/dom/plugins/test/mochitest/test_pluginstream_asfile.html
+++ b/dom/plugins/test/mochitest/test_pluginstream_asfile.html
@@ -1,15 +1,19 @@
 <html>
 <head>
   <title>NPAPI NP_ASFILE NPStream Test</title>
   <script type="text/javascript" 
           src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="text/javascript" 
           src="pluginstream.js"></script>
+  <script type="text/javascript" src="utils.js"></script>
+  <script type="text/javascript">
+    setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
+  </script>
   <link rel="stylesheet" type="text/css" 
         href="/tests/SimpleTest/test.css" />
 </head>
 <body>
   <p id="display"></p>
 
   <iframe id="testframe" name="testframe" onload="frameLoaded()"></iframe>
 
--- a/dom/plugins/test/mochitest/test_pluginstream_asfileonly.html
+++ b/dom/plugins/test/mochitest/test_pluginstream_asfileonly.html
@@ -1,15 +1,19 @@
 <html>
 <head>
   <title>NPAPI NP_ASFILEONLY NPStream Test</title>
   <script type="text/javascript" 
           src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="text/javascript" 
           src="pluginstream.js"></script>
+  <script type="text/javascript" src="utils.js"></script>
+  <script type="text/javascript">
+    setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
+  </script>
   <link rel="stylesheet" type="text/css" 
         href="/tests/SimpleTest/test.css" />
 </head>
 <body>
   <p id="display"></p>
 
   <iframe id="testframe" name="testframe" onload="frameLoaded()"></iframe>
 
--- a/dom/plugins/test/mochitest/test_pluginstream_err.html
+++ b/dom/plugins/test/mochitest/test_pluginstream_err.html
@@ -4,16 +4,17 @@
 https://bugzilla.mozilla.org/show_bug.cgi?id=517078
 
 Tests for plugin stream error conditions.
 -->
 <head>
   <title>NPAPI Stream Error Tests</title>
   <script type="text/javascript" 
           src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="utils.js"></script>
   <link rel="stylesheet" type="text/css" 
         href="/tests/SimpleTest/test.css" />
 </head>
 <body onload="runNextTest()">
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=517078">
   Mozilla Bug 517078</a> - Plugin Stream Error Tests
 <p id="display"></p>
 <div id="content" style="display: none">
@@ -27,16 +28,17 @@ Tests for plugin stream error conditions
 // as the plugin being terminated, or NPP_ stream functions being
 // called inappropriately by the browser after the plugin has returned
 // a stream error.
 //
 
 function $(id) { return document.getElementById(id); }
 
 SimpleTest.waitForExplicitFinish();
+setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
 
 var tests = [
   {
     "src": "loremipsum.txt",
     "streammode": "normal",
     "functiontofail": "npp_newstream",
     "failurecode": "1",
--- a/dom/plugins/test/mochitest/test_pluginstream_geturl.html
+++ b/dom/plugins/test/mochitest/test_pluginstream_geturl.html
@@ -1,15 +1,19 @@
 <html>
 <head>
   <title>NPAPI NPN_GetURL NPStream Test</title>
   <script type="text/javascript" 
           src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="text/javascript" 
           src="pluginstream.js"></script>
+  <script type="text/javascript" src="utils.js"></script>
+  <script type="text/javascript">
+    setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
+  </script>
   <link rel="stylesheet" type="text/css" 
         href="/tests/SimpleTest/test.css" />
 </head>
 <body>
   <p id="display"></p>
 
   <iframe id="testframe" name="testframe" onload="frameLoaded()"></iframe>
 
--- a/dom/plugins/test/mochitest/test_pluginstream_geturlnotify.html
+++ b/dom/plugins/test/mochitest/test_pluginstream_geturlnotify.html
@@ -1,15 +1,19 @@
 <body>
 <head>
   <title>NPAPI NPN_GetURLNotify Test</title>
   <script type="text/javascript" 
           src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="text/javascript" 
           src="pluginstream.js"></script>
+  <script type="text/javascript" src="utils.js"></script>
+  <script type="text/javascript">
+    setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
+  </script>
   <link rel="stylesheet" type="text/css" 
         href="/tests/SimpleTest/test.css" />
 </head>
 <body>
   <p id="display"></p>
 
   <iframe id="testframe" name="testframe" onload="frameLoaded()"></iframe>
 
--- a/dom/plugins/test/mochitest/test_pluginstream_newstream.html
+++ b/dom/plugins/test/mochitest/test_pluginstream_newstream.html
@@ -1,15 +1,19 @@
 <html>
 <head>
   <title>NPAPI NPN_NewStream NPStream Test</title>
   <script type="text/javascript" 
           src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="text/javascript" 
           src="pluginstream.js"></script>
+  <script type="text/javascript" src="utils.js"></script>
+  <script type="text/javascript">
+    setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
+  </script>
   <link rel="stylesheet" type="text/css" 
         href="/tests/SimpleTest/test.css" />
 </head>
 <body>
   <p id="display"></p>
 
   <iframe id="testframe" name="testframe" onload="frameLoaded()"></iframe>
 
--- a/dom/plugins/test/mochitest/test_pluginstream_post.html
+++ b/dom/plugins/test/mochitest/test_pluginstream_post.html
@@ -1,15 +1,19 @@
 <html>
 <head>
   <title>NPAPI NPN_PostURL NPStream Test</title>
   <script type="text/javascript" 
           src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="text/javascript" 
           src="pluginstream.js"></script>
+  <script type="text/javascript" src="utils.js"></script>
+  <script type="text/javascript">
+    setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
+  </script>
   <link rel="stylesheet" type="text/css" 
         href="/tests/SimpleTest/test.css" />
 </head>
 <body>
   <p id="display"></p>
 
   <iframe id="testframe" name="testframe" onload="frameLoaded()"></iframe>
 
--- a/dom/plugins/test/mochitest/test_pluginstream_poststream.html
+++ b/dom/plugins/test/mochitest/test_pluginstream_poststream.html
@@ -1,15 +1,19 @@
 <html>
 <head>
   <title>NPAPI NPN_PostURL NPStream Test</title>
   <script type="text/javascript" 
           src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="text/javascript" 
           src="pluginstream.js"></script>
+  <script type="text/javascript" src="utils.js"></script>
+  <script type="text/javascript">
+    setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
+  </script>
   <link rel="stylesheet" type="text/css" 
         href="/tests/SimpleTest/test.css" />
 </head>
 <body>
   <p id="display"></p>
 
   <iframe id="testframe" name="testframe" onload="frameLoaded()"></iframe>
 
--- a/dom/plugins/test/mochitest/test_pluginstream_referer.html
+++ b/dom/plugins/test/mochitest/test_pluginstream_referer.html
@@ -1,23 +1,20 @@
 <head>
   <title>Do plugin stream requests send the Referer header correctly?</title>
   <script type="application/javascript"
 	  src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="utils.js"></script>
   <link rel="stylesheet" type="text/css" 
         href="/tests/SimpleTest/test.css" />
 
 <body onload="runTests()">
-  <p id="display"></p>
-
-  <embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
-  <embed id="plugin2" type="application/x-test" src="loremipsum.xtest" width="200" height="200"></embed>
-
   <script class="testbody" type="application/javascript">
   SimpleTest.waitForExplicitFinish();
+  setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
   var pending = 3;
   function testDone() {
     --pending;
     if (0 == pending)
       SimpleTest.finish()
   }
 
@@ -47,8 +44,12 @@
                        is(t, "Referer found: " + expectedreferer,
                           "GET Referer correct with plugin src");
                        testDone();
                      }, null, true), "referer GET (2)");
                             
   }
   </script>
 
+  <p id="display"></p>
+
+  <embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
+  <embed id="plugin2" type="application/x-test" src="loremipsum.xtest" width="200" height="200"></embed>
--- a/dom/plugins/test/mochitest/test_pluginstream_seek.html
+++ b/dom/plugins/test/mochitest/test_pluginstream_seek.html
@@ -1,15 +1,19 @@
 <body>
 <head>
   <title>NPAPI Seekable NPStream Test</title>
   <script type="text/javascript" 
           src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="text/javascript" 
           src="pluginstream.js"></script>
+  <script type="text/javascript" src="utils.js"></script>
+  <script type="text/javascript">
+    setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
+  </script>
   <link rel="stylesheet" type="text/css" 
         href="/tests/SimpleTest/test.css" />
 </head>
 <body>
   <p id="display"></p>
 
   <iframe id="testframe" name="testframe" onload="frameLoaded()"></iframe>
 
--- a/dom/plugins/test/mochitest/test_pluginstream_seek_close.html
+++ b/dom/plugins/test/mochitest/test_pluginstream_seek_close.html
@@ -1,19 +1,21 @@
 <body>
 <head>
   <title>NPAPI Seekable NPStream Test</title>
   <script type="text/javascript" 
           src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="utils.js"></script>
   <link rel="stylesheet" type="text/css" 
         href="/tests/SimpleTest/test.css" />
 <script>
   SimpleTest.expectAssertions(0, 1);
 
   SimpleTest.waitForExplicitFinish();
+  setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
   function frameLoaded() {
     var testframe = document.getElementById('testframe');
     var content = testframe.contentDocument.body.innerHTML;
     if (!content.length)
       return;
 
     ok(true, "We didn't crash");
--- a/dom/plugins/test/mochitest/test_pluginstream_src.html
+++ b/dom/plugins/test/mochitest/test_pluginstream_src.html
@@ -1,15 +1,19 @@
 <html>
 <head>
   <title>NPAPI src="" NPStream Test</title>
   <script type="text/javascript" 
           src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="text/javascript" 
           src="pluginstream.js"></script>
+  <script type="text/javascript" src="utils.js"></script>
+  <script type="text/javascript">
+    setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
+  </script>
   <link rel="stylesheet" type="text/css" 
         href="/tests/SimpleTest/test.css" />
 </head>
 <body>
   <p id="display"></p>
 
   <iframe id="testframe" name="testframe" onload="frameLoaded()"></iframe>
 
--- a/dom/plugins/test/mochitest/test_pluginstream_src_dynamic.html
+++ b/dom/plugins/test/mochitest/test_pluginstream_src_dynamic.html
@@ -1,15 +1,19 @@
 <html>
 <head>
   <title>NPAPI src="" NPStream Test</title>
   <script type="text/javascript" 
           src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="text/javascript" 
           src="pluginstream.js"></script>
+  <script type="text/javascript" src="utils.js"></script>
+  <script type="text/javascript">
+    setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
+  </script>
   <link rel="stylesheet" type="text/css" 
         href="/tests/SimpleTest/test.css" />
 </head>
 <body>
   <p id="display"></p>
 
   <iframe id="testframe" name="testframe" onload="frameLoaded()"></iframe>
 
--- a/dom/plugins/test/mochitest/test_pluginstream_src_referer.html
+++ b/dom/plugins/test/mochitest/test_pluginstream_src_referer.html
@@ -1,20 +1,22 @@
 <head>
   <title>Do plugin stream src requests send the Referer header correctly?</title>
   <script type="application/javascript"
 	  src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="utils.js"></script>
   <link rel="stylesheet" type="text/css" 
         href="/tests/SimpleTest/test.css" />
 
 <body>
   <p id="display"></p>
 
   <script class="testbody" type="application/javascript">
   SimpleTest.waitForExplicitFinish();
+  setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
   function frameLoaded() {
     var testframe = document.getElementById('pluginframe');
     var content = testframe.contentDocument.body.innerHTML;
     if (!content.length)
       return;
 
     is(content, "Referer found: " + window.location);
--- a/dom/plugins/test/mochitest/test_positioning.html
+++ b/dom/plugins/test/mochitest/test_positioning.html
@@ -1,32 +1,34 @@
 <!DOCTYPE html>
 <html>
 <head>
   <title>Test whether windowless plugins receive correct visible/invisible notifications.</title>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="utils.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 
   <style type="text/css">
   body {
     height: 10000px;
   }
   </style>
 
 <body onload="startTest()">
   <p id="display"></p>
 
-  <embed id="theplugin" type="application/x-test" width="200" height="200"></embed>
-
   <script type="application/javascript;version=1.8">
   SimpleTest.waitForExplicitFinish();
+  setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
-  var p = document.getElementById('theplugin');
+  var p = null;
 
   function startTest() {
+    p = document.getElementById('theplugin');
+
     // Wait for the plugin to have painted once
     var interval = setInterval(function() {
       if (!p.getPaintCount())
         return;
 
       clearInterval(interval);
       doScroll();
     }, 100);
@@ -45,8 +47,10 @@
 
   function checkScroll() {
     let [x, y, w, h] = p.getWindowPosition();
 
     is(y, startY - kScrollAmount, "Window should be informed of its new position.");
     SimpleTest.finish();
   }
   </script>
+
+  <embed id="theplugin" type="application/x-test" width="200" height="200"></embed>
--- a/dom/plugins/test/mochitest/test_privatemode_perwindowpb.xul
+++ b/dom/plugins/test/mochitest/test_privatemode_perwindowpb.xul
@@ -5,16 +5,20 @@
 <window title="NPAPI Private Mode Tests"
   xmlns:html="http://www.w3.org/1999/xhtml"
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <title>NPAPI Private Mode Tests</title>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/chrome-harness.js" />
+  <script type="application/javascript" src="utils.js"></script>
+  <script type="application/javascript">
+    setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
+  </script>
 <body xmlns="http://www.w3.org/1999/xhtml" onload="runTests()">
 <embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
 <embed id="plugin2" type="application/x-test" width="200" height="200"></embed>
 </body>
 <script class="testbody" type="application/javascript">
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
--- a/dom/plugins/test/mochitest/test_propertyAndMethod.html
+++ b/dom/plugins/test/mochitest/test_propertyAndMethod.html
@@ -1,35 +1,35 @@
 <html>
   <head>
     <title>NPObject with property and method with the same name</title>
 
     <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+    <script type="text/javascript" src="utils.js"></script>
     <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
   </head>
 
   <body onload="run()">
 
-    <embed id="plugin" type="application/x-test" wmode="window"></embed>
-
     <script class="testbody" type="application/javascript">
       if (typeof Object.getPrototypeOf !== "function") {
         if (typeof "test".__proto__ === "object") {
           Object.getPrototypeOf = function(object) {
             return object.__proto__;
           };
         } else {
           Object.getPrototypeOf = function(object) {
             // May break if the constructor has been tampered with
             return object.constructor.prototype;
           };
         }
       }
 
       SimpleTest.waitForExplicitFinish();
+      setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
       function run() {
         var plugin = document.getElementById("plugin");
         var pluginProto = Object.getPrototypeOf(plugin);
 
         delete pluginProto.propertyAndMethod;
         ok(isNaN(plugin.propertyAndMethod + 0), "Shouldn't be set yet!");
 
@@ -40,10 +40,12 @@
         ok(isNaN(plugin.propertyAndMethod + 0), "Shouldn't be set any more!");
 
         var res = plugin.propertyAndMethod();
         is(res, 5, "Method invocation should return 5!");
 
         SimpleTest.finish();
       }
     </script>
+
+    <embed id="plugin" type="application/x-test" wmode="window"></embed>
   </body>
 </html>
--- a/dom/plugins/test/mochitest/test_queryContentsScaleFactor.html
+++ b/dom/plugins/test/mochitest/test_queryContentsScaleFactor.html
@@ -1,26 +1,30 @@
 <html>
 <head>
   <title>NPAPI NPNVcontentsScaleFactor Test</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="utils.js"></script>
 </head>
 
 <body onload="runTests()">
-  <embed id="plugin" type="application/x-test" width="400" height="400"></embed>
   <script class="testbody" type="application/javascript">
     SimpleTest.waitForExplicitFinish();
+    setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
+
     function runTests() {
       var pluginElement = document.getElementById("plugin");
       var contentsScaleFactor;
       var exceptionThrown = false;
       try {
         contentsScaleFactor = pluginElement.queryContentsScaleFactor();
       } catch (e) {
         exceptionThrown = true;
       }
       is(exceptionThrown, false, "Exception thrown getting contents scale factor.");
       is(isNaN(contentsScaleFactor), false, "Invalid return getting contents scale factor");
       SimpleTest.finish();
     }
   </script>
+
+  <embed id="plugin" type="application/x-test" width="400" height="400"></embed>
 </body>
 </html>
--- a/dom/plugins/test/mochitest/test_redirect_handling.html
+++ b/dom/plugins/test/mochitest/test_redirect_handling.html
@@ -1,20 +1,20 @@
 <html>
 <head>
   <title>Basic NPAPI Redirect Handling</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="utils.js"></script>
 </head>
-<body onload="runNextTest()">
-  <embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
-
+<body onload="runTests()">
   <script class="testbody" type="application/javascript">
     SimpleTest.waitForExplicitFinish();
+    setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
-    var p = document.getElementById("plugin1");
+    var p = null;
 
     var redirectingURL = "307-xo-redirect.sjs";
     var redirectTargetURL = "http://example.org/tests/dom/plugins/test/mochitest/loremipsum.txt";
 
     var expectedWriteURL = "";
     var expectedNotifyStatus = -1;
 
     function redirectCallback(url, httpStatus) {
@@ -50,11 +50,18 @@
     function runNextTest() {
       currentTest++;
       if (currentTest < tests.length) {
         tests[currentTest]();
       } else {
         SimpleTest.finish();
       }
     }
+
+    function runTests() {
+      p = document.getElementById("plugin1");
+      runNextTest();
+    }
   </script>
+
+  <embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
 </body>
 </html>
--- a/dom/plugins/test/mochitest/test_refresh_navigator_plugins.html
+++ b/dom/plugins/test/mochitest/test_refresh_navigator_plugins.html
@@ -1,20 +1,23 @@
 <!DOCTYPE html>
 <!-- bug 820708 -->
 <html>
   <head>
     <meta><charset="utf-8"/>
     <title>Test Refreshing navigator.plugins (bug 820708)</title>
     <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
     <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/ChromeUtils.js"></script>
+    <script type="application/javascript" src="utils.js"></script>
   </head>
   <body>
     <script class="testbody" type="application/javascript">
       SimpleTest.waitForExplicitFinish();
+      setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
+
       var pluginHost = Components.classes["@mozilla.org/plugin/host;1"]
                        .getService(Components.interfaces.nsIPluginHost);
       var pluginTags = pluginHost.getPluginTags();
       var nextTest = null;
       var obsService = Components.classes["@mozilla.org/observer-service;1"]
                        .getService(Components.interfaces.nsIObserverService);
       var observer = {
         observe: function(aSubject, aTopic, aData) {
--- a/dom/plugins/test/mochitest/test_secondPlugin.html
+++ b/dom/plugins/test/mochitest/test_secondPlugin.html
@@ -1,21 +1,22 @@
 <html>
   <head>
      <title>Second Test Plug-in Test</title>
 
     <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+    <script type="text/javascript" src="utils.js"></script>
     <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
   </head>
 
   <body onload="run()">
-    <object id="plugin" type="application/x-second-test" width=200 height=200></object>
-
     <script class="testbody" type="application/javascript">
       SimpleTest.waitForExplicitFinish();
+      setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
+      setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED, "Second Test Plug-in");
 
       function run() {
         var foundFirstPlugin = false;
         var foundSecondPlugin = false;
         for (var index in navigator.plugins) {
           var plugin = navigator.plugins[index];
           if (plugin.name == "Test Plug-in") foundFirstPlugin = true;
           if (plugin.name == "Second Test Plug-in") foundSecondPlugin = true;
@@ -24,10 +25,12 @@
         ok(foundSecondPlugin, "Should have a plugin named 'Second Test Plug-in'");
 
         var pluginElement = document.getElementById("plugin");
         is(pluginElement.identifierToStringTest("foo"), "foo", "Should be able to call a function provided by the plugin");
 
         SimpleTest.finish();
       }
     </script>
+
+    <object id="plugin" type="application/x-second-test" width=200 height=200></object>
   </body>
 </html>
--- a/dom/plugins/test/mochitest/test_src_url_change.html
+++ b/dom/plugins/test/mochitest/test_src_url_change.html
@@ -1,40 +1,42 @@
 <!DOCTYPE html>
 <html>
 <head>
   <title>Test changing src attribute</title>
   <script type="text/javascript" src="/MochiKit/packed.js"></script>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="utils.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body onload="runTests()">
-  <p id="display"></p>
-
-  <embed id="plugin1" src="about:blank" type="application/x-test" width="200" height="200"></embed>
-
   <script type="application/javascript;version=1.8">
   SimpleTest.waitForExplicitFinish();
-
-  var p = document.getElementById('plugin1');
+  setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
   var destroyed = false;
   function onDestroy() {
     destroyed = true;
   }
 
   function runTests() {
+    p = document.getElementById('plugin1');
+
     p.startWatchingInstanceCount();
     p.callOnDestroy(onDestroy);
 
     p.setAttribute("src", "loremipsum.txt");
 
     is(destroyed, true, "Instance should have been destroyed.");
     is(p.getInstanceCount(), 1, "One new instance should have been created.");
 
     p.stopWatchingInstanceCount();
 
     SimpleTest.finish();
   }
   </script>
+
+  <p id="display"></p>
+
+  <embed id="plugin1" src="about:blank" type="application/x-test" width="200" height="200"></embed>
 </body>
 </html>
 
--- a/dom/plugins/test/mochitest/test_streamNotify.html
+++ b/dom/plugins/test/mochitest/test_streamNotify.html
@@ -1,17 +1,17 @@
 <head>
   <title>NPN_Get/PostURLNotify tests</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="utils.js"></script>
 
 <body onload="runTests()">
-  <embed id="plugin1" type="application/x-test" width="400" height="400"></embed>
-
   <script class="testbody" type="application/javascript">
   SimpleTest.waitForExplicitFinish();
+  setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
   var pending = 5;
   function testDone() {
     dump("testDone: " + pending + "\n")
     --pending;
 
     // Wait for a bit so that any unexpected notifications from the
     // malformed data or null-post tests are received.
@@ -79,8 +79,10 @@
                     }, null, true), "streamTest GET data: URI");
 
     ok(!p.streamTest("data:malformed?", false, null, null,
                      function(r, t) {
                        todo(false, "Shouldn't get callback for invalid data: URI");
                      }, null, true), "streamTest GET bad data: URI");
   }
   </script>
+
+  <embed id="plugin1" type="application/x-test" width="400" height="400"></embed>
--- a/dom/plugins/test/mochitest/test_streamatclose.html
+++ b/dom/plugins/test/mochitest/test_streamatclose.html
@@ -1,30 +1,28 @@
 <html>
 <head>
   <title>Stream open at NPP_Destroy</title>
   <script type="text/javascript"
 	  src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="utils.js"></script>
   <link rel="stylesheet" type="text/css"
 	href="/tests/SimpleTest/test.css">
 
 <body onload="startTest()">
-  <p id="display"></p>
-
-  <embed id="embedtest"
-	 style="width: 400px; height: 100px;" type="application/x-test"></embed>
-
   <script type="text/javascript">
   SimpleTest.waitForExplicitFinish();
+  setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
   var urlnotified = false;
 
-  var p = document.getElementById('embedtest');
+  var p = null;
 
   function startTest() {
+    p = document.getElementById('embedtest');
     ok(p.streamTest("neverending.sjs", false, null, null,
                     function(r, t) {
                       is(r, 2, "Stream should have failed");
                       urlnotified = true;
                     }, null, true), "neverending.sjs started successfully");
 
     setTimeout(removePlugin, 500);
   }
@@ -35,8 +33,13 @@
   }
 
   function done() {
     ok(urlnotified, "NPP_URLNotify should be called if streams are active at NPP_Destroy");
     SimpleTest.finish();
   }
 
   </script>
+
+  <p id="display"></p>
+
+  <embed id="embedtest"
+   style="width: 400px; height: 100px;" type="application/x-test"></embed>
\ No newline at end of file
--- a/dom/plugins/test/mochitest/test_twostreams.html
+++ b/dom/plugins/test/mochitest/test_twostreams.html
@@ -1,23 +1,25 @@
 <html>
 <head>
   <title>Dual NPAPI NP_ASFILEONLY NPStream Test</title>
   <script type="text/javascript" 
           src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="utils.js"></script>
   <link rel="stylesheet" type="text/css" 
         href="/tests/SimpleTest/test.css" />
 </head>
 <body>
   <p id="display"></p>
 
   <script type="text/javascript">
   SimpleTest.expectAssertions(0, 2);
 
   SimpleTest.waitForExplicitFinish();
+  setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
   var framesToLoad = 2;
   function frameLoaded(id) {
     var frame = document.getElementById('testframe' + id);
     if (!frame.contentDocument.body.innerHTML.length)
       return;
 
     --framesToLoad;
--- a/dom/plugins/test/mochitest/test_visibility.html
+++ b/dom/plugins/test/mochitest/test_visibility.html
@@ -10,16 +10,17 @@
   </style>
 
 <body onload="startTest()">
   <p id="display"></p>
 
   <script type="application/javascript" src="utils.js"></script>
   <script type="application/javascript">
   SimpleTest.waitForExplicitFinish();
+  setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
   var didPaint = function() {};
 
   function startTest() {
     if (SimpleTest.testPluginIsOOP()) {
       if (p.getPaintCount() < 1) {
         setTimeout(startTest, 0);
         return;
--- a/dom/plugins/test/mochitest/test_windowed_invalidate.html
+++ b/dom/plugins/test/mochitest/test_windowed_invalidate.html
@@ -1,28 +1,24 @@
 <html>
 <head>
   <title>Test NPN_Invalidate working for a windowed plugin</title>
   <script type="text/javascript" 
           src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="utils.js"></script>
   <link rel="stylesheet" type="text/css" 
         href="/tests/SimpleTest/test.css" />
 </head>
-<body onload="checkPaintCountStabilized()">
-  <p id="display"></p>
-
-  <embed id="p" type="application/x-test" wmode="window" drawmode="solid"
-         color="FFFF0000">
-  </embed>
-
+<body onload="runTests()">
   <script class="testbody" type="application/javascript">
   SimpleTest.waitForExplicitFinish();
+  setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
   var lastPaintCount;
-  var p = document.getElementById("p");
+  var p = null;
 
   function checkPainted() {
     if (p.getPaintCount() > lastPaintCount) {
       ok(true, "Plugin did repaint");
       SimpleTest.finish();
     } else {
       setTimeout(checkPainted, 100);
     }
@@ -45,14 +41,25 @@
       var newCount = p.getPaintCount();
       if (newCount == lastPaintCount) {
         doTest();
       } else {
         checkPaintCountStabilized();
       }
     }, 1000);
   }
+
+  function runTests() {
+    p = document.getElementById("p");
+    checkPaintCountStabilized();
+  }
   </script>
-  
+
+  <p id="display"></p>
+
+  <embed id="p" type="application/x-test" wmode="window" drawmode="solid"
+         color="FFFF0000">
+  </embed>
+
   <div id="verbose">
   </div>
  </body>
  </html>
--- a/dom/plugins/test/mochitest/test_wmode.xul
+++ b/dom/plugins/test/mochitest/test_wmode.xul
@@ -3,16 +3,20 @@
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 <window title="WMode Tests"
   xmlns:html="http://www.w3.org/1999/xhtml"
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <title>WMode Tests</title>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
+  <script type="application/javascript" src="utils.js"></script>
+  <script type="application/javascript">
+    setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
+  </script>
 <body xmlns="http://www.w3.org/1999/xhtml" onload="runTests()">
 <embed id="plugin2" type="application/x-test" width="400" height="400" wmode="window"></embed>
 <embed id="plugin1" type="application/x-test" width="400" height="400"></embed>
 </body>
 <script class="testbody" type="application/javascript">
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
--- a/dom/plugins/test/mochitest/test_xulbrowser_plugin_visibility.xul
+++ b/dom/plugins/test/mochitest/test_xulbrowser_plugin_visibility.xul
@@ -1,18 +1,20 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
 	  src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
+  <script type="application/javascript" src="utils.js"></script>
 
   <script>
   SimpleTest.waitForExplicitFinish();
+  setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
   var w = window.open('xulbrowser_plugin_visibility.xul', '_blank', 'chrome,resizable=yes,width=400,height=600');
 
   function done()
   {
     w.close();
     SimpleTest.finish();
   }
--- a/dom/plugins/test/mochitest/test_zero_opacity.html
+++ b/dom/plugins/test/mochitest/test_zero_opacity.html
@@ -1,26 +1,25 @@
 <!DOCTYPE html>
 <html>
 <head>
   <title>Test whether windowed plugins with opacity:0 get their window set correctly</title>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="utils.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 
 <body onload="startTest()">
-  <p id="display"></p>
-
-  <embed id="theplugin" type="application/x-test" width="100" height="50" style="opacity:0" wmode="window"></embed>
-
   <script type="application/javascript;version=1.8">
   SimpleTest.waitForExplicitFinish();
+  setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
-  var p = document.getElementById('theplugin');
+  var p = null;
 
   function startTest() {
+    p = document.getElementById('theplugin');
     if (!p.hasWidget()) {
       todo(false, "This test is only relevant for windowed plugins");
       SimpleTest.finish();
       return;
     }
 
     // Wait for the plugin to have painted once.
     var interval = setInterval(function() {
@@ -34,8 +33,12 @@
   }
 
   function doTest() {
     is(p.getClipRegionRectCount(), 1, "getClipRegionRectCount should be a single rect");
     is(p.getClipRegionRectEdge(0,2) - p.getClipRegionRectEdge(0,0), 100, "width of clip region rect");
     is(p.getClipRegionRectEdge(0,3) - p.getClipRegionRectEdge(0,1), 50, "height of clip region rect");
   }
   </script>
+
+  <p id="display"></p>
+
+  <embed id="theplugin" type="application/x-test" width="100" height="50" style="opacity:0" wmode="window"></embed>
\ No newline at end of file
--- a/dom/plugins/test/mochitest/utils.js
+++ b/dom/plugins/test/mochitest/utils.js
@@ -10,8 +10,35 @@ function paintCountIs(plugin, expected, 
         realExpected *= 2;
       }
     } catch (e) {}
   }
   ok(realExpected == count, msg + " (expected " + expected +
      " independent paints, expected " + realExpected + " logged paints, got " +
      count + " actual paints)");
 }
+
+function getTestPlugin(pluginName) {
+  var ph = SpecialPowers.Cc["@mozilla.org/plugin/host;1"]
+                                 .getService(SpecialPowers.Ci.nsIPluginHost);
+  var tags = ph.getPluginTags();
+  var name = pluginName || "Test Plug-in";
+  for (var tag of tags) {
+    if (tag.name == name) {
+      return tag;
+    }
+  }
+
+  ok(false, "Could not find plugin tag with plugin name '" + name + "'");
+  return null;
+}
+
+// call this to set the test plugin(s) initially expected enabled state.
+// it will automatically be reset to it's previous value after the test
+// ends
+function setTestPluginEnabledState(newEnabledState, pluginName) {
+  var plugin = getTestPlugin(pluginName);
+  var oldEnabledState = plugin.enabledState;
+  plugin.enabledState = newEnabledState;
+  SimpleTest.registerCleanupFunction(function() {
+    getTestPlugin(pluginName).enabledState = oldEnabledState;
+  });
+}