2012-08-10 22:28:34 +04:00
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Bug 751809</title>
|
2013-04-24 03:21:22 +04:00
|
|
|
<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>
|
2015-11-17 01:54:12 +03:00
|
|
|
<script type="application/javascript" src="plugin-utils.js"></script>
|
2017-02-23 00:10:07 +03:00
|
|
|
<script type="application/javascript">
|
2019-01-17 21:18:31 +03:00
|
|
|
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
2013-04-24 03:21:22 +04:00
|
|
|
Services.prefs.setBoolPref("plugins.click_to_play", true);
|
2013-09-04 18:05:40 +04:00
|
|
|
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_CLICKTOPLAY);
|
2012-10-29 21:27:32 +04:00
|
|
|
</script>
|
2012-08-10 22:28:34 +04:00
|
|
|
</head>
|
|
|
|
|
2012-10-29 21:27:32 +04:00
|
|
|
<body onload="go();">
|
|
|
|
<embed id="plugin" type="application/x-test" width="400" height="400" drawmode="solid" color="FF00FFFF"></embed>
|
|
|
|
|
2017-02-23 00:10:07 +03:00
|
|
|
<script type="application/javascript">
|
2012-10-29 21:27:32 +04:00
|
|
|
|
2012-08-10 22:28:34 +04:00
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
2018-07-25 02:47:41 +03:00
|
|
|
const utils = window.windowUtils;
|
2012-08-10 22:28:34 +04:00
|
|
|
|
2012-10-29 21:27:32 +04:00
|
|
|
function go() {
|
2012-08-10 22:28:34 +04:00
|
|
|
var plugin = document.getElementById('plugin');
|
2013-03-17 18:42:05 +04:00
|
|
|
var objLoadingContent = SpecialPowers.wrap(plugin);
|
2012-08-10 22:28:34 +04:00
|
|
|
ok(!objLoadingContent.activated, "plugin should not be activated");
|
|
|
|
|
|
|
|
SimpleTest.waitForFocus(afterWindowFocus);
|
|
|
|
}
|
2012-10-29 21:27:32 +04:00
|
|
|
|
2012-08-10 22:28:34 +04:00
|
|
|
function afterWindowFocus() {
|
|
|
|
var plugin = document.getElementById('plugin');
|
2013-06-24 16:51:07 +04:00
|
|
|
var objLoadingContent = SpecialPowers.wrap(plugin);
|
2012-10-29 21:27:32 +04:00
|
|
|
|
2013-06-24 16:51:07 +04:00
|
|
|
objLoadingContent.playPlugin();
|
2015-09-23 12:39:15 +03:00
|
|
|
var condition = () => plugin.setColor !== undefined;
|
2015-09-18 06:06:47 +03:00
|
|
|
SimpleTest.waitForCondition(condition, afterPluginActivation,
|
|
|
|
"Waited too long for plugin to activate");
|
2012-08-10 22:28:34 +04:00
|
|
|
}
|
|
|
|
|
2012-10-29 21:27:32 +04:00
|
|
|
function afterPluginActivation() {
|
2012-08-10 22:28:34 +04:00
|
|
|
var plugin = document.getElementById('plugin');
|
2013-03-17 18:42:05 +04:00
|
|
|
var objLoadingContent = SpecialPowers.wrap(plugin);
|
2012-08-10 22:28:34 +04:00
|
|
|
ok(objLoadingContent.activated, "plugin should be activated now");
|
2012-12-05 17:39:26 +04:00
|
|
|
|
|
|
|
// 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');
|
2012-08-10 22:28:34 +04:00
|
|
|
try {
|
|
|
|
is(plugin.getMouseUpEventCount(), 0, "Plugin should not have received mouse events yet.");
|
|
|
|
} catch(e) {
|
|
|
|
ok(false, "plugin.getMouseUpEventCount() shouldn't throw");
|
|
|
|
}
|
|
|
|
|
2012-10-29 21:27:32 +04:00
|
|
|
synthesizeMouseAtCenter(plugin, {});
|
2015-09-23 12:39:15 +03:00
|
|
|
var condition = () => plugin.getMouseUpEventCount() > 0;
|
2015-09-18 06:06:47 +03:00
|
|
|
SimpleTest.waitForCondition(condition, afterFirstClick,
|
|
|
|
"Waited too long for plugin to receive the mouse click");
|
2012-08-10 22:28:34 +04:00
|
|
|
}
|
2012-10-29 21:27:32 +04:00
|
|
|
|
2012-08-10 22:28:34 +04:00
|
|
|
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");
|
|
|
|
}
|
|
|
|
|
2013-04-24 03:21:22 +04:00
|
|
|
Services.prefs.clearUserPref("plugins.click_to_play");
|
2012-08-10 22:28:34 +04:00
|
|
|
SimpleTest.finish();
|
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|