Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 function paintCountIs(plugin, expected, msg) {
2 var count = plugin.getPaintCount();
3 var realExpected = expected;
4 var isAsync = SimpleTest.testPluginIsOOP();
5 if (isAsync) {
6 ++realExpected; // extra paint at startup for all async-rendering plugins
7 } else {
8 try {
9 if (SpecialPowers.Cc["@mozilla.org/gfx/info;1"].getService(SpecialPowers.Ci.nsIGfxInfo).D2DEnabled) {
10 realExpected *= 2;
11 }
12 } catch (e) {}
13 }
14 ok(realExpected == count, msg + " (expected " + expected +
15 " independent paints, expected " + realExpected + " logged paints, got " +
16 count + " actual paints)");
17 }
19 function getTestPlugin(pluginName) {
20 var ph = SpecialPowers.Cc["@mozilla.org/plugin/host;1"]
21 .getService(SpecialPowers.Ci.nsIPluginHost);
22 var tags = ph.getPluginTags();
23 var name = pluginName || "Test Plug-in";
24 for (var tag of tags) {
25 if (tag.name == name) {
26 return tag;
27 }
28 }
30 ok(false, "Could not find plugin tag with plugin name '" + name + "'");
31 return null;
32 }
34 // call this to set the test plugin(s) initially expected enabled state.
35 // it will automatically be reset to it's previous value after the test
36 // ends
37 function setTestPluginEnabledState(newEnabledState, pluginName) {
38 var plugin = getTestPlugin(pluginName);
39 var oldEnabledState = plugin.enabledState;
40 plugin.enabledState = newEnabledState;
41 SimpleTest.registerCleanupFunction(function() {
42 getTestPlugin(pluginName).enabledState = oldEnabledState;
43 });
44 }