| 2219 | JSValueRef JavaScriptRuntime::queueMicrotask(JSFunctionNativeCallContext& callContext) { |
| 2220 | callContext.getContext().enqueueMicrotask(callContext.getParameter(0), callContext.getExceptionTracker()); |
| 2221 | return callContext.getContext().newUndefined(); |
| 2222 | } |
| 2223 | |
| 2224 | JSValueRef JavaScriptRuntime::performanceNow(JSFunctionNativeCallContext& callContext) { |
| 2225 | return callContext.getContext().newNumber(_upTime.elapsed().milliseconds()); |
| 2226 | } |
| 2227 | |
| 2228 | template<typename T> |
| 2229 | Ref<T> thisFromCallContext(JSFunctionNativeCallContext& callContext) { |
| 2230 | auto val = |
| 2231 | callContext.getContext().valueToWrappedObject(callContext.getThisValue(), callContext.getExceptionTracker()); |
| 2232 | return castOrNull<T>(val); |
| 2233 | } |
| 2234 | |
| 2235 | // worker.onmessage = func |
| 2236 | JSValueRef JavaScriptRuntime::workerSetOnMessage(JSFunctionNativeCallContext& callContext) { |
| 2237 | auto worker = thisFromCallContext<JavaScriptWorker>(callContext); |
| 2238 | if (worker != nullptr) { |
| 2239 | worker->setHostOnMessage(callContext.getParameterAsFunction(0)); |
| 2240 | CHECK_CALL_CONTEXT(callContext); |
| 2241 | } |
| 2242 | return callContext.getContext().newUndefined(); |
| 2243 | } |
| 2244 | |
| 2245 | // worker.postMessage(any) |
| 2246 | JSValueRef JavaScriptRuntime::workerPostMessage(JSFunctionNativeCallContext& callContext) { |
| 2247 | auto worker = thisFromCallContext<JavaScriptWorker>(callContext); |
| 2248 | if (worker != nullptr) { |
| 2249 | worker->postMessage(callContext.getParameterAsValue(0)); |
| 2250 | CHECK_CALL_CONTEXT(callContext); |
| 2251 | } |
| 2252 | return callContext.getContext().newUndefined(); |
| 2253 | } |
| 2254 | |
| 2255 | // worker.terminate() |
| 2256 | JSValueRef JavaScriptRuntime::workerTerminate(JSFunctionNativeCallContext& callContext) { |
| 2257 | auto worker = thisFromCallContext<JavaScriptWorker>(callContext); |
| 2258 | if (worker != nullptr) { |
| 2259 | worker->close(); |
| 2260 | } |
| 2261 | return callContext.getContext().newUndefined(); |
| 2262 | } |
| 2263 | |
| 2264 | constexpr static std::string_view getBuildType() { |
| 2265 | if (snap::kIsDevBuild) { |
| 2266 | return "dev"; |
| 2267 | } |
| 2268 | |
| 2269 | if (snap::kIsGoldBuild) { |
| 2270 | return "gold"; |
| 2271 | } |
| 2272 | |
| 2273 | if (snap::kIsAlphaBuild) { |
| 2274 | return "alpha"; |
| 2275 | } |
| 2276 | |
| 2277 | if (snap::kIsAppstoreBuild) { |
| 2278 | return "prod"; |
nothing calls this directly
no test coverage detected