Bug 1251659 - test_bug967796.html should use SpecialPowers.pushPrefEnv. r=smaug
authorStone Shih <sshih@mozilla.com>
Wed, 19 Oct 2016 09:24:12 +0800
changeset 325119 bd30cdbf03c342fc16fe21921e82515ef0a27d45
parent 325118 4855aa893e36a07ffd2a226b36332b545ef53a5b
child 325120 7156a06172f4f652d7bfc9240bb89891288aeabe
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewerssmaug
bugs1251659, 967796
milestone53.0a1
Bug 1251659 - test_bug967796.html should use SpecialPowers.pushPrefEnv. r=smaug
dom/events/test/mochitest.ini
dom/events/test/test_bug967796.html
--- a/dom/events/test/mochitest.ini
+++ b/dom/events/test/mochitest.ini
@@ -119,17 +119,16 @@ skip-if = toolkit == 'android' #CRASH_DU
 [test_bug864040.html]
 [test_bug924087.html]
 [test_bug930374-content.html]
 [test_bug944011.html]
 [test_bug944847.html]
 [test_bug946632.html]
 skip-if = (e10s && os == "mac") # bug 1252273
 [test_bug967796.html]
-skip-if = e10s # bug 1251659
 [test_bug985988.html]
 [test_bug998809.html]
 [test_bug1003432.html]
 support-files = test_bug1003432.js
 [test_bug1013412.html]
 [test_bug1017086_disable.html]
 support-files = bug1017086_inner.html
 [test_bug1017086_enable.html]
--- a/dom/events/test/test_bug967796.html
+++ b/dom/events/test/test_bug967796.html
@@ -14,21 +14,25 @@ https://bugzilla.mozilla.org/show_bug.cg
 <p id="display"></p>
 <div id="content" style="display: none">
 
 </div>
 <pre id="test">
 <script type="application/javascript">
 
 /** Test for Bug 967796 **/
-
-SpecialPowers.setBoolPref("dom.w3c_pointer_events.enabled", true);      // Enable Pointer Events
-
 SimpleTest.waitForExplicitFinish();
-SimpleTest.waitForFocus(runTests);
+SimpleTest.waitForFocus(() => {
+  // Enable Pointer Events
+  SpecialPowers.pushPrefEnv({
+    "set": [
+      ["dom.w3c_pointer_events.enabled", true]
+    ]
+  }, runTests);
+});
 var outer;
 var middle;
 var inner;
 var outside;
 var container;
 var file;
 var iframe;
 var checkRelatedTarget = false;
@@ -49,17 +53,24 @@ var expectedPointerLeaveTargets = [];
 
 function runTests() {
   outer = document.getElementById("outertest");
   middle = document.getElementById("middletest");
   inner = document.getElementById("innertest");
   outside = document.getElementById("outside");
   container = document.getElementById("container");
   file = document.getElementById("file");
-  iframe = document.getElementById("iframe");
+  iframe = document.createElement('iframe');
+  iframe.width=50;
+  iframe.height=50;
+  container.appendChild(iframe);
+  iframe.addEventListener("pointerenter", penter, false);
+  iframe.addEventListener("pointerleave", pleave, false);
+  iframe.addEventListener("pointerout", pout, false);
+  iframe.addEventListener("pointerover", pover, false);
 
   // Make sure ESM thinks pointer is outside the test elements.
   sendPointerEvent("pointermove", outside);
 
   pointerentercount = 0;
   pointerleavecount = 0;
   pointerovercount = 0;
   pointeroutcount = 0;
@@ -121,22 +132,26 @@ function runTests() {
   iframe.contentDocument.body.lastChild.onpointerenter = penter;
   iframe.contentDocument.body.lastChild.onpointerleave = pleave;
   r = iframe.getBoundingClientRect();
   expectedRelatedEnter = outside;
   expectedRelatedLeave = iframe;
   // Move pointer inside the iframe.
   synthesizePointer(iframe.contentDocument.body, r.width / 2, r.height / 4, {type: "pointermove"},
                     iframe.contentWindow);
+  is(pointerentercount, 6, "Unexpected pointerenter event count!");
+  is(pointerleavecount, 4, "Unexpected pointerleave event count!");
   synthesizePointer(iframe.contentDocument.body, r.width / 2, r.height - (r.height / 4), {type: "pointermove"},
                     iframe.contentWindow);
   is(pointerentercount, 7, "Unexpected pointerenter event count!");
+  is(pointerleavecount, 5, "Unexpected pointerleave event count!");
   expectedRelatedEnter = iframe;
   expectedRelatedLeave = outside;
   sendPointerEvent("pointermove", outside);
+  is(pointerentercount, 7, "Unexpected pointerenter event count!");
   is(pointerleavecount, 7, "Unexpected pointerleave event count!");
 
   // pointerdown must produce pointerenter event
   expectedRelatedEnter = outside;
   expectedRelatedLeave = iframe;
   // Move pointer inside the iframe.
   synthesizePointer(iframe.contentDocument.body, r.width / 2, r.height / 4, {type: "pointerdown"},
                     iframe.contentWindow);
@@ -156,18 +171,16 @@ function runTests() {
   Array.from(document.querySelectorAll('*'))
     .concat([iframe.contentDocument.body.firstChild, iframe.contentDocument.body.lastChild])
     .forEach((elt) => {
       elt.onpointerenter = null;
       elt.onpointerleave = null;
       elt.onpointerenter = null;
       elt.onpointerleave = null;
     });
-  SpecialPowers.clearUserPref("dom.w3c_pointer_events.enabled");      // Disable Pointer Events
-
   SimpleTest.finish();
 }
 
 function penter(evt) {
   ++pointerentercount;
   evt.stopPropagation();
   if (expectedPointerEnterTargets.length) {
     var t = expectedPointerEnterTargets.shift();
@@ -222,14 +235,11 @@ function pout(evt) {
       <div id="innertest" onpointerenter="penter(event)" onpointerleave="pleave(event)"
                           onpointerout="pout(event)" onpointerover="pover(event)">foo</div>
     </div>
   </div>
   <input type="file" id="file"
          onpointerenter="penter(event)" onpointerleave="pleave(event)"
          onpointerout="pout(event)" onpointerover="pover(event)">
   <br>
-  <iframe id="iframe" width="50px" height="50px"
-          onpointerenter="penter(event)" onpointerleave="pleave(event)"
-          onpointerout="pout(event)" onpointerover="pover(event)"></iframe>
 </div>
 </body>
 </html>