1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
<html>
<head>
<title>Bug 751809</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/paint_listener.js"></script>
<script type="application/javascript" src="plugin-utils.js"></script>
<script type="application/javascript;version=1.7">
Components.utils.import("resource://gre/modules/Services.jsm");
Services.prefs.setBoolPref("plugins.click_to_play", true);
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_CLICKTOPLAY);
</script>
</head>
<body onload="go();">
<embed id="plugin" type="application/x-test" width="400" height="400" drawmode="solid" color="FF00FFFF"></embed>
<script type="application/javascript;version=1.7">
SimpleTest.waitForExplicitFinish();
const Ci = Components.interfaces;
const utils = window.QueryInterface(Ci.nsIInterfaceRequestor).
getInterface(Ci.nsIDOMWindowUtils);
function go() {
var plugin = document.getElementById('plugin');
var objLoadingContent = SpecialPowers.wrap(plugin);
ok(!objLoadingContent.activated, "plugin should not be activated");
SimpleTest.waitForFocus(afterWindowFocus);
}
function afterWindowFocus() {
var plugin = document.getElementById('plugin');
var objLoadingContent = SpecialPowers.wrap(plugin);
objLoadingContent.playPlugin();
var condition = () => plugin.setColor !== undefined;
SimpleTest.waitForCondition(condition, afterPluginActivation,
"Waited too long for plugin to activate");
}
function afterPluginActivation() {
var plugin = document.getElementById('plugin');
var objLoadingContent = SpecialPowers.wrap(plugin);
ok(objLoadingContent.activated, "plugin should be activated now");
// Triggering a paint and waiting for it to be flushed makes sure
// that both plugin and platform see the plugin element as visible.
// See bug 805330 for details.
plugin.setColor("FF000088");
waitForAllPaintsFlushed(afterPaintsFlushed);
}
function afterPaintsFlushed() {
var plugin = document.getElementById('plugin');
try {
is(plugin.getMouseUpEventCount(), 0, "Plugin should not have received mouse events yet.");
} catch(e) {
ok(false, "plugin.getMouseUpEventCount() shouldn't throw");
}
synthesizeMouseAtCenter(plugin, {});
var condition = () => plugin.getMouseUpEventCount() > 0;
SimpleTest.waitForCondition(condition, afterFirstClick,
"Waited too long for plugin to receive the mouse click");
}
function afterFirstClick() {
var plugin = document.getElementById('plugin');
try {
is(plugin.getMouseUpEventCount(), 1, "Plugin should have received 1 mouse up event.");
} catch(e) {
ok(false, "plugin.getMouseUpEventCount() shouldn't throw");
}
Services.prefs.clearUserPref("plugins.click_to_play");
SimpleTest.finish();
}
</script>
</body>
</html>
|