testing/web-platform/tests/dom/interfaces.html
author Chris Nardi <christopherncarmel@hotmail.com>
Wed, 06 Jun 2018 17:24:24 +0000
changeset 478974 afbc5459b7badb33b629464376dcb975cbeaf35a
parent 461088 9816ae2341d485cc52ed758e39704a3b53c530aa
child 481789 cfdc0066db98dca2ca7906306dec82570ab551b5
permissions -rw-r--r--
Bug 1465551 [wpt PR 11252] - Add MouseEvent/MouseEventInit as untested DOM IDLs, a=testonly Automatic update from web-platform-testsMove HTML from untested IDL to a dependency IDL for DOM The DOM idlharness test would not run as dependencies for the HTML IDL file were not declared. However, we don't need to define HTML as untested IDL -- using the new dependency IDL feature generates the same tests but prevents the current dependency problem. -- wpt-commits: 2ae39a003cba3b1292d5239f6043281d9277d25b wpt-pr: 11252

<!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_dependency_idls(html);
  idlArray.add_idls(dom);
  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>