diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /testing/web-platform/tests/html/webappapis/scripting/events/event-handler-spec-example.html | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/web-platform/tests/html/webappapis/scripting/events/event-handler-spec-example.html')
-rw-r--r-- | testing/web-platform/tests/html/webappapis/scripting/events/event-handler-spec-example.html | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/webappapis/scripting/events/event-handler-spec-example.html b/testing/web-platform/tests/html/webappapis/scripting/events/event-handler-spec-example.html new file mode 100644 index 000000000..c06806e3c --- /dev/null +++ b/testing/web-platform/tests/html/webappapis/scripting/events/event-handler-spec-example.html @@ -0,0 +1,65 @@ +<!DOCTYPE html> +<title>Event handler invocation order</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +var objects = [{}, function() {}, new Number(42), new String()]; +var primitives = [42, null, undefined, ""]; +objects.forEach(function(object) { + var t = async_test("Event handler listeners should be registered when they " + + "are first set to an object value (" + + format_value(object) + ")."); + t.step(function() { + var i = 0; + var uncalled = "t.step(function() { assert_unreached('First event handler.') })" + var button = document.createElement('button'); + button.onclick = object; // event handler listener is registered here + button.addEventListener('click', t.step_func(function () { assert_equals(++i, 2) }), false); + button.setAttribute('onclick', uncalled); + button.addEventListener('click', t.step_func(function () { assert_equals(++i, 3) }), false); + button.onclick = t.step_func(function () { assert_equals(++i, 1); }); + button.addEventListener('click', t.step_func(function () { assert_equals(++i, 4) }), false); + button.click() + assert_equals(button.getAttribute("onclick"), uncalled) + assert_equals(i, 4); + t.done() + }); +}); +primitives.forEach(function(primitive) { + var t = async_test("Event handler listeners should be registered when they " + + "are first set to an object value (" + + format_value(primitive) + ")."); + t.step(function() { + var i = 0; + var uncalled = "t.step(function() { assert_unreached('First event handler.') })" + var button = document.createElement('button'); + button.onclick = primitive; + button.addEventListener('click', t.step_func(function () { assert_equals(++i, 1) }), false); + button.setAttribute('onclick', uncalled); // event handler listener is registered here + button.addEventListener('click', t.step_func(function () { assert_equals(++i, 3) }), false); + button.onclick = t.step_func(function () { assert_equals(++i, 2); }); + button.addEventListener('click', t.step_func(function () { assert_equals(++i, 4) }), false); + button.click() + assert_equals(button.getAttribute("onclick"), uncalled) + assert_equals(i, 4); + t.done() + }); +}); +var t = async_test("Event handler listeners should be registered when they " + + "are first set to an object value."); +t.step(function() { + var i = 0; + var uncalled = "t.step(function() { assert_unreached('First event handler.') })" + var button = document.createElement('button'); + button.addEventListener('click', t.step_func(function () { assert_equals(++i, 1) }), false); + button.setAttribute('onclick', uncalled); // event handler listener is registered here + button.addEventListener('click', t.step_func(function () { assert_equals(++i, 3) }), false); + button.onclick = t.step_func(function () { assert_equals(++i, 2); }); + button.addEventListener('click', t.step_func(function () { assert_equals(++i, 4) }), false); + button.click() + assert_equals(button.getAttribute("onclick"), uncalled) + assert_equals(i, 4); + t.done() +}); +</script> |