| 565 | value, |
| 566 | ReferenceInfoBuilder().withObject(globalKey).withProperty(name), |
| 567 | entry.exceptionTracker); |
| 568 | if (!entry.exceptionTracker) { |
| 569 | onRecoverableError("setValueToGlobalObject", entry.exceptionTracker); |
| 570 | return; |
| 571 | } |
| 572 | |
| 573 | auto globalObject = entry.jsContext.getGlobalObject(entry.exceptionTracker); |
| 574 | if (!entry.exceptionTracker) { |
| 575 | onRecoverableError("setValueToGlobalObject", entry.exceptionTracker); |
| 576 | return; |
| 577 | } |
| 578 | |
| 579 | entry.jsContext.setObjectProperty( |
| 580 | globalObject.get(), name.toStringView(), jsValueResult.get(), true, entry.exceptionTracker); |
| 581 | if (!entry.exceptionTracker) { |
| 582 | onRecoverableError("setValueToGlobalObject", entry.exceptionTracker); |
| 583 | return; |
| 584 | } |
| 585 | }); |
| 586 | } |
| 587 | |
| 588 | JSValueRef JavaScriptRuntime::runtimeOutputLog(JSFunctionNativeCallContext& callContext) { |
| 589 | LogType logType; |
| 590 | |
| 591 | auto logTypeIndex = static_cast<int>( |
| 592 | callContext.getContext().valueToInt(callContext.getParameter(0), callContext.getExceptionTracker())); |
| 593 | CHECK_CALL_CONTEXT(callContext); |
| 594 | |
| 595 | if (logTypeIndex == 0) { |
| 596 | logType = LogType::LogTypeDebug; |
| 597 | } else if (logTypeIndex == 1) { |
| 598 | logType = LogType::LogTypeInfo; |
| 599 | } else if (logTypeIndex == 2) { |
| 600 | logType = LogType::LogTypeInfo; |
| 601 | } else if (logTypeIndex == 3) { |
| 602 | logType = LogType::LogTypeWarn; |
| 603 | } else if (logTypeIndex == 4) { |
| 604 | logType = LogType::LogTypeError; |
| 605 | } else { |
| 606 | return callContext.throwError(Error("Invalid log type")); |
| 607 | } |
| 608 | |
| 609 | if (snap::kIsAppstoreBuild && !_logger->isEnabledForType(logType)) { |
| 610 | return callContext.getContext().newUndefined(); |
| 611 | } |
| 612 | |
| 613 | auto logContentString = |
| 614 | callContext.getContext().valueToStaticString(callContext.getParameter(1), callContext.getExceptionTracker()); |
| 615 | CHECK_CALL_CONTEXT(callContext); |
| 616 | |
| 617 | _logger->log(logType, logContentString->toStdString()); |
| 618 | |
| 619 | return callContext.getContext().newUndefined(); |
| 620 | } |
| 621 | |
| 622 | JSValueRef JavaScriptRuntime::runtimePostMessage(JSFunctionNativeCallContext& callContext) { |
nothing calls this directly
no test coverage detected