fune/dom/plugins/test/mochitest/cocoa_window_focus.html
Bogdan Tara 56346a0425 Backed out 19 changesets (bug 1675349) for lint failures on browser_ext_browsingData_pluginData and test_archive CLOSED TREE
Backed out changeset 244e0f2b410c (bug 1675349)
Backed out changeset ba5724069dd4 (bug 1675349)
Backed out changeset 37fca259c7e9 (bug 1675349)
Backed out changeset f2b16caca1fc (bug 1675349)
Backed out changeset 28835d4935be (bug 1675349)
Backed out changeset eb913f58953a (bug 1675349)
Backed out changeset 19e3cb80f469 (bug 1675349)
Backed out changeset d9723f3a3a7e (bug 1675349)
Backed out changeset c888dfcdf70e (bug 1675349)
Backed out changeset 48f153341af6 (bug 1675349)
Backed out changeset 7fc67a9b2932 (bug 1675349)
Backed out changeset 1cee4d97f801 (bug 1675349)
Backed out changeset 59a0cb79c7c1 (bug 1675349)
Backed out changeset 43d349fa37b1 (bug 1675349)
Backed out changeset c84bfb6eae59 (bug 1675349)
Backed out changeset 38e9af69ae57 (bug 1675349)
Backed out changeset 3255c1ab3059 (bug 1675349)
Backed out changeset 2f3eaf9c342c (bug 1675349)
Backed out changeset 769e5c0db4c2 (bug 1675349)
2020-11-18 06:06:36 +02:00

95 lines
4 KiB
HTML

<html>
<head>
<title>NPCocoaEventWindowFocusChanged 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 executeSoon(func) {
window.opener.SimpleTest.executeSoon(func);
}
function waitForFocus(aCb, aTarget, aBlank) {
window.opener.SimpleTest.waitForFocus(aCb, aTarget, aBlank);
}
function runTests() {
var plugin1 = document.getElementById("plugin1");
var plugin2 = document.getElementById("plugin2");
if (plugin1.getEventModel() != 1) {
window.opener.todo(false, "Skipping this test when not testing the Cocoa event model");
window.opener.testsFinished();
return;
}
// The first plugin will have in-page focus for these tests.
plugin1.focus();
// The expected event count which applies to all instances.
// Initialize to 1 to account for the initial state event.
var expectedEventCount = 1;
// First make sure the plugins got an initial window focus event.
// Since this window was just opened it should be in the front. If
// the plugin has not been sent an initial window state then it will
// be in an unknown state and it will throw an exception.
try {
is(plugin1.getTopLevelWindowActivationState(), true, "Activation state should be: activated");
is(plugin1.getTopLevelWindowActivationEventCount(), expectedEventCount, "Window focus event count should be " + expectedEventCount);
is(plugin2.getTopLevelWindowActivationState(), true, "Activation state should be: activated");
is(plugin2.getTopLevelWindowActivationEventCount(), expectedEventCount, "Window focus event count should be " + expectedEventCount);
} catch (e) {
ok(false, "Plugin does not know its initial top-level window activation state!");
}
var fm = SpecialPowers.Services.focus;
waitForFocus(function() {
// Make sure the plugin handled the focus event before checking.
executeSoon(function() {
expectedEventCount++;
is(plugin1.getTopLevelWindowActivationState(), false, "Activation state should be: deactivated");
is(plugin1.getTopLevelWindowActivationEventCount(), expectedEventCount, "Window focus event count should be " + expectedEventCount);
is(plugin2.getTopLevelWindowActivationState(), false, "Activation state should be: deactivated");
is(plugin2.getTopLevelWindowActivationEventCount(), expectedEventCount, "Window focus event count should be " + expectedEventCount);
// Bring our window back to the front and make sure plugins were properly notified.
fm.focusedWindow = window;
waitForFocus(function() {
// Make sure the plugin handled the focus event before checking.
executeSoon(function() {
expectedEventCount++;
is(plugin1.getTopLevelWindowActivationState(), true, "Activation state should be: activated");
is(plugin1.getTopLevelWindowActivationEventCount(), expectedEventCount, "Window focus event count should be " + expectedEventCount);
is(plugin2.getTopLevelWindowActivationState(), true, "Activation state should be: activated");
is(plugin2.getTopLevelWindowActivationEventCount(), expectedEventCount, "Window focus event count should be " + expectedEventCount);
window.opener.testsFinished();
});
}, window);
});
}, window.opener);
// Send our window to the back and make sure plugins were properly notified.
// Calling window.blur() is not allowed.
fm.focusedWindow = window.opener;
}
</script>
</body>
</html>