| Michael[tm] Smith | 1f66bf6 | 2014-05-26 07:50:19 | [diff] [blame] | 1 | <!doctype html> |
| 2 | <title>EventSource IDL tests</title> |
| 3 | <script src=/resources/testharness.js></script> |
| 4 | <script src=/resources/testharnessreport.js></script> |
| 5 | <script src=/resources/WebIDLParser.js></script> |
| 6 | <script src=/resources/idlharness.js></script> |
| 7 | |
| 8 | <h1>EventSource IDL tests</h1> |
| 9 | <div id=log></div> |
| 10 | |
| 11 | <script type=text/plain> |
| Rakina Zata Amni | 56e2df8 | 2017-11-10 07:33:36 | [diff] [blame] | 12 | [Constructor(), Exposed=(Window,Worker)] |
| Keith Yeung | 4b9f9ac | 2017-01-30 20:09:22 | [diff] [blame] | 13 | interface EventTarget { |
| 14 | void addEventListener(DOMString type, EventListener? listener, optional (AddEventListenerOptions or boolean) options); |
| 15 | void removeEventListener(DOMString type, EventListener? listener, optional (EventListenerOptions or boolean) options); |
| 16 | boolean dispatchEvent(Event event); |
| 17 | }; |
| 18 | callback interface EventListener { |
| 19 | void handleEvent(Event event); |
| 20 | }; |
| 21 | dictionary EventListenerOptions { |
| 22 | boolean capture = false; |
| 23 | }; |
| 24 | dictionary AddEventListenerOptions : EventListenerOptions { |
| 25 | boolean passive = false; |
| 26 | boolean once = false; |
| 27 | }; |
| Michael[tm] Smith | 1f66bf6 | 2014-05-26 07:50:19 | [diff] [blame] | 28 | [Constructor(DOMString url, optional EventSourceInit eventSourceInitDict)] |
| 29 | interface EventSource : EventTarget { |
| 30 | readonly attribute DOMString url; |
| 31 | readonly attribute boolean withCredentials; |
| 32 | |
| 33 | // ready state |
| 34 | const unsigned short CONNECTING = 0; |
| 35 | const unsigned short OPEN = 1; |
| 36 | const unsigned short CLOSED = 2; |
| 37 | readonly attribute unsigned short readyState; |
| 38 | |
| 39 | // networking |
| 40 | attribute EventHandler onopen; |
| 41 | attribute EventHandler onmessage; |
| 42 | attribute EventHandler onerror; |
| 43 | void close(); |
| 44 | }; |
| 45 | |
| 46 | dictionary EventSourceInit { |
| 47 | boolean withCredentials = false; |
| 48 | }; |
| 49 | |
| 50 | [TreatNonCallableAsNull] |
| 51 | callback EventHandlerNonNull = any (Event event); |
| 52 | typedef EventHandlerNonNull? EventHandler; |
| 53 | </script> |
| 54 | <script> |
| 55 | "use strict"; |
| 56 | var idlArray; |
| 57 | setup(function() { |
| Ms2ger | 53321dc | 2015-05-18 08:31:44 | [diff] [blame] | 58 | idlArray = new IdlArray(); |
| 59 | [].forEach.call(document.querySelectorAll("script[type=text\\/plain]"), function(node) { |
| 60 | if (node.className == "untested") { |
| 61 | idlArray.add_untested_idls(node.textContent); |
| 62 | } else { |
| 63 | idlArray.add_idls(node.textContent); |
| 64 | } |
| 65 | }); |
| Michael[tm] Smith | 1f66bf6 | 2014-05-26 07:50:19 | [diff] [blame] | 66 | }, {explicit_done:true}); |
| 67 | window.onload = function() { |
| Ms2ger | 53321dc | 2015-05-18 08:31:44 | [diff] [blame] | 68 | idlArray.add_objects({ |
| 69 | EventSource: ['new EventSource("http://foo")'], |
| 70 | }); |
| 71 | idlArray.test(); |
| 72 | done(); |
| Michael[tm] Smith | 1f66bf6 | 2014-05-26 07:50:19 | [diff] [blame] | 73 | }; |
| 74 | </script> |