summaryrefslogtreecommitdiffstats
path: root/layout/base/tests
diff options
context:
space:
mode:
Diffstat (limited to 'layout/base/tests')
-rw-r--r--layout/base/tests/bug1078327_inner.html8
-rw-r--r--layout/base/tests/bug1162990_inner_1.html4
-rw-r--r--layout/base/tests/bug1162990_inner_2.html2
-rw-r--r--layout/base/tests/bug976963_inner.html241
-rw-r--r--layout/base/tests/bug977003_inner_5.html8
-rw-r--r--layout/base/tests/bug977003_inner_6.html6
-rw-r--r--layout/base/tests/mochitest.ini2
-rw-r--r--layout/base/tests/test_bug976963.html35
8 files changed, 19 insertions, 287 deletions
diff --git a/layout/base/tests/bug1078327_inner.html b/layout/base/tests/bug1078327_inner.html
index 9e32fc996..0cfb9da7f 100644
--- a/layout/base/tests/bug1078327_inner.html
+++ b/layout/base/tests/bug1078327_inner.html
@@ -24,16 +24,16 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1078327
var test_mediator_move = false;
var test_mediator_out = false;
var test_listener = false;
+ var test_lost_capture = false;
function TargetHandler(event) {
logger("Target receive event: " + event.type + ". Mediator.setPointerCapture()");
mediator.setPointerCapture(event.pointerId);
test_target = true;
+ test_capture = true;
}
function MediatorHandler(event) {
logger("Mediator receive event: " + event.type);
- if(event.type == "gotpointercapture")
- test_capture = true;
if(!test_capture)
return;
if(event.type == "pointermove")
@@ -43,7 +43,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1078327
if(event.type == "pointerout")
test_mediator_out++;
if(event.type == "lostpointercapture")
- test_capture = false;
+ test_lost_capture = true;
}
function ListenerHandler(event) {
logger("Listener receive event: " + event.type);
@@ -86,7 +86,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1078327
}
function finishTest() {
parent.is(test_target, true, "pointerdown event should be received by target");
- parent.is(test_capture, false, "test_capture should be false at the end of the test");
+ parent.is(test_lost_capture, true, "mediator should receive lostpointercapture");
parent.is(test_mediator_over, 1, "mediator should receive pointerover event only once");
parent.is(test_mediator_move, 5, "mediator should receive pointermove event five times");
parent.is(test_mediator_out, 1, "mediator should receive pointerout event only once");
diff --git a/layout/base/tests/bug1162990_inner_1.html b/layout/base/tests/bug1162990_inner_1.html
index 4ea5edb5c..0f950df8d 100644
--- a/layout/base/tests/bug1162990_inner_1.html
+++ b/layout/base/tests/bug1162990_inner_1.html
@@ -111,10 +111,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1162990
}
function finishTest() {
- parent.is(test_basketLeave, 0, "Part1: basket should not receive pointerleave event after pointer capturing");
+ parent.is(test_basketLeave, 1, "Part1: basket should receive pointerleave event after pointer capturing");
parent.is(test_targetGotCapture, 1, "Part1: target should receive gotpointercapture event");
parent.is(test_targetLostCapture, 1, "Part1: target should receive lostpointercapture event");
- parent.is(test_targetLeave, 2, "Part1: target should receive pointerleave event two times");
+ parent.is(test_targetLeave, 1, "Part1: target should receive pointerleave event only one time");
parent.is(test_childLeave, 0, "Part1: child should not receive pointerleave event after pointer capturing");
parent.is(test_listenerDown, 1, "Part1: listener should receive pointerdown event");
parent.is(test_listenerLeave, 1, "Part1: listener should receive pointerleave event only one time");
diff --git a/layout/base/tests/bug1162990_inner_2.html b/layout/base/tests/bug1162990_inner_2.html
index 54aa74ca3..e418927bd 100644
--- a/layout/base/tests/bug1162990_inner_2.html
+++ b/layout/base/tests/bug1162990_inner_2.html
@@ -116,7 +116,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1162990
parent.is(test_targetDown, 1, "Part2: target should receive pointerdown event");
parent.is(test_targetGotCapture, 1, "Part2: target should receive gotpointercapture event");
parent.is(test_targetLostCapture, 1, "Part2: target should receive lostpointercapture event");
- parent.is(test_targetLeave, 1, "Part2: target should receive pointerleave event");
+ parent.is(test_targetLeave, 0, "Part2: target should not receive pointerleave event");
parent.is(test_childLeave, 0, "Part2: child should not receive pointerleave event after pointer capturing");
parent.is(test_listenerLeave, 0, "Part2: listener should not receive pointerleave event after pointer capturing");
logger("finishTest");
diff --git a/layout/base/tests/bug976963_inner.html b/layout/base/tests/bug976963_inner.html
deleted file mode 100644
index 2c55fbccd..000000000
--- a/layout/base/tests/bug976963_inner.html
+++ /dev/null
@@ -1,241 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=976963
--->
-<head>
- <meta charset="utf-8">
- <title>Test for Bug 976963</title>
- <meta name="author" content="Maksim Lebedev" />
- <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
- <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
- <style>
- div#listener {
- background: yellow;
- position: absolute;
- top: -100px;
- }
- div#middler {
- background: yellow;
- margin: 10px;
- }
- div#target {
- background: yellow;
- }
- </style>
- <script type="application/javascript">
- /** Test for Bug 976963 **/
- var All_Pointer_Events = ["pointerover", "pointerenter",
- "pointermove",
- "pointerdown", "pointerup",
- "pointerout", "pointerleave",
- "pointercancel",
- "gotpointercapture", "lostpointercapture"];
-
- function on_event(object, event, callback) {
- object.addEventListener(event, callback, false);
- }
- function ok(check, msg) {
- parent.ok(check, msg);
- }
- function is(a, b, msg) {
- parent.is(a, b, msg);
- }
-
- var listener = undefined;
- var middler = undefined;
- var target = undefined;
-
- var test_ListenerGotCapture = 0;
- var test_ListenerUnwanted = 0;
- var test_ListenerLostCapture = 0;
- var test_ListenerAfterCapture = 0;
- var test_MiddlerGotCapture = 0;
- var test_MiddlerOver = 0;
- var test_MiddlerLeave = 0;
- var test_MiddlerUp = 0;
- var test_MiddlerLostCapture = 0;
- var test_TargetDown = 0;
- var test_TargetUnwanted = 0;
- var test_TargetUp = 0;
-
- var captured_event = undefined;
- var f_gotPointerCapture = false;
- var f_lostPointerCapture = false;
- var f_gotMiddlerPointerCapture = false;
-
- function listenerEventHandler(event) {
- logger("Listener: " + event.type + ". Captured_event: " + captured_event);
- if(test_ListenerLostCapture)
- test_ListenerAfterCapture++;
- if (event.type == "gotpointercapture") {
- f_gotPointerCapture = true;
- test_ListenerGotCapture++;
- }
- else if (event.type == "lostpointercapture") {
- f_lostPointerCapture = true;
- f_gotPointerCapture = false;
- test_ListenerLostCapture++;
- }
- else if (event.type == "pointermove") {
- ok(captured_event && captured_event.pointerId == event.pointerId, "Listener: equals pointerId for lostpointercapture event");
- if (f_gotPointerCapture) {
- // on first event received for capture, release capture
- logger("Listener call release");
- ok(!!listener, "Listener should be live!");
- ok(typeof(listener.releasePointerCapture) == "function", "Listener should have a function releasePointerCapture");
- listener.releasePointerCapture(event.pointerId);
- }
- else {
- logger("Listener.ASSERT: " + event.type);
- test_ListenerUnwanted++;
- // if any other events are received after releaseCapture, then the test fails
- ok(false, event.target.id + "-" + event.type + " should be handled by target element handler");
- }
- }
- else {
- test_ListenerUnwanted++;
- logger("Listener.ASSERT: " + event.type);
- ok(false, event.type + "should be never handled by listener");
- }
- }
-
- function middlerEventHandler(event) {
- logger("Middler: " + event.type + ". Captured_event: " + captured_event);
- if (event.type == "gotpointercapture") {
- test_MiddlerGotCapture++;
- f_gotMiddlerPointerCapture = true;
- ok(captured_event && captured_event.pointerId == event.pointerId, "Middler: equals pointerId for gotpointercapture event");
- }
- else if (event.type == "pointerover") {
- test_MiddlerOver++;
- ok(captured_event && captured_event.pointerId == event.pointerId, "Middler: equals pointerId for pointerover event");
- }
- else if (event.type == "pointerleave") {
- test_MiddlerLeave++;
- ok(captured_event && captured_event.pointerId == event.pointerId, "Middler: equals pointerId for pointerleave event");
- ok(!!listener, "Listener should be live!");
- ok(typeof(listener.setPointerCapture) == "function", "Listener should have a function setPointerCapture");
- listener.setPointerCapture(event.pointerId);
- }
- else if (event.type == "lostpointercapture") {
- test_MiddlerLostCapture++;
- f_gotMiddlerPointerCapture = false;
- ok(captured_event && captured_event.pointerId == event.pointerId, "Middler: equals pointerId for lostpointercapture event");
- }
- else if (event.type == "pointerup" ) {
- test_MiddlerUp++;
- }
- }
-
- function targetEventHandler(event) {
- logger("Target: " + event.type + ". Captured_event: " + captured_event);
- if (f_gotPointerCapture || f_gotMiddlerPointerCapture) {
- if (event.type != "pointerout" && event.type != "pointerleave") {
- logger("Target.ASSERT: " + event.type + " " + event.pointerId);
- test_TargetUnwanted++;
- ok(false, "The Target element should not have received any events while capture is active. Event recieved:" + event.type + ". ");
- }
- }
- if (event.type == "pointerdown") {
- logger("Target.pointerdown 1: " + captured_event);
- test_TargetDown++;
- captured_event = event;
- ok(!!middler, "Middler should be live!");
- ok(typeof(middler.setPointerCapture) == "function", "Middler should have a function setPointerCapture");
- middler.setPointerCapture(event.pointerId);
- logger("Target.pointerdown 2: " + captured_event);
- }
- else if (event.type == "pointerup") {
- ok(f_lostPointerCapture, "Target should have received pointerup");
- ok(captured_event && captured_event.pointerId == event.pointerId, "Target: equals pointerId for lostpointercapture event");
- test_TargetUp++; // complete test
- }
- }
-
- function colorerHandler(event) {
- if(event.type == "pointerover")
- event.target.style.background = "red";
- else if(event.type == "pointerout")
- event.target.style.background = "yellow";
- }
-
- function setEventHandlers() {
- listener = document.getElementById("listener");
- middler = document.getElementById("middler");
- target = document.getElementById("target");
- target.style["touchAction"] = "none";
-
- // target and listener - handle all events
- for (var i = 0; i < All_Pointer_Events.length; i++) {
- on_event(target, All_Pointer_Events[i], targetEventHandler);
- on_event(listener, All_Pointer_Events[i], listenerEventHandler);
- on_event(middler, All_Pointer_Events[i], middlerEventHandler);
- on_event(target, All_Pointer_Events[i], colorerHandler);
- on_event(middler, All_Pointer_Events[i], colorerHandler);
- }
- }
-
- function prepareTest() {
- SpecialPowers.pushPrefEnv({
- "set": [
- ["dom.w3c_pointer_events.enabled", true]
- ]
- }, executeTest);
- }
-
- function executeTest()
- {
- logger("executeTest");
- setEventHandlers();
- document.body.offsetLeft;
- var rect = target.getBoundingClientRect();
- synthesizePointer(target, rect.width/2, rect.height/2, {type: "pointermove"});
- synthesizePointer(target, rect.width/2, rect.height/2, {type: "pointerdown"});
- synthesizePointer(target, rect.width/3, rect.height/3, {type: "pointermove"});
- synthesizePointer(middler, rect.width/2, rect.height/2, {type: "pointermove"});
- synthesizePointer(target, rect.width/2, rect.height/2, {type: "pointermove"});
- synthesizePointer(middler, rect.width/2, rect.height/2, {type: "pointermove"});
- synthesizePointer(target, rect.width/2, rect.height/2, {type: "pointermove"});
- synthesizePointer(target, rect.width/2, rect.height/2, {type: "pointerup"});
- finishTest();
- }
-
- function finishTest() {
- setTimeout(function() {
- is(test_ListenerGotCapture, 1, "Listener should receive gotpointercapture event");
- is(test_ListenerUnwanted, 0, "Listener should not receive any unwanted events");
- is(test_ListenerLostCapture, 1, "Listener should receive lostpointercapture event");
- is(test_ListenerAfterCapture, 0, "Listener should not receive any events after release pointer capture");
- is(test_MiddlerGotCapture, 1, "Middler should receive gotpointercapture event");
- is(test_MiddlerOver, 1, "Middler should receive pointerover event");
- is(test_MiddlerLeave, 1, "Middler should receive pointerleave event");
- is(test_MiddlerUp, 0, "Middler should not receive pointerup event");
- is(test_MiddlerLostCapture, 1, "Middler should receive lostpointercapture event");
- is(test_TargetDown, 1, "Target should receive pointerdown event");
- is(test_TargetUnwanted, 0, "Target should not receive any event while pointer capture is active");
- is(test_TargetUp, 1, "Target should receive pointerup event");
- logger("finishTest");
- parent.finishTest();
- }, 1000);
- }
-
- function logger(message) {
- console.log(message);
- var log = document.getElementById('log');
- log.innerHTML = message + "<br>" + log.innerHTML;
- }
- </script>
-</head>
-<body onload="prepareTest()">
- <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=976963">Mozilla Bug 976963</a>
- <p id="display"></p>
- <div id="content" style="display: none">
- </div>
- <div id="listener">div id=listener</div>
- <div id="middler">div id=middler</div>
- <div id="target">div id=target</div>
- <pre id="log">
- </pre>
-</body>
-</html>
diff --git a/layout/base/tests/bug977003_inner_5.html b/layout/base/tests/bug977003_inner_5.html
index 70fc5ba40..81094043c 100644
--- a/layout/base/tests/bug977003_inner_5.html
+++ b/layout/base/tests/bug977003_inner_5.html
@@ -26,6 +26,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1098139
var test_lost_listener = false;
var test_lost_type = "";
var test_move_listener = false;
+ var test_over_listener = false;
var test_listener = false;
var test_lost_primary = false;
@@ -53,6 +54,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1098139
logger("Receive event on Listener: " + event.type);
test_move_listener = true;
}
+ function ListenerOverHandler(event) {
+ logger("Receive event on Listener: " + event.type);
+ test_over_listener = true;
+ }
function ListenerHandler(event) {
logger("Receive event on Listener: " + event.type);
test_listener = true;
@@ -74,7 +79,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1098139
target.addEventListener("pointerdown", TargetDownHandler, false);
listener.addEventListener("gotpointercapture", ListenerGotPCHandler, false);
listener.addEventListener("lostpointercapture", ListenerLostPCHandler, false);
- listener.addEventListener("pointerover", ListenerHandler, false);
+ listener.addEventListener("pointerover", ListenerOverHandler, false);
listener.addEventListener("pointermove", ListenerMoveHandler, false);
listener.addEventListener("pointerup", ListenerHandler, false);
listener.addEventListener("pointerout", ListenerHandler, false);
@@ -93,6 +98,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1098139
parent.is(test_lost_type, "touch", "Part 5: lostpointercapture event should have pointerType touch");
parent.is(test_lost_primary, true, "Part 5: lostpointercapture event should have isPrimary as true");
parent.is(test_move_listener, true, "Part 5: gotpointercapture should be triggered by pointermove");
+ parent.is(test_over_listener, true, "Part 5: listener should receive pointerover when capturing pointer");
parent.is(test_listener, false, "Part 5: listener should not receive any other events");
logger("finishTest");
parent.finishTest();
diff --git a/layout/base/tests/bug977003_inner_6.html b/layout/base/tests/bug977003_inner_6.html
index 12424b1f2..b60ca5c31 100644
--- a/layout/base/tests/bug977003_inner_6.html
+++ b/layout/base/tests/bug977003_inner_6.html
@@ -19,6 +19,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1073563
var listener = undefined;
var test_target = false;
var test_move = false;
+ var test_over = false;
var test_listener = false;
var receive_lostpointercapture = false;
@@ -44,6 +45,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1073563
}
} else if(event.type == "pointermove") {
test_move = true;
+ } else if(event.type == "pointerover") {
+ test_over = true;
} else {
test_listener = true;
}
@@ -81,7 +84,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1073563
// PE level 2 defines that the pending pointer capture is processed when firing next pointer events.
// In this test case, pointer capture release is processed when firing pointermove
parent.is(test_move, true, "Part 6: gotpointercapture should be triggered by pointermove");
- parent.is(test_listener, false, "Part 6: no other pointerevents should be fired before gotpointercapture");
+ parent.is(test_over, true, "Part 6: pointerover should be received when capturing pointer");
+ parent.is(test_listener, false, "Part 6: no other pointerevents should be fired before gotpointercapture except pointerover");
logger("finishTest");
parent.finishTest();
}
diff --git a/layout/base/tests/mochitest.ini b/layout/base/tests/mochitest.ini
index 279b0af8a..405697977 100644
--- a/layout/base/tests/mochitest.ini
+++ b/layout/base/tests/mochitest.ini
@@ -256,8 +256,6 @@ skip-if = toolkit == 'android'
support-files = bug851445_helper.html
[test_bug970964.html]
support-files = bug970964_inner.html
-[test_bug976963.html]
-support-files = bug976963_inner.html
[test_bug977003.html]
support-files =
bug977003_inner_1.html
diff --git a/layout/base/tests/test_bug976963.html b/layout/base/tests/test_bug976963.html
deleted file mode 100644
index 4b8da3a6e..000000000
--- a/layout/base/tests/test_bug976963.html
+++ /dev/null
@@ -1,35 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=976963
--->
- <head>
- <meta charset="utf-8">
- <meta name="author" content="Maksim Lebedev" />
- <title>Test for Bug 976963</title>
- <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
- <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
- <script type="text/javascript">
- function prepareTest() {
- SimpleTest.waitForExplicitFinish();
- SimpleTest.requestFlakyTimeout("untriaged");
- SpecialPowers.pushPrefEnv({
- "set": [
- ["dom.w3c_pointer_events.enabled", true],
- ["layout.reflow.synthMouseMove", false]
- ]
- }, startTest);
- }
- function startTest() {
- var iframe = document.getElementById("testFrame");
- iframe.src = "bug976963_inner.html";
- }
- function finishTest() {
- SimpleTest.finish();
- }
- </script>
- </head>
- <body onload="prepareTest()">
- <iframe id="testFrame" height="700" width="700"></iframe>
- </body>
-</html>