/** Test for Bug 967796 */
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(runTests); var outer; var middle; var inner; var outside; var container; var file; variframe; var checkRelatedTarget = false; var expectedRelatedEnter = null; var expectedRelatedLeave = null; var pointerentercount = 0; var pointerleavecount = 0; var pointerovercount = 0; var pointeroutcount = 0;
function sendMouseEventToElement(t, elem) { var r = elem.getBoundingClientRect();
synthesizeMouse(elem, r.width / 2, r.height / 2, {type: t, id: 0});
}
var expectedPointerEnterTargets = []; var expectedPointerLeaveTargets = [];
iframe.contentDocument.body.firstChild.onpointerenter = penter; iframe.contentDocument.body.firstChild.onpointerleave = pleave; iframe.contentDocument.body.lastChild.onpointerenter = penter; iframe.contentDocument.body.lastChild.onpointerleave = pleave;
r = iframe.getBoundingClientRect();
expectedRelatedEnter = outside;
expectedRelatedLeave = iframe;
// Move pointer inside the iframe.
info("Synthesizing mousemove on the body in the iframe #1...");
synthesizeMouse(iframe.contentDocument.body, r.width / 2, r.height / 4, {type: "mousemove"}, iframe.contentWindow);
is(pointerentercount, 6, "Unexpected pointerenter event count!");
is(pointerleavecount, 4, "Unexpected pointerleave event count!");
info("Synthesizing mousemove on the body in the iframe #2...");
synthesizeMouse(iframe.contentDocument.body, r.width / 2, r.height - (r.height / 4), {type: "mousemove"}, iframe.contentWindow);
is(pointerentercount, 7, "Unexpected pointerenter event count!");
is(pointerleavecount, 5, "Unexpected pointerleave event count!");
expectedRelatedEnter = iframe;
expectedRelatedLeave = outside;
info("Synthesizing mousemove on the outside after the iframe...");
sendMouseEventToElement("mousemove", 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.
info("Synthesizing mousemove on the body in the iframe #3...");
synthesizeMouse(iframe.contentDocument.body, r.width / 2, r.height / 4, {type: "mousedown"}, iframe.contentWindow);
info("Synthesizing mousemove on the body in the iframe #4...");
synthesizeMouse(iframe.contentDocument.body, r.width / 2, r.height - (r.height / 4), {type: "mousedown"}, iframe.contentWindow);
is(pointerentercount, 10, "Unexpected pointerenter event count!");
// pointerdown + pointermove must produce single pointerenter event
expectedRelatedEnter = outside;
expectedRelatedLeave = iframe;
info("Synthesizing mousemove on the body in the iframe #5...");
synthesizeMouse(iframe.contentDocument.body, r.width / 2, r.height / 4, {type: "mousedown"}, iframe.contentWindow);
info("Synthesizing mousemove on the body in the iframe #6...");
synthesizeMouse(iframe.contentDocument.body, r.width / 2 + 1, r.height / 4 + 1, {type: "mousemove"}, iframe.contentWindow);
is(pointerentercount, 11, "Unexpected pointerenter event count!");
function penter(evt) {
if (evt.pointerId != 0) {
return; // Preceding test must have used the unexpected pointer. Ignore pointer boundary events for the pointer.
}
++pointerentercount;
evt.stopPropagation();
if (expectedPointerEnterTargets.length) { var t = expectedPointerEnterTargets.shift();
is(evt.target.id, t, "Wrong event target!");
}
is(evt.bubbles, false, evt.type + " should not bubble!");
is(evt.cancelable, false, evt.type + " is cancelable!");
is(evt.target, evt.currentTarget, "Wrong event target!");
ok(!evt.relatedTarget || evt.target.ownerDocument == evt.relatedTarget.ownerDocument, "Leaking nodes to another document?");
if (checkRelatedTarget && evt.target.ownerDocument == document) {
is(evt.relatedTarget, expectedRelatedEnter, "Wrong related target (pointerenter)");
}
}
function pleave(evt) {
if (evt.pointerId != 0) {
return; // Preceding test must have used the unexpected pointer. Ignore pointer boundary events for the pointer.
}
++pointerleavecount;
evt.stopPropagation();
if (expectedPointerLeaveTargets.length) { var t = expectedPointerLeaveTargets.shift();
is(evt.target.id, t, "Wrong event target!");
}
is(evt.bubbles, false, evt.type + " should not bubble!");
is(evt.cancelable, false, evt.type + " is cancelable!");
is(evt.target, evt.currentTarget, "Wrong event target!");
ok(!evt.relatedTarget || evt.target.ownerDocument == evt.relatedTarget.ownerDocument, "Leaking nodes to another document?");
if (checkRelatedTarget && evt.target.ownerDocument == document) {
is(evt.relatedTarget, expectedRelatedLeave, "Wrong related target (pointerleave)");
}
}
function pover(evt) {
if (evt.pointerId != 0) {
return; // Preceding test must have used the unexpected pointer. Ignore pointer boundary events for the pointer.
}
++pointerovercount;
evt.stopPropagation();
}
function pout(evt) {
if (evt.pointerId != 0) {
return; // Preceding test must have used the unexpected pointer. Ignore pointer boundary events for the pointer.
}
++pointeroutcount;
evt.stopPropagation();
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.