mirror of
https://github.com/classilla/tenfourfox.git
synced 2024-11-19 18:38:36 +00:00
98 lines
3.4 KiB
HTML
98 lines
3.4 KiB
HTML
|
<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 waitForCondition(condition, nextTest, errorMsg) {
|
||
|
var tries = 0;
|
||
|
var interval = setInterval(function() {
|
||
|
if (tries >= 30) {
|
||
|
ok(false, errorMsg);
|
||
|
moveOn();
|
||
|
}
|
||
|
if (condition()) {
|
||
|
moveOn();
|
||
|
}
|
||
|
tries++;
|
||
|
}, 100);
|
||
|
var moveOn = function() { clearInterval(interval); nextTest(); };
|
||
|
}
|
||
|
|
||
|
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;
|
||
|
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;
|
||
|
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>
|