function fetch_spec(spec) {
    var url = '/interfaces/' + spec + '.idl';
    return fetch(url).then(function (r) {
        if (!r.ok) {
            throw new IdlHarnessError("Error fetching " + url + ".");
        }
        return r.text();
    }).then(idl => ({ spec, idl }));
}
fetch_spec is a shorthand for a Promise that fetches the spec's content.
Note: ShadowRealm-specific implementation in testharness-shadowrealm-inner.js