Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(618)

Unified Diff: LayoutTests/fast/events/event-trusted.html

Issue 1233233003: Add Event.isTrusted support (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master_event_trusted_main2
Patch Set: Add back Unforgeable Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: LayoutTests/fast/events/event-trusted.html
diff --git a/LayoutTests/fast/events/event-trusted.html b/LayoutTests/fast/events/event-trusted.html
new file mode 100644
index 0000000000000000000000000000000000000000..a33f9994a06c77a7d6a1e2bc4ba0f1cb0a4942f3
--- /dev/null
+++ b/LayoutTests/fast/events/event-trusted.html
@@ -0,0 +1,46 @@
+<input id="clitty-click" type="checkbox"/>
+<div id="console"/>
+<script src="../../resources/js-test.js"></script>
+<script>
+ description("This tests that isTrusted returns the correct value under certain situations.")
tkent 2015/07/16 03:29:37 nit: should remove the top-level 4 space indentati
dtapuska 2015/07/16 14:48:21 Done.
+
+ var redispatched = false;
+
+ function createAndInitEvent() {
+ var e = document.createEvent('Event');
+ e.initEvent(false, false, false);
+ return e;
+ }
+
+ shouldBeFalse("document.createEvent('Event').isTrusted");
+ shouldBeFalse("createAndInitEvent().isTrusted");
+
+ function originalDispatch(e) {
+ originalEvent = e;
+ }
+
+ function redispatch(e) {
+ redispatched = true;
+ }
+
+ var element = document.getElementById("clitty-click");
+ if (window.eventSender) {
+ element.addEventListener('click', originalDispatch);
+ element.addEventListener('focus', function (e) {
+ event = e;
+ shouldBeTrue("event.isTrusted");
+ });
+ eventSender.mouseMoveTo(element.offsetLeft, element.offsetTop);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+
+ shouldBeTrue("originalEvent.isTrusted");
+ element.removeEventListener('click', originalDispatch);
+ element.addEventListener('click', redispatch);
+
+ element.dispatchEvent(originalEvent);
+ shouldBeTrue("redispatched");
+ shouldBeFalse("originalEvent.isTrusted");
+ }
+
+</script>

Powered by Google App Engine
This is Rietveld 408576698