Bug 899080 - Test fixup part 7 - accessible. r=surkov
authorGeorg Fritzsche <georg.fritzsche@googlemail.com>
Wed, 04 Sep 2013 16:07:53 +0200
changeset 145523 eb82f789664b509ecb6f66094c5e0dd657b2035b
parent 145522 1c3c7005f6af6f078def0533ae6a1890fdc48df4
child 145524 1e63861a73d93b45284379c5fe1bcb279aa2e995
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)
reviewerssurkov
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 7 - accessible. r=surkov
accessible/tests/mochitest/common.js
accessible/tests/mochitest/elm/test_HTMLSpec.html
accessible/tests/mochitest/elm/test_plugin.html
--- a/accessible/tests/mochitest/common.js
+++ b/accessible/tests/mochitest/common.js
@@ -749,16 +749,31 @@ function getMainChromeWindow(aWindow)
   return aWindow.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
                 .getInterface(Components.interfaces.nsIWebNavigation)
                 .QueryInterface(Components.interfaces.nsIDocShellTreeItem)
                 .rootTreeItem
                 .QueryInterface(Components.interfaces.nsIInterfaceRequestor)
                 .getInterface(Components.interfaces.nsIDOMWindow);
 }
 
+/** Sets the test plugin(s) initially expected enabled state.
+ * It will automatically be reset to it's previous value after the test
+ * ends.
+ * @param aNewEnabledState [in] the enabled state, e.g. SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED
+ * @param aPluginName [in, optional] The name of the plugin, defaults to "Test Plug-in"
+ */
+function setTestPluginEnabledState(aNewEnabledState, aPluginName)
+{
+  var plugin = getTestPluginTag(aPluginName);
+  var oldEnabledState = plugin.enabledState;
+  plugin.enabledState = aNewEnabledState;
+  SimpleTest.registerCleanupFunction(function() {
+    getTestPluginTag(aPluginName).enabledState = oldEnabledState;
+  });
+}
 
 ////////////////////////////////////////////////////////////////////////////////
 // Private
 ////////////////////////////////////////////////////////////////////////////////
 
 ////////////////////////////////////////////////////////////////////////////////
 // Accessible general
 
@@ -784,8 +799,24 @@ function getObjAddress(aObj)
 {
   var exp = /native\s*@\s*(0x[a-f0-9]+)/g;
   var match = exp.exec(aObj.toString());
   if (match)
     return match[1];
 
   return aObj.toString();
 }
+
+function getTestPluginTag(aPluginName)
+{
+  var ph = SpecialPowers.Cc["@mozilla.org/plugin/host;1"]
+                        .getService(SpecialPowers.Ci.nsIPluginHost);
+  var tags = ph.getPluginTags();
+  var name = aPluginName || "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;
+}
--- a/accessible/tests/mochitest/elm/test_HTMLSpec.html
+++ b/accessible/tests/mochitest/elm/test_HTMLSpec.html
@@ -1234,18 +1234,18 @@
       };
       testElm("video", obj);
 
       SimpleTest.finish();
     }
 
     SimpleTest.waitForExplicitFinish();
     addA11yLoadEvent(doTest);
+    setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
-  
     </script>
 </head>
 <body>
 
   <a target="_blank"
     title="Implement figure and figcaption accessibility"
     href="https://bugzilla.mozilla.org/show_bug.cgi?id=658272">
      Mozilla Bug 658272
--- a/accessible/tests/mochitest/elm/test_plugin.html
+++ b/accessible/tests/mochitest/elm/test_plugin.html
@@ -33,16 +33,17 @@
       testStates("plugin-windowed", 0, 0, STATE_UNAVAILABLE);
       testAccessibleTree("plugin-windowed", { EMBEDDED_OBJECT: [ { NOTHING: [] } ] });
 
       SimpleTest.finish();
     }
 
     SimpleTest.waitForExplicitFinish();
     addA11yLoadEvent(doTest);
+    setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
   </script>
 </head>
 <body>
 
   <a target="_blank"
      title="Embed and object HTML tags should be given an accessible role of embedded object"
      href="https://bugzilla.mozilla.org/show_bug.cgi?id=485270">Bug 485270</a>
   <a target="_blank"