Bug 920013 - Rewrite test_cocoa_focus.html to use SpecialPowers. r=smichaud

This commit is contained in:
Martijn Wargers 2015-03-20 18:51:17 +01:00
parent 121794fd96
commit 5df22d1a7c
4 changed files with 6 additions and 9 deletions

View File

@ -15,7 +15,6 @@
}
function runTests() {
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var utils = SpecialPowers.DOMWindowUtils;
var scale = utils.screenPixelsPerCSSPixel;
@ -67,7 +66,7 @@
// change plugin focus.
// Blur the window.
window.blur();
SpecialPowers.focus(opener);
is(plugin1.getFocusState(), true, "(2) Plugin should still have focus.");
is(plugin1.getFocusEventCount(), expectedEventCount, "Focus event count should be " + expectedEventCount);
@ -95,7 +94,7 @@
expectedEventCount++;
// Blur the window.
window.blur();
SpecialPowers.focus(opener);
// Take focus from the plugin while the window is blurred.
plugin2.focus();
@ -104,7 +103,7 @@
is(plugin1.getFocusEventCount(), expectedEventCount, "Focus event count should be " + expectedEventCount);
// Focus the window.
window.focus();
SpecialPowers.focus(window);
expectedEventCount++;
is(plugin1.getFocusState(), false, "(6) Plugin should not have focus.");

View File

@ -53,9 +53,7 @@
ok(false, "Plugin does not know its initial top-level window activation state!");
}
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var fm = SpecialPowers.Cc["@mozilla.org/focus-manager;1"].
getService(SpecialPowers.Ci.nsIFocusManager);
var fm = SpecialPowers.Services.focus;
waitForFocus(function() {
// Make sure the plugin handled the focus event before checking.
@ -69,7 +67,6 @@
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.
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
fm.focusedWindow = window;
waitForFocus(function() {
@ -91,7 +88,6 @@
// Send our window to the back and make sure plugins were properly notified.
// Calling window.blur() is not allowed.
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
fm.focusedWindow = window.opener;
}
</script>

View File

@ -3,6 +3,7 @@
<title>NPCocoaEventFocusChanged Tests</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="utils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body onload="runTests()">

View File

@ -3,6 +3,7 @@
<title>NPCocoaEventWindowFocusChanged Tests</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="utils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body onload="runTests()">