summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/resources/test/idl-helper.js
blob: 2b73527ff2becedfa7d191d7d82e76c1c378ff25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"use strict";

var typedefFrom = interfaceFrom;
var dictionaryFrom = interfaceFrom;
function interfaceFrom(i) {
    var idl = new IdlArray();
    idl.add_idls(i);
    for (var prop in idl.members) {
        return idl.members[prop];
    }
}

function memberFrom(m) {
    var idl = new IdlArray();
    idl.add_idls('interface A { ' + m + '; };');
    return idl.members["A"].members[0];
}

function typeFrom(type) {
    var ast = WebIDL2.parse('interface Foo { ' + type + ' a(); };');
    ast = ast[0]; // get the first fragment
    ast = ast.members[0]; // get the first member
    return ast.idlType; // get the type of the first field
}