Back out 8 changesets (bug 931445, bug 1274104, bug 1270386) for frequent e10s APZ mochitest failures starting with test_group_mouseevents.html
authorPhil Ringnalda <philringnalda@gmail.com>
Mon, 23 May 2016 18:42:32 -0700
changeset 327502 589b2826c6c5875717f653d2ed4e0bdf7c2b6b3f
parent 327501 d63acfaf882084a50b75de6d2a421ddd6f1d228b
child 327503 a94bd69a86169a16b818795845e8d75ab5ea2ffd
push idunknown
push userunknown
push dateunknown
bugs931445, 1274104, 1270386
milestone49.0a1
backs out6db35dcc68856908a0f25e3072fec2fd0cd0662c
0c2fc088a46d389d9ebddaa2f11acc44792ca67c
17786141f3ac3b18f8094a967aae6684492a7769
f7c6b58dddc196d9773bb40b9b90074b9cac0bdc
67407d1829a38cbbd9ac20f5cac0e1a5c6c3d8f8
82d2c5404d8433ea7a0edde20523c2e32dcc505b
0921152b9f08cc399440920af67885e9ba715892
f73352ab6f99914b039485fdd9734f639fe1bbca
Back out 8 changesets (bug 931445, bug 1274104, bug 1270386) for frequent e10s APZ mochitest failures starting with test_group_mouseevents.html CLOSED TREE Backed out changeset 6db35dcc6885 (bug 1274104) Backed out changeset 0c2fc088a46d (bug 1274104) Backed out changeset 17786141f3ac (bug 1274104) Backed out changeset f7c6b58dddc1 (bug 1274104) Backed out changeset 67407d1829a3 (bug 1270386) Backed out changeset 82d2c5404d84 (bug 931445) Backed out changeset 0921152b9f08 (bug 931445) Backed out changeset f73352ab6f99 (bug 931445)
dom/events/EventStateManager.cpp
dom/tests/mochitest/pointerlock/file_childIframe.html
dom/tests/mochitest/pointerlock/file_doubleLock.html
dom/tests/mochitest/pointerlock/file_escapeKey.html
dom/tests/mochitest/pointerlock/file_infiniteMovement.html
dom/tests/mochitest/pointerlock/file_locksvgelement.html
dom/tests/mochitest/pointerlock/file_movementXY.html
dom/tests/mochitest/pointerlock/file_nestedFullScreen.html
dom/tests/mochitest/pointerlock/file_pointerLockPref.html
dom/tests/mochitest/pointerlock/file_pointerlock-api.html
dom/tests/mochitest/pointerlock/file_removedFromDOM.html
dom/tests/mochitest/pointerlock/file_retargetMouseEvents.html
dom/tests/mochitest/pointerlock/file_screenClientXYConst.html
dom/tests/mochitest/pointerlock/file_suppressSomeMouseEvents.html
dom/tests/mochitest/pointerlock/file_targetOutOfFocus.html
dom/tests/mochitest/pointerlock/mochitest.ini
dom/tests/mochitest/pointerlock/pointerlock_utils.js
dom/webidl/Document.webidl
dom/webidl/EventHandler.webidl
testing/mochitest/server.js
toolkit/content/tests/widgets/chrome.ini
toolkit/content/tests/widgets/mochitest.ini
toolkit/content/tests/widgets/test_videocontrols.html
--- a/dom/events/EventStateManager.cpp
+++ b/dom/events/EventStateManager.cpp
@@ -4395,19 +4395,16 @@ EventStateManager::SetPointerLock(nsIWid
       dragService->Suppress();
     }
   } else {
     // Unlocking, so return pointer to the original position by firing a
     // synthetic mouse event. We first reset sLastRefPoint to its
     // pre-pointerlock position, so that the synthetic mouse event reports
     // no movement.
     sLastRefPoint = mPreLockPoint;
-    // Reset SynthCenteringPoint to invalid so that next time we start
-    // locking pointer, it has its initial value.
-    sSynthCenteringPoint = kInvalidRefPoint;
     if (aWidget) {
       aWidget->SynthesizeNativeMouseMove(
         mPreLockPoint + aWidget->WidgetToScreenOffset(), nullptr);
     }
 
     // Don't retarget events to this element any more.
     nsIPresShell::SetCapturingContent(nullptr, CAPTURE_POINTERLOCK);
 
--- a/dom/tests/mochitest/pointerlock/file_childIframe.html
+++ b/dom/tests/mochitest/pointerlock/file_childIframe.html
@@ -103,32 +103,39 @@ https://bugzilla.mozilla.org/show_bug.cg
         synthesizeMouseAtCenter(childDiv, {type: "mousemove"}, window);
       };
 
       var secondMoveChild = function (e) {
         secondMove.mozMovementX = e.mozMovementX;
         secondMove.mozMovementY = e.mozMovementY;
         parent.removeEventListener("mousemove", secondMoveChild);
 
-        addFullscreenChangeContinuation("exit", function() {
-          runTests();
-          SimpleTest.finish();
-        });
         document.exitFullscreen();
       };
 
       document.addEventListener("mozpointerlockchange", function () {
         if (document.mozPointerLockElement === parent) {
           parent.addEventListener("mousemove", firstMoveChild);
           synthesizeMouseAtCenter(childDiv, {type: "mousemove"}, window);
         }
       }, false);
 
+      document.addEventListener("mozpointerlockerror", function () {
+        document.exitFullscreen();
+      }, false);
+
+      document.addEventListener("fullscreenchange", function (e)  {
+        if (document.fullscreenElement === parent) {
+          parent.mozRequestPointerLock();
+        }
+        else {
+          runTests();
+          SimpleTest.finish();
+        }
+      }, false);
+
       function start() {
-        addFullscreenChangeContinuation("enter", function() {
-          parent.mozRequestPointerLock();
-        });
         parent.requestFullscreen();
       }
     </script>
   </pre>
 </body>
 </html>
--- a/dom/tests/mochitest/pointerlock/file_doubleLock.html
+++ b/dom/tests/mochitest/pointerlock/file_doubleLock.html
@@ -35,32 +35,35 @@ https://bugzilla.mozilla.org/show_bug.cg
       function runTests () {
         is(numberOfLocks, 2, "Requesting pointer lock on a locked element " +
           "should dispatch mozpointerlockchange event");
       }
 
       document.addEventListener("mozpointerlockchange", function (e) {
         if (document.mozPointerLockElement === div) {
           if (numberOfLocks === 2) {
-            addFullscreenChangeContinuation("exit", function() {
-              runTests();
-              SimpleTest.finish();
-            });
             document.exitFullscreen();
           }
           else {
             numberOfLocks++;
             div.mozRequestPointerLock();
           }
         }
       }, false);
 
+      document.addEventListener("fullscreenchange", function (e) {
+        if (document.fullscreenElement === div) {
+          div.mozRequestPointerLock();
+        }
+        else {
+          runTests();
+          SimpleTest.finish();
+        }
+      }, false);
+
       function start() {
         console.log('started');
-        addFullscreenChangeContinuation("enter", function() {
-          div.mozRequestPointerLock();
-        });
         div.requestFullscreen();
       }
     </script>
   </pre>
 </body>
 </html>
--- a/dom/tests/mochitest/pointerlock/file_escapeKey.html
+++ b/dom/tests/mochitest/pointerlock/file_escapeKey.html
@@ -24,47 +24,49 @@
        */
 
       SimpleTest.waitForExplicitFinish();
 
       var div = document.getElementById("div")
         , pointerUnLocked = false;
 
       function start() {
-        addFullscreenChangeContinuation("enter", enteredFullscreen);
+        document.addEventListener("fullscreenchange", enteredFullscreen);
         div.requestFullscreen();
       }
 
       function enteredFullscreen(e) {
+        document.removeEventListener("fullscreenchange", enteredFullscreen);
         is(document.fullscreenElement, div, "Element #div should entered fullscreen");
         ok(!document.mozPointerLockElement, "Pointer shouldn't have been locked");
         document.addEventListener("mozpointerlockchange", lockedPointer);
         div.mozRequestPointerLock();
       }
 
       function lockedPointer(e) {
         document.removeEventListener("mozpointerlockchange", lockedPointer);
         is(document.mozPointerLockElement, div, "Pointer should have been locked on #div");
         document.addEventListener("mozpointerlockchange", unlockedPointer);
-        addFullscreenChangeContinuation("exit", leavedFullscreen);
+        document.addEventListener("fullscreenchange", leavedFullscreen);
         SimpleTest.executeSoon(() => synthesizeKey("VK_ESCAPE", {}));
       }
 
       var pointerUnlocked = false;
       var exitedFullscreen = false;
 
       function unlockedPointer() {
         document.removeEventListener("mozpointerlockchange", unlockedPointer);
         ok(!pointerUnlocked, "Shouldn't have unlocked pointer before");
         ok(!document.mozPointerLockElement, "Pointer should have been unlocked now");
         pointerUnlocked = true;
         finishTest();
       }
 
       function leavedFullscreen() {
+        document.removeEventListener("fullscreenchange", leavedFullscreen);
         ok(!exitedFullscreen, "Shouldn't have exited fullscreen before");
         ok(!document.fullscreenElement, "Should have exited fullscreen now");
         exitedFullscreen = true;
         finishTest();
       }
 
       function finishTest() {
         if (pointerUnlocked && exitedFullscreen) {
--- a/dom/tests/mochitest/pointerlock/file_infiniteMovement.html
+++ b/dom/tests/mochitest/pointerlock/file_infiniteMovement.html
@@ -60,21 +60,16 @@ https://bugzilla.mozilla.org/show_bug.cg
         }
 
         var secondMoveListener = function (e) {
           info("Got second mousemove");
           totalMovementX = divCenterWidth + ((divCenterWidth / 2) * 3);
           totalMovementY = divCenterHeight + ((divCenterHeight / 2) * 3);
 
           div.removeEventListener("mousemove", secondMoveListener, false);
-          addFullscreenChangeContinuation("exit", function() {
-            info("Got fullscreenchange for exiting");
-            runTests();
-            SimpleTest.finish();
-          });
           document.exitFullscreen();
         }
 
         document.addEventListener("mozpointerlockchange", function (e) {
           if (document.mozPointerLockElement === div) {
             info("Got mozpointerlockchange for entering");
             div.addEventListener("mousemove", firstMoveListener, false);
 
@@ -84,20 +79,28 @@ https://bugzilla.mozilla.org/show_bug.cg
             synthesizeMouse(div, divCenterWidth, divCenterHeight, {
               type: "mousemove"
             }, window);
           } else {
             info("Got mozpointerlockchange for exiting");
           }
         }, false);
 
+        document.addEventListener("fullscreenchange", function() {
+          if (document.fullscreenElement === div) {
+            info("Got fullscreenchange for entering");
+            div.mozRequestPointerLock();
+          }
+          else {
+            info("Got fullscreenchange for exiting");
+            runTests();
+            SimpleTest.finish();
+          }
+        }, false);
+
         function start() {
           info("Requesting fullscreen on parent");
-          addFullscreenChangeContinuation("enter", function() {
-            info("Got fullscreenchange for entering");
-            div.mozRequestPointerLock();
-          });
           div.requestFullscreen();
         }
       </script>
     </pre>
   </body>
 </html>
--- a/dom/tests/mochitest/pointerlock/file_locksvgelement.html
+++ b/dom/tests/mochitest/pointerlock/file_locksvgelement.html
@@ -36,27 +36,29 @@
           elemWasLocked = false;
 
         document.addEventListener("mozpointerlockchange", function (e) {
           if (document.fullscreenElement &&
               document.mozPointerLockElement === elem) {
             elemWasLocked = true;
             document.mozExitPointerLock();
           } else {
-            addFullscreenChangeContinuation("exit", function() {
-              ok(elemWasLocked, "Expected SVG elem to become locked.");
-              SimpleTest.finish();
-            });
             document.exitFullscreen();
           }
         }, false);
 
+        document.addEventListener("fullscreenchange", function (e) {
+          if (document.fullscreenElement === elem) {
+            elem.mozRequestPointerLock();
+          } else {
+            ok(elemWasLocked, "Expected SVG elem to become locked.");
+            SimpleTest.finish();
+          }
+        }, false);
+
         function start() {
           elem = document.getElementById("svg-elem");
-          addFullscreenChangeContinuation("enter", function() {
-            elem.mozRequestPointerLock();
-          });
           elem.requestFullscreen();
         }
       </script>
     </pre>
   </body>
 </html>
--- a/dom/tests/mochitest/pointerlock/file_movementXY.html
+++ b/dom/tests/mochitest/pointerlock/file_movementXY.html
@@ -78,29 +78,43 @@ https://bugzilla.mozilla.org/show_bug.cg
         var moveMouseAgain = function(e) {
           info("Got mouse move again");
           secondMove.screenX = e.screenX;
           secondMove.screenY = e.screenY;
           secondMove.mozMovementX = e.mozMovementX;
           secondMove.mozMovementY = e.mozMovementY;
 
           div.removeEventListener("mousemove", moveMouseAgain, false);
-          addFullscreenChangeContinuation("exit", function() {
-            info("Got fullscreenchange for exiting");
-            runTests();
-            SimpleTest.finish();
-          });
           document.exitFullscreen();
         };
 
+        function fullscreenchange() {
+          if (document.fullscreenElement === div) {
+            info("Got fullscreenchange for entering");
+            var screenX = window.screenX;
+            var screenY = window.screenY;
+            if (screenX != 0 || screenY != 0) {
+              todo(screenX == 0 && screenY == 0,
+                "We should only receive fullscreenchange once we've finished fullscreen transition");
+              setTimeout(fullscreenchange, 250);
+              return;
+            } 
+            info("Finish waiting for fullscreenchange");
+            div.addEventListener("mousemove", moveMouse, false);
+            synthesizeMouseAtCenter(div, {type: "mousemove"}, window);
+          }
+          else {
+            info("Got fullscreenchange for exiting");
+            runTests();
+            SimpleTest.finish();
+          }
+        }
+        
+        document.addEventListener("fullscreenchange", fullscreenchange, false);
+
         function start() {
           info("Requesting fullscreen on parent");
-          addFullscreenChangeContinuation("enter", function() {
-            info("Got fullscreenchange for entering");
-            div.addEventListener("mousemove", moveMouse, false);
-            synthesizeMouseAtCenter(div, {type: "mousemove"}, window);
-          });
           div.requestFullscreen();
         }
       </script>
     </pre>
   </body>
 </html>
--- a/dom/tests/mochitest/pointerlock/file_nestedFullScreen.html
+++ b/dom/tests/mochitest/pointerlock/file_nestedFullScreen.html
@@ -44,33 +44,37 @@
         isnot(pointerLocked, true, "Requesting fullscreen on " +
           "childDiv while parentDiv still in fullscreen should " +
           "unlock the pointer");
       }
 
       document.addEventListener("mozpointerlockchange", function (e) {
         if (document.mozPointerLockElement === parentDiv) {
           parentDivLocked = true;
-          addFullscreenChangeContinuation("enter", function() {
-            pointerLocked = !!document.mozPointerLockElement;
-            addFullscreenChangeContinuation("exit", function() {
-              addFullscreenChangeContinuation("exit", function() {
-                runTests();
-                SimpleTest.finish();
-              });
-              document.exitFullscreen();
-            });
-            document.exitFullscreen();
-          });
           childDiv.requestFullscreen();
         }
       }, false);
 
+      document.addEventListener("fullscreenchange", function() {
+        if (document.fullscreenElement === parentDiv) {
+          if (parentDivFullScreen === true) {
+            document.exitFullscreen();
+          } else {
+            parentDivFullScreen = true;
+            parentDiv.mozRequestPointerLock();
+          }
+        }
+        else if (document.fullscreenElement === childDiv) {
+          pointerLocked = !!document.mozPointerLockElement;
+          document.exitFullscreen();
+        }
+        else {
+          runTests();
+          SimpleTest.finish();
+        }
+      }, false);
+
       function start() {
-        addFullscreenChangeContinuation("enter", function() {
-          parentDivFullScreen = true;
-          parentDiv.mozRequestPointerLock();
-        });
         parentDiv.requestFullscreen();
       }
     </script>
   </body>
 </html>
--- a/dom/tests/mochitest/pointerlock/file_pointerLockPref.html
+++ b/dom/tests/mochitest/pointerlock/file_pointerLockPref.html
@@ -47,29 +47,32 @@
             SpecialPowers.setBoolPref("full-screen-api.pointer-lock.enabled",
                                       false );
             div.mozRequestPointerLock();
           }
         }, false);
 
         document.addEventListener("mozpointerlockerror", function (e) {
           prefDisabled = true;
-          addFullscreenChangeContinuation("exit", function() {
+          document.exitFullscreen();
+        }, false);
+
+        document.addEventListener("fullscreenchange", function (e) {
+          if (document.fullscreenElement === div) {
+            SpecialPowers.setBoolPref("full-screen-api.pointer-lock.enabled",
+                                      true );
+            div.mozRequestPointerLock();
+          }
+          else {
             SpecialPowers.setBoolPref("full-screen-api.pointer-lock.enabled",
                                        true );
             runTests();
             SimpleTest.finish();
-          });
-          document.exitFullscreen();
+          }
         }, false);
 
         function start() {
-          addFullscreenChangeContinuation("enter", function() {
-            SpecialPowers.setBoolPref("full-screen-api.pointer-lock.enabled",
-                                      true );
-            div.mozRequestPointerLock();
-          });
           div.requestFullscreen();
         }
       </script>
     </pre>
   </body>
 </html>
--- a/dom/tests/mochitest/pointerlock/file_pointerlock-api.html
+++ b/dom/tests/mochitest/pointerlock/file_pointerlock-api.html
@@ -74,31 +74,33 @@
                           { type: "contextmenu", button: 2 },
                           window);
 
           document.addEventListener("mousemove", mouseMoveHandler, false);
           synthesizeMouseAtCenter(div, {type: "mousemove"}, window);
         } else {
           info("Got mozpointerlockchange for exiting");
           pointerUnlocked = true;
-          addFullscreenChangeContinuation("exit", function() {
-            info("Got fullscreenchange for exiting");
-            runTests();
-            SimpleTest.finish();
-          });
           document.exitFullscreen();
         }
       }, false);
 
+      document.addEventListener("fullscreenchange", function(e) {
+        if (document.fullscreenElement === div) {
+          info("Got fullscreenchange for entering");
+          hasRequestPointerLock = "mozRequestPointerLock" in div;
+          div.mozRequestPointerLock();
+        } else {
+          info("Got fullscreenchange for exiting");
+          runTests();
+          SimpleTest.finish();
+        }
+      }, false);
+
       function start() {
         div = document.getElementById("div");
         info("Requesting fullscreen on parent");
-        addFullscreenChangeContinuation("enter", function() {
-          info("Got fullscreenchange for entering");
-          hasRequestPointerLock = "mozRequestPointerLock" in div;
-          div.mozRequestPointerLock();
-        });
         div.requestFullscreen();
       }
     </script>
   </pre>
 </body>
 </html>
--- a/dom/tests/mochitest/pointerlock/file_removedFromDOM.html
+++ b/dom/tests/mochitest/pointerlock/file_removedFromDOM.html
@@ -46,17 +46,17 @@ function checkPointerLockElement(elem) {
     is(document.mozPointerLockElement, elem,
        `#${elem.id} should have locked the pointer`);
   } else {
     ok(!document.mozPointerLockElement, "Pointer should have been unlocked");
   }
 }
 
 function start() {
-  addFullscreenChangeContinuation("enter", enteredFullscreen);
+  listenOneDocEvent("fullscreenchange", enteredFullscreen);
   document.documentElement.requestFullscreen();
 }
 
 function enteredFullscreen() {
   is(document.fullscreenElement, document.documentElement,
      "Root element should have entered fullscreen");
   listenOneDocEvent("mozpointerlockchange", lockedPointerOnDiv);
   div.mozRequestPointerLock();
@@ -77,17 +77,17 @@ function unlockedPointerFromDiv() {
 function lockedPointerOnInner() {
   checkPointerLockElement(inner);
   listenOneDocEvent("mozpointerlockchange", unlockedPointerFromInner);
   document.body.removeChild(outer);
 }
 
 function unlockedPointerFromInner() {
   checkPointerLockElement(null);
-  addFullscreenChangeContinuation("exit", exitedFullscreen);
+  listenOneDocEvent("fullscreenchange", exitedFullscreen);
   document.exitFullscreen();
 }
 
 function exitedFullscreen() {
   SimpleTest.finish();
 }
 </script>
 </pre>
--- a/dom/tests/mochitest/pointerlock/file_retargetMouseEvents.html
+++ b/dom/tests/mochitest/pointerlock/file_retargetMouseEvents.html
@@ -166,21 +166,16 @@ https://bugzilla.mozilla.org/show_bug.cg
 
       var parentMoveTest = function (e) {
         info("Got parent mousemove");
         parentStats.mouseMove = true;
         parent.removeEventListener("mousemove", parentMoveTest);
         child.removeEventListener("mousemove", childMoveTest);
         SimpleTest.executeSoon(function () {
           info("Exit fullscreen");
-          addFullscreenChangeContinuation("exit", function() {
-            info("Got fullscreenchange for exiting");
-            runTests();
-            SimpleTest.finish();
-          });
           document.exitFullscreen();
         });
       }
 
       document.addEventListener("mozpointerlockchange", function (e) {
         if (document.mozPointerLockElement === parent) {
           info("Got mozpointerlockchange for entering");
           parent.addEventListener("mousemove", startMouseTests);
@@ -188,20 +183,27 @@ https://bugzilla.mozilla.org/show_bug.cg
           SimpleTest.executeSoon(function () {
             synthesizeMouseAtCenter(parent, {type: "mousemove"}, window);
           });
         } else {
           info("Got mozpointerlockchange for exiting");
         }
       }, false);
 
+      document.addEventListener("fullscreenchange", function (e)  {
+        if (document.fullscreenElement === parent) {
+          info("Got fullscreenchange for entering");
+          parent.mozRequestPointerLock();
+        } else {
+          info("Got fullscreenchange for exiting");
+          runTests();
+          SimpleTest.finish();
+        }
+      }, false);
+
       function start() {
         info("Requesting fullscreen on parent");
-        addFullscreenChangeContinuation("enter", function() {
-          info("Got fullscreenchange for entering");
-          parent.mozRequestPointerLock();
-        });
         parent.requestFullscreen();
       }
     </script>
   </pre>
 </body>
 </html>
--- a/dom/tests/mochitest/pointerlock/file_screenClientXYConst.html
+++ b/dom/tests/mochitest/pointerlock/file_screenClientXYConst.html
@@ -77,45 +77,58 @@ https://bugzilla.mozilla.org/show_bug.cg
         isLocked = !!document.mozPointerLockElement;
         lockedCoords = {
           screenX: e.screenX,
           screenY: e.screenY,
           clientX: e.clientX,
           clientY: e.clientY
         };
 
-        addFullscreenChangeContinuation("exit", function() {
-          info("Got fullscreenchange for exiting");
-          runTests();
-          SimpleTest.finish();
-        });
         document.exitFullscreen();
       }
 
       document.addEventListener("mozpointerlockchange", function (e) {
         if (document.mozPointerLockElement === div) {
           info("Got mozpointerlockchange for entering");
           div.removeEventListener("mousemove", moveUnlocked, false);
           div.addEventListener("mousemove", moveLocked, false);
           divRect = div.getBoundingClientRect();
           synthesizeNativeMouseMove(div, (divRect.width / 4) * 3,
                                     (divRect.height / 4) * 3);
         } else {
           info("Got mozpointerlockchange for exiting");
         }
       }, false);
 
-      function start() {
-        div = document.getElementById("div");
-        info("Requesting fullscreen on parent");
-        addFullscreenChangeContinuation("enter", function() {
+      function fullscreenchange() {
+        var screenX = window.screenX;
+        var screenY = window.screenY;
+        if (document.fullscreenElement === div) {
           info("Got fullscreenchange for entering");
+          if (screenX != 0 || screenY != 0) {
+            todo(screenX == 0 && screenY == 0,
+              "We should only receive fullscreenchange once we've finished fullscreen transition " +
+              "window.screenX=" + screenX + " window.screenY=" + screenY);
+            setTimeout(fullscreenchange, 250);
+            return;
+          }
+          info("Finish waiting for fullscreenchange");
           synthesizeNativeMouseMove(div, 0, 0, () => {
             div.addEventListener("mousemove", moveUnlocked, false);
             divRect = div.getBoundingClientRect();
             synthesizeNativeMouseMove(div, divRect.width / 2, divRect.height / 2);
           });
-        });
+        } else {
+          info("Got fullscreenchange for exiting");
+          runTests();
+          SimpleTest.finish();
+        }
+      }
+      document.addEventListener("fullscreenchange", fullscreenchange, false);
+
+      function start() {
+        div = document.getElementById("div");
+        info("Requesting fullscreen on parent");
         div.requestFullscreen();
       }
   </script>
 </body>
 </html>
--- a/dom/tests/mochitest/pointerlock/file_suppressSomeMouseEvents.html
+++ b/dom/tests/mochitest/pointerlock/file_suppressSomeMouseEvents.html
@@ -132,27 +132,30 @@ https://bugzilla.mozilla.org/show_bug.cg
       }
 
       document.addEventListener("mozpointerlockchange", function (e) {
         if (document.mozPointerLockElement === parent) {
           addEventListeners();
           synthesizeMouseAtCenter(child, { type: "mousemove" }, window);
         }
         else {
-          addFullscreenChangeContinuation("exit", function() {
-            runTests();
-            SimpleTest.finish();
-          });
           document.exitFullscreen();
         }
       }, false);
 
+      document.addEventListener("fullscreenchange", function() {
+        if (document.fullscreenElement === parent) {
+          parent.mozRequestPointerLock();
+        }
+        else {
+          runTests();
+          SimpleTest.finish();
+        }
+      }, false);
+
       function start() {
         parent = document.getElementById("parent");
         child = document.getElementById("child");
-        addFullscreenChangeContinuation("enter", function() {
-          parent.mozRequestPointerLock();
-        });
         parent.requestFullscreen();
       }
   </script>
 </body>
 </html>
--- a/dom/tests/mochitest/pointerlock/file_targetOutOfFocus.html
+++ b/dom/tests/mochitest/pointerlock/file_targetOutOfFocus.html
@@ -43,26 +43,28 @@
 
         input.addEventListener("focus", function() {
           div.mozRequestPointerLock();
         }, false);
 
         document.addEventListener("mozpointerlockchange", function (e) {
           if (document.mozPointerLockElement === div) {
             divPointerLock = true;
-            addFullscreenChangeContinuation("exit", function() {
-              runTests();
-              SimpleTest.finish();
-            });
             document.exitFullscreen();
           }
         }, false);
 
+        document.addEventListener("fullscreenchange", function() {
+          if (document.fullscreenElement === div) {
+            input.focus();
+          } else {
+            runTests();
+            SimpleTest.finish();
+          }
+        }, false);
+
         function start() {
-          addFullscreenChangeContinuation("enter", function() {
-            input.focus();
-          });
           div.requestFullscreen();
         }
       </script>
     </pre>
   </body>
 </html>
--- a/dom/tests/mochitest/pointerlock/mochitest.ini
+++ b/dom/tests/mochitest/pointerlock/mochitest.ini
@@ -17,9 +17,9 @@ support-files =
   file_screenClientXYConst.html
   file_suppressSomeMouseEvents.html
   file_locksvgelement.html
   file_allowPointerLockSandboxFlag.html
   iframe_differentDOM.html
 
 [test_pointerlock-api.html]
 tags = fullscreen
-skip-if = buildapp == 'b2g' || toolkit == 'android' || os == 'win' # B2G - window.open focus issues using fullscreen. Win: Bug 931445
+skip-if = buildapp == 'b2g' || toolkit == 'android' || os == 'linux' || os == 'win' # B2G - window.open focus issues using fullscreen. Linux/Win: Bug 931445
--- a/dom/tests/mochitest/pointerlock/pointerlock_utils.js
+++ b/dom/tests/mochitest/pointerlock/pointerlock_utils.js
@@ -1,120 +1,66 @@
-// Get test filename for page being run in popup so errors are more useful
-var testName = location.pathname.split('/').pop();
+const isWinXP = navigator.userAgent.indexOf("Windows NT 5.1") != -1;
+const isOSXLion = navigator.userAgent.indexOf("Mac OS X 10.7") != -1;
 
-// Wrap test functions and pass to parent window
-window.ok = function(a, msg) {
-  opener.ok(a, testName + ": " + msg);
-};
+// If we're running in a child window, shim things so it works the same
+// as if we were running stand-alone.
+if (window.opener) {
+  // Get test filename for page being run in popup so errors are more useful
+  var testName = location.pathname.split('/').pop();
+
+  // Wrap test functions and pass to parent window
+  window.ok = function(a, msg) {
+    opener.ok(a, testName + ": " + msg);
+  };
 
-window.is = function(a, b, msg) {
-  opener.is(a, b, testName + ": " + msg);
-};
+  window.is = function(a, b, msg) {
+    opener.is(a, b, testName + ": " + msg);
+  };
+
+  window.isnot = function(a, b, msg) {
+    opener.isnot(a, b, testName + ": " + msg);
+  };
 
-window.isnot = function(a, b, msg) {
-  opener.isnot(a, b, testName + ": " + msg);
-};
+  window.todo = function(a, msg) {
+    opener.todo(a, testName + ": " + msg);
+  };
 
-window.todo = function(a, msg) {
-  opener.todo(a, testName + ": " + msg);
-};
+  window.todo_is = function(a, b, msg) {
+    opener.todo_is(a, b, testName + ": " + msg);
+  };
 
-window.todo_is = function(a, b, msg) {
-  opener.todo_is(a, b, testName + ": " + msg);
-};
+  window.todo_isnot = function(a, b, msg) {
+    opener.todo_isnot(a, b, testName + ": " + msg);
+  };
 
-window.todo_isnot = function(a, b, msg) {
-  opener.todo_isnot(a, b, testName + ": " + msg);
-};
+  window.info = function(msg) {
+    opener.info(testName + ": " + msg);
+  };
 
-window.info = function(msg) {
-  opener.info(testName + ": " + msg);
-};
+  // Override bits of SimpleTest so test files work stand-alone
+  var SimpleTest = SimpleTest || {};
+
+  SimpleTest.waitForExplicitFinish = function() {
+    dump("[POINTERLOCK] Starting " + testName+ "\n");
+  };
 
-// Override bits of SimpleTest so test files work stand-alone
-var SimpleTest = SimpleTest || {};
+  SimpleTest.finish = function () {
+    dump("[POINTERLOCK] Finishing " + testName+ "\n");
+    opener.nextTest();
+  };
+} else {
+  // If we're not running in a child window, prefs need to get flipped here,
+  // otherwise it was already done in the test runner parent.
 
-SimpleTest.waitForExplicitFinish = function() {
-  dump("[POINTERLOCK] Starting " + testName+ "\n");
-};
+  // Ensure the full-screen api is enabled, and will be disabled on test exit.
+  SpecialPowers.setBoolPref("full-screen-api.enabled", true);
 
-SimpleTest.finish = function () {
-  dump("[POINTERLOCK] Finishing " + testName+ "\n");
-  opener.nextTest();
-};
+  // Disable the requirement for trusted contexts only, so the tests are easier to write.
+  SpecialPowers.setBoolPref("full-screen-api.allow-trusted-requests-only", false);
+}
 
 addLoadEvent(function() {
   if (typeof start !== 'undefined') {
     SimpleTest.waitForFocus(start);
   }
 });
 
-// Returns true if the window occupies the entire screen.
-// Note this only returns true once the transition from normal to
-// fullscreen mode is complete.
-function inFullscreenMode(win) {
-  return win.innerWidth == win.screen.width &&
-         win.innerHeight == win.screen.height;
-}
-
-// Returns true if the window is in normal mode, i.e. non fullscreen mode.
-// Note this only returns true once the transition from fullscreen back to
-// normal mode is complete.
-function inNormalMode(win) {
-  return win.innerWidth == win.normalSize.w &&
-         win.innerHeight == win.normalSize.h;
-}
-
-// Adds a listener that will be called once a fullscreen transition
-// is complete. When type==='enter', callback is called when we've
-// received a fullscreenchange event, and the fullscreen transition is
-// complete. When type==='exit', callback is called when we've
-// received a fullscreenchange event and the window dimensions match
-// the window dimensions when the window opened (so don't resize the
-// window while running your test!). inDoc is the document which
-// the listeners are added on, if absent, the listeners are added to
-// the current document.
-function addFullscreenChangeContinuation(type, callback, inDoc) {
-  var doc = inDoc || document;
-  var topWin = doc.defaultView.top;
-  // Remember the window size in non-fullscreen mode.
-  if (!topWin.normalSize) {
-    topWin.normalSize = {
-      w: window.innerWidth,
-      h: window.innerHeight
-    };
-  }
-  function checkCondition() {
-    if (type == "enter") {
-      return inFullscreenMode(topWin);
-    } else if (type == "exit") {
-      // If we just revert the state to a previous fullscreen state,
-      // the window won't back to the normal mode. Hence we check
-      // fullscreenElement first here. Note that we need to check
-      // the fullscreen element of the outmost document here instead
-      // of the current one.
-      return topWin.document.fullscreenElement || inNormalMode(topWin);
-    } else {
-      throw "'type' must be either 'enter', or 'exit'.";
-    }
-  }
-  function invokeCallback(event) {
-    // Use async call after a paint to workaround unfinished fullscreen
-    // change even when the window size has changed on Linux.
-    requestAnimationFrame(() => setTimeout(() => callback(event), 0), 0);
-  }
-  function onFullscreenChange(event) {
-    doc.removeEventListener("fullscreenchange", onFullscreenChange, false);
-    if (checkCondition()) {
-      invokeCallback(event);
-      return;
-    }
-    function onResize() {
-      if (checkCondition()) {
-        topWin.removeEventListener("resize", onResize, false);
-        invokeCallback(event);
-      }
-    }
-    topWin.addEventListener("resize", onResize, false);
-  }
-  doc.addEventListener("fullscreenchange", onFullscreenChange, false);
-}
--- a/dom/webidl/Document.webidl
+++ b/dom/webidl/Document.webidl
@@ -235,22 +235,16 @@ partial interface Document {
   readonly attribute Element? fullscreenElement;
   [BinaryName="fullscreenElement", Deprecated="PrefixedFullscreenAPI"]
   readonly attribute Element? mozFullScreenElement;
 
   [Func="nsDocument::IsUnprefixedFullscreenEnabled"]
   void exitFullscreen();
   [BinaryName="exitFullscreen", Deprecated="PrefixedFullscreenAPI"]
   void mozCancelFullScreen();
-
-  // Events handlers
-  [Func="nsDocument::IsUnprefixedFullscreenEnabled"]
-  attribute EventHandler onfullscreenchange;
-  [Func="nsDocument::IsUnprefixedFullscreenEnabled"]
-  attribute EventHandler onfullscreenerror;
 };
 
 // http://dvcs.w3.org/hg/pointerlock/raw-file/default/index.html#extensions-to-the-document-interface
 partial interface Document {
     readonly attribute Element? mozPointerLockElement;
     void mozExitPointerLock ();
 };
 
--- a/dom/webidl/EventHandler.webidl
+++ b/dom/webidl/EventHandler.webidl
@@ -112,20 +112,25 @@ interface GlobalEventHandlers {
            attribute EventHandler onpointerenter;
            [Pref="dom.w3c_pointer_events.enabled"]
            attribute EventHandler onpointerleave;
            [Pref="dom.w3c_pointer_events.enabled"]
            attribute EventHandler ongotpointercapture;
            [Pref="dom.w3c_pointer_events.enabled"]
            attribute EventHandler onlostpointercapture;
 
-           // Mozilla-specific handlers. Unprefixed handlers live in
-           // Document rather than here.
+           // Fullscreen events handlers
+           [Func="nsDocument::IsUnprefixedFullscreenEnabled"]
+           attribute EventHandler onfullscreenchange;
+           [Func="nsDocument::IsUnprefixedFullscreenEnabled"]
+           attribute EventHandler onfullscreenerror;
            attribute EventHandler onmozfullscreenchange;
            attribute EventHandler onmozfullscreenerror;
+
+           // Mozilla-specific handlers
            attribute EventHandler onmozpointerlockchange;
            attribute EventHandler onmozpointerlockerror;
 };
 
 [NoInterfaceObject]
 interface WindowEventHandlers {
            attribute EventHandler onafterprint;
            attribute EventHandler onbeforeprint;
--- a/testing/mochitest/server.js
+++ b/testing/mochitest/server.js
@@ -707,17 +707,17 @@ function testListing(metadata, response)
           DIV({class: "clear"}),
           DIV({id: "current-test"},
             B("Currently Executing: ",
               SPAN({id: "current-test-path"}, "_")
             )
           ),
           DIV({class: "clear"}),
           DIV({class: "frameholder"},
-            IFRAME({scrolling: "no", id: "testframe", "allowfullscreen": true})
+            IFRAME({scrolling: "no", id: "testframe"})
           ),
           DIV({class: "clear"}),
           DIV({class: "toggle"},
             A({href: "#", id: "toggleNonTests"}, "Show Non-Tests"),
             BR()
           ),
 
           (
--- a/toolkit/content/tests/widgets/chrome.ini
+++ b/toolkit/content/tests/widgets/chrome.ini
@@ -1,18 +1,21 @@
 [DEFAULT]
 skip-if = buildapp == 'b2g' || os == 'android'
 support-files =
   tree_shared.js
   popup_shared.js
   window_menubar.xul
+  seek_with_sound.ogg
 
 [test_contextmenu_nested.xul]
 skip-if = os == 'linux' # Bug 1116215
 [test_contextmenu_menugroup.xul]
 skip-if = os == 'linux' # Bug 1115088
 [test_editor_currentURI.xul]
 [test_menubar.xul]
 skip-if = os == 'mac'
 [test_popupanchor.xul]
 skip-if = os == 'android'
 [test_popupreflows.xul]
 [test_tree_column_reorder.xul]
+skip-if = toolkit == 'android'
+[test_videocontrols.html]
--- a/toolkit/content/tests/widgets/mochitest.ini
+++ b/toolkit/content/tests/widgets/mochitest.ini
@@ -19,18 +19,16 @@ support-files =
   videocontrols_direction-2d.html
   videocontrols_direction-2e.html
   videocontrols_direction_test.js
   videomask.css
 
 [test_audiocontrols_dimensions.html]
 skip-if = toolkit == 'android'
 [test_mousecapture_area.html]
-[test_videocontrols.html]
-tags = fullscreen
 skip-if = toolkit == 'android' #TIMED_OUT
 [test_videocontrols_audio.html]
 [test_videocontrols_audio_direction.html]
 [test_videocontrols_jsdisabled.html]
 skip-if = toolkit == 'android' # bug 1272646
 [test_videocontrols_standalone.html]
 skip-if = toolkit == 'android' # bug 1075573
 [test_videocontrols_video_direction.html]
--- a/toolkit/content/tests/widgets/test_videocontrols.html
+++ b/toolkit/content/tests/widgets/test_videocontrols.html
@@ -1,15 +1,15 @@
 <!DOCTYPE HTML>
 <html>
 <head>
   <title>Video controls test</title>
-  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
+  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 </head>
 <body>
 <p id="display"></p>
 
 <div id="content">
   <video width="320" height="240" id="video" controls mozNoDynamicControls preload="auto"></video>
 </div>
 
@@ -24,18 +24,18 @@ const videoWidth = 320;
 const videoHeight = 240;
 const videoDuration = 3.8329999446868896;
 
 const playButtonWidth = 28;
 const playButtonHeight = 28;
 const muteButtonWidth = 33;
 const muteButtonHeight = 28;
 const durationWidth = 34;
-const fullscreenButtonWidth = 28;
-const fullscreenButtonHeight = 28;
+const fullscreenButtonWidth = document.fullscreenEnabled ? 28 : 0;
+const fullscreenButtonHeight = document.fullscreenEnabled ? 28 : 0;
 const volumeSliderWidth = 32;
 const scrubberWidth = videoWidth - playButtonWidth - durationWidth - muteButtonWidth - volumeSliderWidth - fullscreenButtonWidth;
 const scrubberHeight = 28;
 
 // Play button is on the bottom-left
 const playButtonCenterX = 0 + Math.round(playButtonWidth / 2);
 const playButtonCenterY = videoHeight - Math.round(playButtonHeight / 2);
 // Mute button is on the bottom-right before the full screen button and volume slider
@@ -47,24 +47,22 @@ const fullscreenButtonCenterY = videoHei
 // Scrubber bar is between the play and mute buttons. We don't need it's
 // X center, just the offset of its box.
 const scrubberOffsetX = 0 + playButtonWidth;
 const scrubberCenterY = videoHeight - Math.round(scrubberHeight / 2);
 
 var testnum = 1;
 var video = document.getElementById("video");
 
-const domUtil = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
-                             .getService(SpecialPowers.Ci.inIDOMUtils);
-
 function getButtonByAttribute(aName, aValue) {
+  var domUtil = Components.classes["@mozilla.org/inspector/dom-utils;1"]
+                          .getService(Components.interfaces.inIDOMUtils);
   var kids = domUtil.getChildrenForNode(video, true);
   var videocontrols = kids[1];
-  return SpecialPowers.wrap(document)
-    .getAnonymousElementByAttribute(videocontrols, aName, aValue);
+  return document.getAnonymousElementByAttribute(videocontrols, aName, aValue);
 }
 
 function isMuteButtonMuted() {
   var muteButton = getButtonByAttribute('class', 'muteButton');
   return muteButton.getAttribute('muted') === 'true';
 }
 
 function isVolumeSliderShowingCorrectVolume(expectedVolume) {