Tone.js/test/helper/Supports.ts

45 lines
1.4 KiB
TypeScript
Raw Normal View History

2024-05-01 19:55:52 +00:00
// import { UAParser } from "ua-parser-js";
2019-04-12 14:37:47 +00:00
2024-05-01 19:55:52 +00:00
// const parsed = new UAParser().getBrowser();
2019-04-12 14:37:47 +00:00
2024-05-01 19:55:52 +00:00
const name = "Chrome" as string;
2019-04-12 14:37:47 +00:00
2024-05-03 14:16:02 +00:00
const version = 121;
2019-04-12 14:37:47 +00:00
2019-05-23 18:00:49 +00:00
function is(browser, above?): boolean {
2024-05-01 19:55:52 +00:00
return false;
// above = above || 0;
// return name.includes(browser) && version >= above;
2019-04-12 14:37:47 +00:00
}
2019-05-23 18:00:49 +00:00
function isnt(browser, below?): boolean {
2019-04-12 14:37:47 +00:00
below = below || Infinity;
return !(name.includes(browser) && version <= below);
}
2019-05-23 18:00:49 +00:00
function isntVersion(browser, browserVersion?): boolean {
2019-04-12 14:37:47 +00:00
return name.includes(browser) && version !== browserVersion;
}
// can disconnect from a specific node
export const NODE_DISCONNECT = is("Chrome", 50);
// offline rendering matches Chrome closely
// chrome is the platform the files were rendered on
// so it is the default for continuity testing
export const CHROME_AUDIO_RENDERING = is("Chrome");
// firefox does not correctly handle the situation where
// a linear/exponential ramp is scheduled after setTargetValueAtTime
export const SCHEDULE_RAMP_AFTER_SET_TARGET = is("Chrome");
// if the tests run in focus
export const ONLINE_TESTING = isntVersion("Chrome", 71);
// the close method resolves a promise
2024-05-03 15:09:28 +00:00
export const AUDIO_CONTEXT_CLOSE_RESOLVES =
isnt("Firefox") && isnt("Safari", 10);
2019-04-12 14:37:47 +00:00
// if it supports gUM testing
export const GET_USER_MEDIA = isnt("Safari");
2020-04-15 03:54:22 +00:00
// firefox does not invoke AudioBufferSourceNode.onended in the offline context
export const OFFLINE_BUFFERSOURCE_ONENDED = isnt("Firefox");