function doWithTimeout(fn, timeout) {
	if (!cacheTimeoutContext) {
		cacheTimeoutContext = createContext();
		cacheTimeoutScript = new Script('fn()', {
			__proto__: null,
			filename: 'timeout_bridge.js',
			displayErrors: false
		});
	}
	cacheTimeoutContext.fn = fn;
	try {
		return cacheTimeoutScript.runInContext(cacheTimeoutContext, {
			__proto__: null,
			displayErrors: false,
			timeout
		});
	} finally {
		cacheTimeoutContext.fn = null;
	}
}
Run a function with a specific timeout.

@private
@param {runWithTimeout} fn - Function to run with the specific timeout.
@param {number} timeout - The amount of time to give the function to finish.
@return {*} The value returned by the function.
@throws {Error} If the function took to long.