Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | function paintCountIs(plugin, expected, msg) { |
michael@0 | 2 | var count = plugin.getPaintCount(); |
michael@0 | 3 | var realExpected = expected; |
michael@0 | 4 | var isAsync = SimpleTest.testPluginIsOOP(); |
michael@0 | 5 | if (isAsync) { |
michael@0 | 6 | ++realExpected; // extra paint at startup for all async-rendering plugins |
michael@0 | 7 | } else { |
michael@0 | 8 | try { |
michael@0 | 9 | if (SpecialPowers.Cc["@mozilla.org/gfx/info;1"].getService(SpecialPowers.Ci.nsIGfxInfo).D2DEnabled) { |
michael@0 | 10 | realExpected *= 2; |
michael@0 | 11 | } |
michael@0 | 12 | } catch (e) {} |
michael@0 | 13 | } |
michael@0 | 14 | ok(realExpected == count, msg + " (expected " + expected + |
michael@0 | 15 | " independent paints, expected " + realExpected + " logged paints, got " + |
michael@0 | 16 | count + " actual paints)"); |
michael@0 | 17 | } |
michael@0 | 18 | |
michael@0 | 19 | function getTestPlugin(pluginName) { |
michael@0 | 20 | var ph = SpecialPowers.Cc["@mozilla.org/plugin/host;1"] |
michael@0 | 21 | .getService(SpecialPowers.Ci.nsIPluginHost); |
michael@0 | 22 | var tags = ph.getPluginTags(); |
michael@0 | 23 | var name = pluginName || "Test Plug-in"; |
michael@0 | 24 | for (var tag of tags) { |
michael@0 | 25 | if (tag.name == name) { |
michael@0 | 26 | return tag; |
michael@0 | 27 | } |
michael@0 | 28 | } |
michael@0 | 29 | |
michael@0 | 30 | ok(false, "Could not find plugin tag with plugin name '" + name + "'"); |
michael@0 | 31 | return null; |
michael@0 | 32 | } |
michael@0 | 33 | |
michael@0 | 34 | // call this to set the test plugin(s) initially expected enabled state. |
michael@0 | 35 | // it will automatically be reset to it's previous value after the test |
michael@0 | 36 | // ends |
michael@0 | 37 | function setTestPluginEnabledState(newEnabledState, pluginName) { |
michael@0 | 38 | var plugin = getTestPlugin(pluginName); |
michael@0 | 39 | var oldEnabledState = plugin.enabledState; |
michael@0 | 40 | plugin.enabledState = newEnabledState; |
michael@0 | 41 | SimpleTest.registerCleanupFunction(function() { |
michael@0 | 42 | getTestPlugin(pluginName).enabledState = oldEnabledState; |
michael@0 | 43 | }); |
michael@0 | 44 | } |