Skip to content

Commit

Permalink
Bug 1421480 - Revise pointer events test cases to verify implicit poi…
Browse files Browse the repository at this point in the history
…nter capture for touch. r=smaug.

MozReview-Commit-ID: 9PaI4EwRs7O
  • Loading branch information
mingchou committed Nov 13, 2017
1 parent bbb5b07 commit ce606ae
Show file tree
Hide file tree
Showing 5 changed files with 412 additions and 18 deletions.
39 changes: 33 additions & 6 deletions dom/events/test/pointerevents/test_bug1403055.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
/** Test for Bug 1403055 **/
SimpleTest.waitForExplicitFinish();

function runTests() {
let target0 = window.document.getElementById("target0");
let target1 = window.document.getElementById("target1");
let done = window.document.getElementById("done");
var target0 = window.document.getElementById("target0");
var target1 = window.document.getElementById("target1");
var done = window.document.getElementById("done");

function withoutImplicitlyPointerCaptureForTouch() {
let target0_events = ["pointerover", "pointerenter", "pointerdown", "pointermove"];
let target1_events = ["pointerover", "pointerenter", "pointermove", "pointercancel", "pointerout", "pointerleave"];

Expand All @@ -45,9 +45,34 @@
done.addEventListener("mouseup", () => {
ok(target0_events.length == 0, " should receive " + target0_events + " on target0");
ok(target1_events.length == 0, " should receive " + target1_events + " on target1");
SimpleTest.finish();
SpecialPowers.pushPrefEnv({"set": [["dom.w3c_pointer_events.enabled", true],
["dom.w3c_pointer_events.implicit_capture", true]]},
withImplicitlyPointerCaptureForTouch);
}, {once : true});

synthesizeTouch(target0, 5, 5, { type: "touchstart" });
synthesizeTouch(target0, 5, 5, { type: "touchmove" });
synthesizeTouch(target1, 5, 5, { type: "touchmove" });
synthesizeTouch(target1, 5, 5, { type: "touchcancel" });
synthesizeMouseAtCenter(done, { type: "mousedown" });
synthesizeMouseAtCenter(done, { type: "mouseup" });
}

function withImplicitlyPointerCaptureForTouch() {
let target0_events = ["pointerover", "pointerenter", "pointerdown", "pointermove", "pointercancel", "pointerout", "pointerleave"];

target0_events.forEach((elem, index, arr) => {
target0.addEventListener(elem, (event) => {
is(event.type, target0_events[0], "receive " + event.type + " on target0");
target0_events = target0_events.filter(item => item !== event.type);
}, { once: true });
});

done.addEventListener("mouseup", () => {
ok(target0_events.length == 0, " should receive " + target0_events + " on target0");
SimpleTest.finish();
}, {once : true});

synthesizeTouch(target0, 5, 5, { type: "touchstart" });
synthesizeTouch(target0, 5, 5, { type: "touchmove" });
synthesizeTouch(target1, 5, 5, { type: "touchmove" });
Expand All @@ -57,7 +82,9 @@
}

SimpleTest.waitForFocus(() => {
SpecialPowers.pushPrefEnv({"set": [["dom.w3c_pointer_events.enabled", true]]}, runTests);
SpecialPowers.pushPrefEnv({"set": [["dom.w3c_pointer_events.enabled", true],
["dom.w3c_pointer_events.implicit_capture", false]]},
withoutImplicitlyPointerCaptureForTouch);
});

</script>
Expand Down
5 changes: 2 additions & 3 deletions layout/base/tests/bug970964_inner.html
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@
// Let window.onerror have a chance to fire
setTimeout(function() {
setTimeout(function() {
window.parent.postMessage("SimpleTest.finish();", "*");
window.parent.postMessage("run next", "*");
}, 0);
}, 0);
}
Expand All @@ -339,12 +339,11 @@
SpecialPowers.pushPrefEnv({
"set": [
["dom.w3c_pointer_events.enabled", true],
["dom.w3c_pointer_events.implicit_capture", false]
]
}, runTests);
}

SimpleTest.waitForExplicitFinish();

</script>
</pre>
<div id="d0">
Expand Down
Loading

0 comments on commit ce606ae

Please sign in to comment.