flash detection

JavaScript performance comparison

Revision 2 of this test case created by Flash detection

Preparation code

<script src="https://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
      
<script>
Benchmark.prototype.setup = function() {
  var singleLineFlashCheck = function() {
      return (typeof navigator.plugins == "undefined" || navigator.plugins.length == 0) ? !!(new ActiveXObject("ShockwaveFlash.ShockwaveFlash")) : navigator.plugins["Shockwave Flash"];
  };
  
  var swfFlashCheck = function(){
      return swfobject.getFlashPlayerVersion().major;
  };
  
  var a1 = function() {
      return navigator.mimeTypes["application/x-shockwave-flash"]
  };
  
  var googleFlash = function(){
  var a = !1,
      b = "";
  
  function c(d) {
      d = d.match(/[\d]+/g);
      d.length = 3;
      return d.join(".")
  }
  if (navigator.plugins && navigator.plugins.length) {
      var e = navigator.plugins["Shockwave Flash"];
      e && (a = !0, e.description && (b = c(e.description)));
      navigator.plugins["Shockwave Flash 2.0"] && (a = !0, b = "2.0.0.11")
  } else {
      if (navigator.mimeTypes && navigator.mimeTypes.length) {
          var f = navigator.mimeTypes["application/x-shockwave-flash"];
          (a = f && f.enabledPlugin) && (b = c(f.enabledPlugin.description))
      } else {
          try {
              var g = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"),
                  a = !0,
                  b = c(g.GetVariable("$version"))
          } catch (h) {
              try {
                  g = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"), a = !0, b = "6.0.21"
              } catch (i) {
                  try {
                      g = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"), a = !0, b = c(g.GetVariable("$version"))
                  } catch (j) {}
              }
          }
      }
  }
  var k = b;
  return a || k;
  }

};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Mime type (modern)
a1();
pending…
Single Line
singleLineFlashCheck();
pending…
swfObject
swfFlashCheck();
pending…
Google Flash Detect
googleFlash();
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL.

0 Comments