mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
76 lines
2.5 KiB
HTML
76 lines
2.5 KiB
HTML
<html>
|
|
<head>
|
|
<title>NPCocoaEventFocusChanged Tests</title>
|
|
</head>
|
|
<body onload="runTests()">
|
|
<embed id="plugin1" type="application/x-test" width="400" height="400"></embed>
|
|
<embed id="plugin2" type="application/x-test" width="400" height="400"></embed>
|
|
<script type="application/javascript">
|
|
function is(aLeft, aRight, aMessage) {
|
|
window.opener.SimpleTest.is(aLeft, aRight, aMessage);
|
|
}
|
|
|
|
function ok(aValue, aMessage) {
|
|
window.opener.SimpleTest.ok(aValue, aMessage);
|
|
}
|
|
|
|
function runTests() {
|
|
var plugin1 = document.getElementById("plugin1"); // What we're testing.
|
|
var plugin2 = document.getElementById("plugin2"); // Dummy.
|
|
|
|
// Don't run any tests if we're not testing the Cocoa event model.
|
|
if (plugin1.getEventModel() != 1) {
|
|
window.opener.testsFinished();
|
|
return;
|
|
}
|
|
|
|
// The expected event count which applies to all instances.
|
|
// Initialize to 0 since there is no initial state event,
|
|
// plugins should assume they do not initially have focus.
|
|
var expectedEventCount = 0;
|
|
|
|
// Make sure initial event count is correct.
|
|
is(plugin1.getFocusEventCount(), expectedEventCount, "Focus event count should be " + expectedEventCount);
|
|
|
|
// Make sure initial focus state is unkown (assumed false).
|
|
var initialStateUnknown = false;
|
|
try {
|
|
plugin1.getFocusState();
|
|
} catch (e) {
|
|
initialStateUnknown = true;
|
|
}
|
|
is(initialStateUnknown, true, "Initial state should be unknown, assumed false.");
|
|
|
|
// Give the plugin focus.
|
|
plugin1.focus();
|
|
expectedEventCount++;
|
|
|
|
is(plugin1.getFocusState(), true, "Plugin should have focus.");
|
|
is(plugin1.getFocusEventCount(), expectedEventCount, "Focus event count should be " + expectedEventCount);
|
|
|
|
// Make sure window activation state changes don't affect plugin focus.
|
|
// Past this point we can't really count events because of how Gecko's focus works.
|
|
// Only the end result matters anyway.
|
|
|
|
// Blur the window.
|
|
window.focus(); // start in an active state
|
|
window.blur();
|
|
|
|
is(plugin1.getFocusState(), true, "Plugin should have focus.");
|
|
|
|
// Focus the window.
|
|
window.focus();
|
|
|
|
is(plugin1.getFocusState(), true, "Plugin should have focus.");
|
|
|
|
// Take focus from the plugin.
|
|
plugin2.focus();
|
|
|
|
is(plugin1.getFocusState(), false, "Plugin should not have focus.");
|
|
|
|
window.opener.testsFinished();
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|