https://github.com/web-platform-tests/wpt
Revision 041ab0412dfe7eb981ef6aa8de259d118f2b4c70 authored by Yutaka Hirano on 25 April 2018, 06:05:51 UTC, committed by Yutaka Hirano on 25 April 2018, 06:05:51 UTC
1 parent b98931a
Raw File
Tip revision: 041ab0412dfe7eb981ef6aa8de259d118f2b4c70 authored by Yutaka Hirano on 25 April 2018, 06:05:51 UTC
fix
Tip revision: 041ab04
interfaces.html
<!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]) {
  // 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")'],
    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>
back to top