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..2dc9f116271e40aaac765ff0a18fb238cba8c76f |
--- /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.") |
+ |
+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> |