OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <meta charset=urf-8> | 2 <meta charset=urf-8> |
3 <title>EventTarget#dispatchEvent(): redispatching a native event</title> | 3 <title>EventTarget#dispatchEvent(): redispatching a native event</title> |
4 <script src="../../../../resources/testharness.js"></script> | 4 <script src="../../../../resources/testharness.js"></script> |
5 <script src="../../../../resources/testharnessreport.js"></script> | 5 <script src="../../../../resources/testharnessreport.js"></script> |
6 <div id=log></div> | 6 <div id=log></div> |
7 <script> | 7 <script> |
8 async_test(function() { | 8 async_test(function() { |
9 var event; | 9 var event; |
10 document.addEventListener("DOMContentLoaded", this.step_func(function(e) { | 10 document.addEventListener("DOMContentLoaded", this.step_func(function(e) { |
11 assert_true(e.isTrusted, "Should be trusted when first handled"); | 11 assert_true(e.isTrusted, "Should be trusted when first handled"); |
12 event = e; | 12 event = e; |
13 }), true); | 13 }), true); |
14 | 14 |
15 window.onload = this.step_func_done(function() { | 15 window.onload = this.step_func_done(function() { |
16 var received = 0; | 16 var received = 0; |
17 var target = document.createElement("span"); | 17 var target = document.createElement("span"); |
18 target.addEventListener("DOMContentLoaded", this.step_func(function(e) { | 18 target.addEventListener("DOMContentLoaded", this.step_func(function(e) { |
19 assert_false(e.isTrusted, "Should not be trusted during redispatching"); | 19 assert_false(e.isTrusted, "Should not be trusted during redispatching"); |
20 ++received; | 20 ++received; |
21 }), true); | 21 }), true); |
22 assert_true(event.isTrusted, "Should be trusted before redispatching"); | 22 assert_true(event.isTrusted, "Should be trusted before redispatching"); |
23 target.dispatchEvent(event); | 23 target.dispatchEvent(event); |
24 assert_false(event.isTrusted, "Should not be trusted after redispatching"); | 24 assert_false(event.isTrusted, "Should not be trusted after redispatching"); |
25 assert_equals(received, 1); | 25 assert_equals(received, 1); |
26 }); | 26 }); |
27 }); | 27 }); |
28 </script> | 28 </script> |
OLD | NEW |