michael@0: function paintCountIs(plugin, expected, msg) { michael@0: var count = plugin.getPaintCount(); michael@0: var realExpected = expected; michael@0: var isAsync = SimpleTest.testPluginIsOOP(); michael@0: if (isAsync) { michael@0: ++realExpected; // extra paint at startup for all async-rendering plugins michael@0: } else { michael@0: try { michael@0: if (SpecialPowers.Cc["@mozilla.org/gfx/info;1"].getService(SpecialPowers.Ci.nsIGfxInfo).D2DEnabled) { michael@0: realExpected *= 2; michael@0: } michael@0: } catch (e) {} michael@0: } michael@0: ok(realExpected == count, msg + " (expected " + expected + michael@0: " independent paints, expected " + realExpected + " logged paints, got " + michael@0: count + " actual paints)"); michael@0: } michael@0: michael@0: function getTestPlugin(pluginName) { michael@0: var ph = SpecialPowers.Cc["@mozilla.org/plugin/host;1"] michael@0: .getService(SpecialPowers.Ci.nsIPluginHost); michael@0: var tags = ph.getPluginTags(); michael@0: var name = pluginName || "Test Plug-in"; michael@0: for (var tag of tags) { michael@0: if (tag.name == name) { michael@0: return tag; michael@0: } michael@0: } michael@0: michael@0: ok(false, "Could not find plugin tag with plugin name '" + name + "'"); michael@0: return null; michael@0: } michael@0: michael@0: // call this to set the test plugin(s) initially expected enabled state. michael@0: // it will automatically be reset to it's previous value after the test michael@0: // ends michael@0: function setTestPluginEnabledState(newEnabledState, pluginName) { michael@0: var plugin = getTestPlugin(pluginName); michael@0: var oldEnabledState = plugin.enabledState; michael@0: plugin.enabledState = newEnabledState; michael@0: SimpleTest.registerCleanupFunction(function() { michael@0: getTestPlugin(pluginName).enabledState = oldEnabledState; michael@0: }); michael@0: }