Bug 920013 - Rewrite test_cocoa_focus.html to use SpecialPowers. r=smichaud
authorMartijn Wargers <mwargers@mozilla.com>
Fri, 20 Mar 2015 18:51:17 +0100
changeset 235056 b5d1278ee01b0d09ad76e523c324901973f94d8f
parent 235055 0046e9225bbdf76c8d00b81cef1094d964b9614a
child 235057 00cab360dc106f6bf83fb0488c35c5482f4bff85
push id28464
push userkwierso@gmail.com
push dateMon, 23 Mar 2015 23:41:23 +0000
treeherdermozilla-central@e642ae3c0496 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmichaud
bugs920013
milestone39.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 920013 - Rewrite test_cocoa_focus.html to use SpecialPowers. r=smichaud
dom/plugins/test/mochitest/cocoa_focus.html
dom/plugins/test/mochitest/cocoa_window_focus.html
dom/plugins/test/mochitest/test_cocoa_focus.html
dom/plugins/test/mochitest/test_cocoa_window_focus.html
--- a/dom/plugins/test/mochitest/cocoa_focus.html
+++ b/dom/plugins/test/mochitest/cocoa_focus.html
@@ -10,17 +10,16 @@
       window.opener.SimpleTest.is(aLeft, aRight, aMessage);
     }
 
     function ok(aValue, aMessage) {
       window.opener.SimpleTest.ok(aValue, aMessage);
     }
 
     function runTests() {
-      netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
       var utils = SpecialPowers.DOMWindowUtils;
       var scale = utils.screenPixelsPerCSSPixel;
 
       var plugin1 = document.getElementById("plugin1"); // What we're testing.
       var plugin2 = document.getElementById("plugin2"); // Dummy.
 
       var plugin1Bounds = plugin1.getBoundingClientRect();
       var plugin2Bounds = plugin2.getBoundingClientRect();
@@ -62,17 +61,17 @@
 
       is(plugin1.getFocusState(), true, "(1) Plugin should have focus.");
       is(plugin1.getFocusEventCount(), expectedEventCount, "Focus event count should be " + expectedEventCount);
 
       // Make sure window activation state changes don't spontaneously
       // 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);
 
       // Focus the window.
       window.focus();
 
       is(plugin1.getFocusState(), true, "(3) Plugin should still have focus.");
@@ -90,26 +89,26 @@
       // changes that took place while the window was inactive.
 
       // Give the plugin focus (the window is already focused).
       utils.sendNativeMouseEvent(plugin1X * scale, plugin1Y * scale, NSLeftMouseDown, 0, plugin1);
       utils.sendNativeMouseEvent(plugin1X * scale, plugin1Y * scale, NSLeftMouseUp, 0, plugin1);
       expectedEventCount++;
 
       // Blur the window.
-      window.blur();
+      SpecialPowers.focus(opener);
 
       // Take focus from the plugin while the window is blurred.
       plugin2.focus();
 
       is(plugin1.getFocusState(), true, "(5) Plugin should still have focus.");
       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.");
       is(plugin1.getFocusEventCount(), expectedEventCount, "Focus event count should be " + expectedEventCount);
 
       window.opener.testsFinished();
     }
 
--- a/dom/plugins/test/mochitest/cocoa_window_focus.html
+++ b/dom/plugins/test/mochitest/cocoa_window_focus.html
@@ -48,33 +48,30 @@
         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!");
       }
 
-      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.
         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.
-          netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
           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");
@@ -86,14 +83,13 @@
               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.
-      netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
       fm.focusedWindow = window.opener;
     }
   </script>
 </body>
 </html>
--- a/dom/plugins/test/mochitest/test_cocoa_focus.html
+++ b/dom/plugins/test/mochitest/test_cocoa_focus.html
@@ -1,13 +1,14 @@
 <html>
 <head>
   <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()">
   <script class="testbody" type="application/javascript">
     SimpleTest.waitForExplicitFinish();
     setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
     var gOtherWindow;
--- a/dom/plugins/test/mochitest/test_cocoa_window_focus.html
+++ b/dom/plugins/test/mochitest/test_cocoa_window_focus.html
@@ -1,13 +1,14 @@
 <html>
 <head>
   <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()">
   <script class="testbody" type="application/javascript">
     SimpleTest.waitForExplicitFinish();
     setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
     var gOtherWindow;