diff --git a/testing/web-platform/meta/MANIFEST.json b/testing/web-platform/meta/MANIFEST.json index 813b2f5939ea..66da0804a449 100644 --- a/testing/web-platform/meta/MANIFEST.json +++ b/testing/web-platform/meta/MANIFEST.json @@ -537402,7 +537402,7 @@ "support" ], "dom/abort/event.any.js": [ - "25e9c1104acb9b0092d1303190588a3953cf635d", + "d41904ddfc56e5ef3e89d965a4e5fa392e996ef9", "testharness" ], "dom/collections/HTMLCollection-as-proto-length-get-throws.html": [ @@ -537634,7 +537634,7 @@ "testharness" ], "dom/interfaces.html": [ - "7d00e3a778083a91156f4e042c7abd270060a7fc", + "3308c9f3341c12ce99217309eba608e50cca669d", "testharness" ], "dom/lists/DOMTokenList-Iterable.html": [ diff --git a/testing/web-platform/tests/dom/abort/event.any.js b/testing/web-platform/tests/dom/abort/event.any.js index 3b25702c2e4c..a67e6f400fcf 100644 --- a/testing/web-platform/tests/dom/abort/event.any.js +++ b/testing/web-platform/tests/dom/abort/event.any.js @@ -17,6 +17,51 @@ test(t => { assert_true(s.aborted); c.abort(); -}, "AbortController() basics"); +}, "AbortController abort() should fire event synchronously"); + +test(t => { + const controller = new AbortController(); + const signal = controller.signal; + assert_equals(controller.signal, signal, + "value of controller.signal should not have changed"); + controller.abort(); + assert_equals(controller.signal, signal, + "value of controller.signal should still not have changed"); +}, "controller.signal should always return the same object"); + +test(t => { + const controller = new AbortController(); + const signal = controller.signal; + let eventCount = 0; + signal.onabort = () => { + ++eventCount; + }; + controller.abort(); + assert_true(signal.aborted); + assert_equals(eventCount, 1, "event handler should have been called once"); + controller.abort(); + assert_true(signal.aborted); + assert_equals(eventCount, 1, + "event handler should not have been called again"); +}, "controller.abort() should do nothing the second time it is called"); + +test(t => { + const controller = new AbortController(); + controller.abort(); + controller.signal.onabort = + t.unreached_func("event handler should not be called"); +}, "event handler should not be called if added after controller.abort()"); + +test(t => { + const controller = new AbortController(); + const signal = controller.signal; + signal.onabort = t.step_func(e => { + assert_equals(e.type, "abort", "event type should be abort"); + assert_equals(e.target, signal, "event target should be signal"); + assert_false(e.bubbles, "event should not bubble"); + assert_true(e.isTrusted, "event should be trusted"); + }); + controller.abort(); +}, "the abort event should have the right properties"); done(); diff --git a/testing/web-platform/tests/dom/interfaces.html b/testing/web-platform/tests/dom/interfaces.html index 8e9572d0f09c..3cb08f405a5a 100644 --- a/testing/web-platform/tests/dom/interfaces.html +++ b/testing/web-platform/tests/dom/interfaces.html @@ -18,8 +18,12 @@ element.setAttribute("bar", "baz"); var idlArray = new IdlArray(); -function doTest(idl) { - idlArray.add_idls(idl); +function doTest([html, dom]) { + // HTML is needed for EventHandler. Provide a dummy interface for + // LinkStyle which HTML depends on but we're not testing. + idlArray.add_untested_idls('interface LinkStyle {};'); + idlArray.add_untested_idls(html); + idlArray.add_idls(dom); idlArray.add_objects({ EventTarget: ['new EventTarget()'], Event: ['document.createEvent("Event")', 'new Event("foo")'], @@ -46,8 +50,13 @@ function doTest(idl) { idlArray.test(); } +function fetchText(url) { + return fetch(url).then((response) => response.text()); +} + promise_test(function() { - return fetch("/interfaces/dom.idl").then(response => response.text()) - .then(doTest); + return Promise.all(['/interfaces/html.idl', + '/interfaces/dom.idl'].map(fetchText)) + .then(doTest); }, "Test driver");