-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose getCoalescedEvents only on SecureContext
Differential Revision: https://phabricator.services.mozilla.com/D190740 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1858434 gecko-commit: dd3a5d4810b3c06078a0001a17b6e36755c82e0b gecko-reviewers: edgar
- Loading branch information
1 parent
4ab37a2
commit 3324586
Showing
10 changed files
with
204 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>PointerEvent: Constructor test</title> | ||
<meta name="viewport" content="width=device-width"> | ||
<link rel="stylesheet" type="text/css" href="pointerevent_styles.css"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<!-- Additional helper script for common checks across event types --> | ||
</head> | ||
<body> | ||
<h1>PointerEvent: Dispatch custom event</h1> | ||
<h4>Test Description: This test checks if PointerEvent constructor works properly.</h4> | ||
<div id="target0"></div> | ||
<script> | ||
async_test(function() { | ||
var target0 = document.getElementById("target0"); | ||
// set values for non-default constructor | ||
on_event(target0, "pointermove", this.step_func(function(event) { | ||
generate_tests(assert_equals, [ | ||
["getCoalescedEvents().length", event.getCoalescedEvents().length, 2], | ||
["getPredictedEvents().length", event.getPredictedEvents().length, 2], | ||
["event.target", event.target, target0], | ||
["event.currentTarget", event.currentTarget, target0], | ||
["event.eventPhase", event.eventPhase, Event.AT_TARGET], | ||
["event.clientX", event.clientX, 310], | ||
["event.pointerType", event.pointerType, "pen"], | ||
["getCoalescedEvents()[0].clientX", event.getCoalescedEvents()[0].clientX, 300], | ||
["getCoalescedEvents()[1].clientX", event.getCoalescedEvents()[1].clientX, 310], | ||
["getPredictedEvents()[0].clientX", event.getPredictedEvents()[0].clientX, 320], | ||
["getPredictedEvents()[1].clientX", event.getPredictedEvents()[1].clientX, 330], | ||
]); | ||
for (var i=0; i<event.getCoalescedEvents().length; i++) { | ||
var coalescedEvent = event.getCoalescedEvents()[i]; | ||
generate_tests(assert_equals, [ | ||
["getCoalescedEvents()[" + i + "].pointerId", coalescedEvent.pointerId, event.pointerId], | ||
["getCoalescedEvents()[" + i + "].pointerType", coalescedEvent.pointerType, event.pointerType], | ||
["getCoalescedEvents()[" + i + "].isPrimary", coalescedEvent.isPrimary, event.isPrimary], | ||
["getCoalescedEvents()[" + i + "].getCoalescedEvents().length", coalescedEvent.getCoalescedEvents().length, 0], | ||
["getCoalescedEvents()[" + i + "].getPredictedEvents().length", coalescedEvent.getPredictedEvents().length, 0], | ||
["getCoalescedEvents()[" + i + "].target", coalescedEvent.target, null], | ||
["getCoalescedEvents()[" + i + "].currentTarget", coalescedEvent.currentTarget, null], | ||
["getCoalescedEvents()[" + i + "].eventPhase", coalescedEvent.eventPhase, Event.NONE], | ||
["getCoalescedEvents()[" + i + "].cancelable", coalescedEvent.cancelable, false], | ||
["getCoalescedEvents()[" + i + "].bubbles", coalescedEvent.bubbles, false], | ||
["getCoalescedEvents()[" + i + "].offsetX", coalescedEvent.offsetX, 310 + (i==0?-10:0)], | ||
["getCoalescedEvents()[" + i + "].offsetY", coalescedEvent.offsetY, 0], | ||
]); | ||
} | ||
for (var i=0; i<event.getPredictedEvents().length; i++) { | ||
var predictedEvent = event.getPredictedEvents()[i]; | ||
generate_tests(assert_equals, [ | ||
["getPredictedEvents()[" + i + "].pointerId", predictedEvent.pointerId, event.pointerId], | ||
["getPredictedEvents()[" + i + "].pointerType", predictedEvent.pointerType, event.pointerType], | ||
["getPredictedEvents()[" + i + "].isPrimary", predictedEvent.isPrimary, event.isPrimary], | ||
["getPredictedEvents()[" + i + "].getCoalescedEvents().length", predictedEvent.getCoalescedEvents().length, 0], | ||
["getPredictedEvents()[" + i + "].getPredictedEvents().length", predictedEvent.getPredictedEvents().length, 0], | ||
["getPredictedEvents()[" + i + "].target", predictedEvent.target, null], | ||
["getPredictedEvents()[" + i + "].currentTarget", predictedEvent.currentTarget, null], | ||
["getPredictedEvents()[" + i + "].eventPhase", predictedEvent.eventPhase, Event.NONE], | ||
["getPredictedEvents()[" + i + "].cancelable", predictedEvent.cancelable, false], | ||
["getPredictedEvents()[" + i + "].bubbles", predictedEvent.bubbles, false], | ||
["getPredictedEvents()[" + i + "].offsetX", predictedEvent.offsetX, 310 + (i==0?10:20)], | ||
["getPredictedEvents()[" + i + "].offsetY", predictedEvent.offsetY, 0], | ||
]); | ||
} | ||
})); | ||
on_event(target0, "pointerout", this.step_func(function(event) { | ||
generate_tests(assert_equals, [ | ||
["default event.pointerType", event.pointerType, ""], | ||
["default getCoalescedEvents().length", event.getCoalescedEvents().length, 0], | ||
["default getPredictedEvents().length", event.getPredictedEvents().length, 0], | ||
]); | ||
})); | ||
on_event(target0, "pointerup", this.step_func(function(event) { | ||
generate_tests(assert_equals, [ | ||
["type event.pointerType", event.pointerType, "foo"], | ||
]); | ||
})); | ||
|
||
on_event(window, "load", this.step_func_done(function() { | ||
assert_not_equals(window.PointerEvent, undefined); | ||
|
||
var pointerEventInitDict = | ||
{ | ||
pointerId: 42, | ||
pointerType: "pen", | ||
isPrimary: true, | ||
clientX: 300, | ||
}; | ||
|
||
var p1 = new PointerEvent("pointermove", pointerEventInitDict); | ||
pointerEventInitDict.clientX += 10; | ||
var p2 = new PointerEvent("pointermove", pointerEventInitDict); | ||
pointerEventInitDict.clientX += 10; | ||
var p3 = new PointerEvent("pointermove", pointerEventInitDict); | ||
pointerEventInitDict.clientX += 10; | ||
var p4 = new PointerEvent("pointermove", pointerEventInitDict); | ||
pointerEventInitDict.coalescedEvents = [p1, p2]; | ||
pointerEventInitDict.predictedEvents = [p3, p4]; | ||
pointerEventInitDict.clientX = 310; | ||
var event = new PointerEvent("pointermove", pointerEventInitDict); | ||
target0.dispatchEvent(event); | ||
|
||
var pointerEventDefault = new PointerEvent("pointerout"); | ||
target0.dispatchEvent(pointerEventDefault); | ||
|
||
var pointerEventType = new PointerEvent("pointerup", { pointerType: "foo" } ); | ||
target0.dispatchEvent(pointerEventType); | ||
}, "PointerEvent constructor")); | ||
}) | ||
</script> | ||
<div id="complete-notice"> | ||
<p>The following pointer types were detected: <span id="pointertype-log"></span>.</p> | ||
</div> | ||
<div id="log"></div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>pointerrawupdate</title> | ||
<meta name="viewport" content="width=device-width"> | ||
<link rel="stylesheet" type="text/css" href="pointerevent_styles.css"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/resources/testdriver.js"></script> | ||
<script src="/resources/testdriver-actions.js"></script> | ||
<script src="/resources/testdriver-vendor.js"></script> | ||
<!-- Additional helper script for common checks across event types --> | ||
<script type="text/javascript" src="pointerevent_support.js"></script> | ||
</head> | ||
<body onload="run()"> | ||
<h2>pointerrawupdate</h2> | ||
<h4>Test Description: This test checks if pointerrawupdate is dispatched correctly. </h4> | ||
<p>Move your mouse within the black box.</p> | ||
<p>Press left button down and then press middle button while holding down left button. Then release the buttons</p> | ||
<div id="target0"></div> | ||
<script> | ||
var test_pointerrawupdate = async_test("pointerrawupdate event received"); | ||
var actions_promise; | ||
|
||
var pointerrawupdateReceived = false; | ||
var pointerdownReceived = false; | ||
var pointerrawupdateFromButtonChangeReceived = false; | ||
|
||
function run() { | ||
var target0 = document.getElementById("target0"); | ||
|
||
on_event(target0, "pointerrawupdate", function (event) { | ||
pointerrawupdateReceived = true; | ||
if (pointerdownReceived && event.button != -1) | ||
pointerrawupdateFromButtonChangeReceived = true; | ||
}); | ||
on_event(target0, "pointermove", function (event) { | ||
test_pointerrawupdate.step(function() { | ||
assert_true(pointerrawupdateReceived, | ||
"Pointerrawupdate event should have been received before pointermove."); | ||
}, "Pointerrawupdate event should have been received before pointermove."); | ||
}); | ||
on_event(target0, "pointerdown", function (event) { | ||
pointerdownReceived = true; | ||
}); | ||
on_event(target0, "pointerup", function (event) { | ||
test_pointerrawupdate.step(function() { | ||
assert_true(pointerrawupdateFromButtonChangeReceived, | ||
"Pointerrawupdate event should have been received from chorded button changes."); | ||
}, "Pointerrawupdate event should have been received from chorded button changes."); | ||
// Make sure the test finishes after all the input actions are completed. | ||
actions_promise.then( () => { | ||
test_pointerrawupdate.done(); | ||
}); | ||
}); | ||
var actions = new test_driver.Actions(); | ||
actions_promise = actions.pointerMove(0, 0, {origin: target0, button: actions.ButtonType.LEFT}) | ||
.pointerDown({button: actions.ButtonType.LEFT}) | ||
.pointerDown({button: actions.ButtonType.MIDDLE}) | ||
.pointerUp({button: actions.ButtonType.MIDDLE}) | ||
.pointerUp({button: actions.ButtonType.LEFT}) | ||
.send(); | ||
} | ||
|
||
</script> | ||
<div id="complete-notice"> | ||
</div> | ||
</body> | ||
</html> |
File renamed without changes.
File renamed without changes.