| <!doctype html> |
| <meta charset=utf-8> |
| <title>DOM IDL tests</title> |
| <script src=/resources/testharness.js></script> |
| <script src=/resources/testharnessreport.js></script> |
| <script src=/resources/WebIDLParser.js></script> |
| <script src=/resources/idlharness.js></script> |
| |
| <h1>DOM IDL tests</h1> |
| <div id=log></div> |
| <script> |
| "use strict"; |
| var xmlDoc = document.implementation.createDocument(null, "", null); |
| var detachedRange = document.createRange(); |
| detachedRange.detach(); |
| var element = xmlDoc.createElementNS(null, "test"); |
| element.setAttribute("bar", "baz"); |
| |
| var idlArray = new IdlArray(); |
| |
| function doTest([html, dom]) { |
| idlArray.add_idls(dom); |
| idlArray.add_dependency_idls(html); |
| idlArray.add_objects({ |
| EventTarget: ['new EventTarget()'], |
| Event: ['document.createEvent("Event")', 'new Event("foo")'], |
| CustomEvent: ['new CustomEvent("foo")'], |
| AbortController: ['new AbortController()'], |
| AbortSignal: ['new AbortController().signal'], |
| Document: ['new Document()'], |
| XMLDocument: ['xmlDoc'], |
| DOMImplementation: ['document.implementation'], |
| DocumentFragment: ['document.createDocumentFragment()'], |
| DocumentType: ['document.doctype'], |
| Element: ['element'], |
| Attr: ['document.querySelector("[id]").attributes[0]'], |
| Text: ['document.createTextNode("abc")'], |
| ProcessingInstruction: ['xmlDoc.createProcessingInstruction("abc", "def")'], |
| Comment: ['document.createComment("abc")'], |
| Range: ['document.createRange()', 'detachedRange'], |
| NodeIterator: ['document.createNodeIterator(document.body, NodeFilter.SHOW_ALL, null, false)'], |
| TreeWalker: ['document.createTreeWalker(document.body, NodeFilter.SHOW_ALL, null, false)'], |
| NodeList: ['document.querySelectorAll("script")'], |
| HTMLCollection: ['document.body.children'], |
| DOMTokenList: ['document.body.classList'], |
| }); |
| idlArray.test(); |
| } |
| |
| function fetchText(url) { |
| return fetch(url).then((response) => response.text()); |
| } |
| |
| promise_test(function() { |
| return Promise.all(['/interfaces/html.idl', |
| '/interfaces/dom.idl'].map(fetchText)) |
| .then(doTest); |
| }, "Test driver"); |
| </script> |