bool ScriptGlobalObject::set(ScriptState* scriptState, const char* name, InjectedScriptHost* value) { JSLockHolder lock(scriptState); JSDOMGlobalObject* globalObject = jsCast<JSDOMGlobalObject*>(scriptState->lexicalGlobalObject()); globalObject->putDirect(scriptState->vm(), Identifier(scriptState, name), toJS(scriptState, globalObject, value)); return handleException(scriptState); }
PassRefPtr<JSLazyEventListener> createAttributeEventListener(Node* node, Attribute* attr) { ASSERT(node); ASSERT(attr); if (attr->isNull()) return 0; int lineNumber = 1; String sourceURL; JSObject* wrapper = 0; // FIXME: We should be able to provide accurate source information for frameless documents, too (e.g. for importing nodes from XMLHttpRequest.responseXML). if (Frame* frame = node->document()->frame()) { ScriptController* scriptController = frame->script(); if (!scriptController->canExecuteScripts()) return 0; if (!scriptController->xssAuditor()->canCreateInlineEventListener(attr->localName().string(), attr->value())) { // This script is not safe to execute. return 0; } lineNumber = scriptController->eventHandlerLineNumber(); sourceURL = node->document()->url().string(); JSC::JSLock lock(SilenceAssertionsOnly); JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(node->document(), mainThreadNormalWorld()); wrapper = asObject(toJS(globalObject->globalExec(), globalObject, node)); } return JSLazyEventListener::create(attr->localName().string(), eventParameterName(node->isSVGElement()), attr->value(), node, sourceURL, lineNumber, wrapper, mainThreadNormalWorld()); }
bool ScriptGlobalObject::set(ScriptState* scriptState, const char* name, InjectedScriptHost* value) { JSLock lock(SilenceAssertionsOnly); JSDOMGlobalObject* globalObject = static_cast<JSDOMGlobalObject*>(scriptState->lexicalGlobalObject()); globalObject->putDirect(scriptState->globalData(), Identifier(scriptState, name), toJS(scriptState, globalObject, value)); return handleException(scriptState); }
void injectInternalsObject(JSContextRef context) { JSLock lock(SilenceAssertionsOnly); ExecState* exec = toJS(context); JSDOMGlobalObject* globalObject = static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()); globalObject->putDirect(exec->globalData(), Identifier(exec, "internals"), toJS(exec, globalObject, Internals::create())); }
void setJSWorkerContextOnmessage(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); WorkerContext* imp = static_cast<WorkerContext*>(static_cast<JSWorkerContext*>(thisObject)->impl()); JSDOMGlobalObject* globalObject = static_cast<JSWorkerContext*>(thisObject); imp->setOnmessage(globalObject->createJSAttributeEventListener(value)); }
ScriptObject InjectedScriptHost::createInjectedScript(const String& source, ScriptState* scriptState, long id) { SourceCode sourceCode = makeSource(stringToUString(source)); JSLock lock(SilenceAssertionsOnly); JSDOMGlobalObject* globalObject = static_cast<JSDOMGlobalObject*>(scriptState->lexicalGlobalObject()); JSValue globalThisValue = scriptState->globalThisValue(); Completion comp = JSMainThreadExecState::evaluate(scriptState, globalObject->globalScopeChain(), sourceCode, globalThisValue); if (comp.complType() != JSC::Normal && comp.complType() != JSC::ReturnValue) return ScriptObject(); JSValue functionValue = comp.value(); CallData callData; CallType callType = functionValue.getCallData(callData); if (callType == CallTypeNone) return ScriptObject(); MarkedArgumentBuffer args; args.append(toJS(scriptState, globalObject, this)); args.append(globalThisValue); args.append(jsNumber(scriptState, id)); args.append(jsString(scriptState, String("JSC"))); JSValue result = JSC::call(scriptState, functionValue, callType, callData, globalThisValue, args); if (result.isObject()) return ScriptObject(scriptState, result.getObject()); return ScriptObject(); }
void setJSWebSocketOnclose(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); WebSocket* imp = static_cast<WebSocket*>(static_cast<JSWebSocket*>(thisObject)->impl()); JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnclose(globalObject->createJSAttributeEventListener(value)); }
void setJSXMLHttpRequestOnreadystatechange(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(static_cast<JSXMLHttpRequest*>(thisObject)->impl()); JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec); if (!globalObject) return; imp->setOnreadystatechange(globalObject->createJSAttributeEventListener(value)); }
JSObject* JSLazyEventListener::initializeJSFunction(ScriptExecutionContext* executionContext) const { ASSERT(executionContext); ASSERT(executionContext->isDocument()); if (!executionContext) return 0; Document* document = static_cast<Document*>(executionContext); if (!document->frame()) return 0; if (!document->contentSecurityPolicy()->allowInlineEventHandlers()) return 0; ScriptController* script = document->frame()->script(); if (!script->canExecuteScripts(AboutToExecuteScript) || script->isPaused()) return 0; JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(executionContext, isolatedWorld()); if (!globalObject) return 0; ExecState* exec = globalObject->globalExec(); MarkedArgumentBuffer args; args.append(jsNontrivialString(exec, stringToUString(m_eventParameterName))); args.append(jsString(exec, m_code)); JSObject* jsFunction = constructFunctionSkippingEvalEnabledCheck(exec, exec->lexicalGlobalObject(), args, Identifier(exec, stringToUString(m_functionName)), stringToUString(m_sourceURL), m_position); // FIXME: is globalExec ok? if (exec->hadException()) { reportCurrentException(exec); exec->clearException(); return 0; } JSFunction* listenerAsFunction = jsCast<JSFunction*>(jsFunction); if (m_originalNode) { if (!wrapper()) { // Ensure that 'node' has a JavaScript wrapper to mark the event listener we're creating. JSLock lock(SilenceAssertionsOnly); // FIXME: Should pass the global object associated with the node setWrapper(exec->globalData(), asObject(toJS(exec, globalObject, m_originalNode))); } // Add the event's home element to the scope // (and the document, and the form - see JSHTMLElement::eventHandlerScope) listenerAsFunction->setScope(exec->globalData(), jsCast<JSNode*>(wrapper())->pushEventHandlerScope(exec, listenerAsFunction->scope())); } // Since we only parse once, there's no need to keep data used for parsing around anymore. m_functionName = String(); m_code = String(); m_eventParameterName = String(); m_sourceURL = String(); return jsFunction; }
JSValue* JSWorker::addEventListener(ExecState* exec, const ArgList& args) { JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutionContext()); if (!globalObject) return jsUndefined(); RefPtr<JSUnprotectedEventListener> listener = globalObject->findOrCreateJSUnprotectedEventListener(exec, args.at(exec, 1)); if (!listener) return jsUndefined(); impl()->addEventListener(args.at(exec, 0)->toString(exec), listener.release(), args.at(exec, 2)->toBoolean(exec)); return jsUndefined(); }
JSValue JSXMLHttpRequestUpload::addEventListener(ExecState* exec, const ArgList& args) { JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutionContext()); if (!globalObject) return jsUndefined(); RefPtr<JSEventListener> listener = globalObject->findOrCreateJSEventListener(args.at(1)); if (!listener) return jsUndefined(); impl()->addEventListener(args.at(0).toString(exec), listener.release(), args.at(2).toBoolean(exec)); return jsUndefined(); }
JSValue* JSWorker::removeEventListener(ExecState* exec, const ArgList& args) { JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutionContext()); if (!globalObject) return jsUndefined(); JSUnprotectedEventListener* listener = globalObject->findJSUnprotectedEventListener(exec, args.at(exec, 1)); if (!listener) return jsUndefined(); impl()->removeEventListener(args.at(exec, 0)->toString(exec), listener, args.at(exec, 2)->toBoolean(exec)); return jsUndefined(); }
JSValue JSXMLHttpRequestUpload::removeEventListener(ExecState* exec, const ArgList& args) { JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutionContext()); if (!globalObject) return jsUndefined(); JSEventListener* listener = globalObject->findJSEventListener(args.at(1)); if (!listener) return jsUndefined(); impl()->removeEventListener(args.at(0).toString(exec), listener, args.at(2).toBoolean(exec)); return jsUndefined(); }
JSValuePtr JSNode::removeEventListener(ExecState* exec, const ArgList& args) { JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutionContext()); if (!globalObject) return jsUndefined(); if (JSEventListener* listener = globalObject->findJSEventListener(args.at(exec, 1))) impl()->removeEventListener(args.at(exec, 0).toString(exec), listener, args.at(exec, 2).toBoolean(exec)); return jsUndefined(); }
void resetInternalsObject(JSContextRef context) { JSLock lock(SilenceAssertionsOnly); ExecState* exec = toJS(context); JSDOMGlobalObject* globalObject = static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()); Internals * internals = toInternals(globalObject->getDirect(exec->globalData(), Identifier(exec, Internals::internalsId))); if (internals) { ScriptExecutionContext* scriptContext = globalObject->scriptExecutionContext(); if (scriptContext->isDocument()) internals->reset(static_cast<Document*>(scriptContext)); } }
void reportException(ExecState* exec, JSValue exception, CachedScript* cachedScript) { if (isTerminatedExecutionException(exception)) return; Interpreter::ErrorHandlingMode mode(exec); RefPtr<ScriptCallStack> callStack(createScriptCallStackFromException(exec, exception, ScriptCallStack::maxCallStackSizeToCapture)); exec->clearException(); exec->clearSupplementaryExceptionInfo(); JSDOMGlobalObject* globalObject = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()); if (JSDOMWindow* window = jsDynamicCast<JSDOMWindow*>(globalObject)) { if (!window->impl()->isCurrentlyDisplayedInFrame()) return; } int lineNumber = 0; int columnNumber = 0; String exceptionSourceURL; if (callStack->size()) { const ScriptCallFrame& frame = callStack->at(0); lineNumber = frame.lineNumber(); columnNumber = frame.columnNumber(); exceptionSourceURL = frame.sourceURL(); } else { // There may not be an exceptionStack for a <script> SyntaxError. Fallback to getting at least the line and sourceURL from the exception. JSObject* exceptionObject = exception.toObject(exec); JSValue lineValue = exceptionObject->getDirect(exec->vm(), Identifier(exec, "line")); lineNumber = lineValue && lineValue.isNumber() ? int(lineValue.toNumber(exec)) : 0; JSValue columnValue = exceptionObject->getDirect(exec->vm(), Identifier(exec, "column")); columnNumber = columnValue && columnValue.isNumber() ? int(columnValue.toNumber(exec)) : 0; JSValue sourceURLValue = exceptionObject->getDirect(exec->vm(), Identifier(exec, "sourceURL")); exceptionSourceURL = sourceURLValue && sourceURLValue.isString() ? sourceURLValue.toString(exec)->value(exec) : ASCIILiteral("undefined"); } String errorMessage; if (ExceptionBase* exceptionBase = toExceptionBase(exception)) errorMessage = exceptionBase->message() + ": " + exceptionBase->description(); else { // FIXME: <http://webkit.org/b/115087> Web Inspector: WebCore::reportException should not evaluate JavaScript handling exceptions // If this is a custon exception object, call toString on it to try and get a nice string representation for the exception. errorMessage = exception.toString(exec)->value(exec); exec->clearException(); exec->clearSupplementaryExceptionInfo(); } ScriptExecutionContext* scriptExecutionContext = globalObject->scriptExecutionContext(); scriptExecutionContext->reportException(errorMessage, lineNumber, columnNumber, exceptionSourceURL, callStack->size() ? callStack : 0, cachedScript); }
void HTMLPlugInImageElement::didAddUserAgentShadowRoot(ShadowRoot* root) { HTMLPlugInElement::didAddUserAgentShadowRoot(root); if (displayState() >= PreparingPluginReplacement) return; Page* page = document().page(); if (!page) return; // Reset any author styles that may apply as we only want explicit // styles defined in the injected user agents stylesheets to specify // the look-and-feel of the snapshotted plug-in overlay. root->setResetStyleInheritance(true); String mimeType = loadedMimeType(); DOMWrapperWorld& isolatedWorld = plugInImageElementIsolatedWorld(); document().ensurePlugInsInjectedScript(isolatedWorld); ScriptController& scriptController = document().frame()->script(); JSDOMGlobalObject* globalObject = JSC::jsCast<JSDOMGlobalObject*>(scriptController.globalObject(isolatedWorld)); JSC::ExecState* exec = globalObject->globalExec(); JSC::JSLockHolder lock(exec); JSC::MarkedArgumentBuffer argList; argList.append(toJS(exec, globalObject, root)); argList.append(jsString(exec, titleText(page, mimeType))); argList.append(jsString(exec, subtitleText(page, mimeType))); // This parameter determines whether or not the snapshot overlay should always be visible over the plugin snapshot. // If no snapshot was found then we want the overlay to be visible. argList.append(JSC::jsBoolean(!m_snapshotImage)); // It is expected the JS file provides a createOverlay(shadowRoot, title, subtitle) function. JSC::JSObject* overlay = globalObject->get(exec, JSC::Identifier::fromString(exec, "createOverlay")).toObject(exec); if (!overlay) { ASSERT(exec->hadException()); exec->clearException(); return; } JSC::CallData callData; JSC::CallType callType = overlay->methodTable()->getCallData(overlay, callData); if (callType == JSC::CallType::None) return; JSC::call(exec, overlay, callType, callData, globalObject, argList); exec->clearException(); }
void JSDOMGlobalObject::visitChildren(JSCell* cell, SlotVisitor& visitor) { JSDOMGlobalObject* thisObject = jsCast<JSDOMGlobalObject*>(cell); ASSERT_GC_OBJECT_INHERITS(thisObject, info()); Base::visitChildren(thisObject, visitor); for (auto& structure : thisObject->structures().values()) visitor.append(&structure); for (auto& constructor : thisObject->constructors().values()) visitor.append(&constructor); thisObject->m_builtinInternalFunctions.visit(visitor); }
InjectedScript InjectedScriptHost::injectedScriptFor(ScriptState* scriptState) { JSLock lock(SilenceAssertionsOnly); JSDOMGlobalObject* globalObject = static_cast<JSDOMGlobalObject*>(scriptState->lexicalGlobalObject()); JSObject* injectedScript = globalObject->injectedScript(); if (injectedScript) return InjectedScript(ScriptObject(scriptState, injectedScript)); ASSERT(!m_injectedScriptSource.isEmpty()); pair<long, ScriptObject> injectedScriptObject = injectScript(m_injectedScriptSource, scriptState); globalObject->setInjectedScript(injectedScriptObject.second.jsObject()); InjectedScript result(injectedScriptObject.second); m_idToInjectedScript.set(injectedScriptObject.first, result); return result; }
TransferSharedPtr<WebValue> WebFrame::getWrappedAttributeEventListener(const char* name) { AtomicString type(name); Frame* coreFrame = core(this); if (!coreFrame && !coreFrame->document()) return 0; EventListener* listener = coreFrame->document()->getWindowAttributeEventListener(type); if (listener && listener->type() == EventListener::JSEventListenerType) { JSEventListener* jsListener = static_cast<JSEventListener*>(listener); JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(coreFrame->document(), mainThreadNormalWorld()); JSC::ExecState* execState = globalObject->globalExec(); return WebValue::createInstance(BALValue::create(coreFrame, execState, jsListener->jsFunction(coreFrame->document())).get()); } return 0; }
void reportException(ExecState* exec, Exception* exception, CachedScript* cachedScript) { RELEASE_ASSERT(exec->vm().currentThreadIsHoldingAPILock()); if (isTerminatedExecutionException(exception)) return; ErrorHandlingScope errorScope(exec->vm()); RefPtr<ScriptCallStack> callStack(createScriptCallStackFromException(exec, exception, ScriptCallStack::maxCallStackSizeToCapture)); exec->clearException(); exec->clearLastException(); JSDOMGlobalObject* globalObject = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()); if (JSDOMWindow* window = jsDynamicCast<JSDOMWindow*>(globalObject)) { if (!window->impl().isCurrentlyDisplayedInFrame()) return; } int lineNumber = 0; int columnNumber = 0; String exceptionSourceURL; if (const ScriptCallFrame* callFrame = callStack->firstNonNativeCallFrame()) { lineNumber = callFrame->lineNumber(); columnNumber = callFrame->columnNumber(); exceptionSourceURL = callFrame->sourceURL(); } String errorMessage; JSValue exceptionValue = exception->value(); if (ExceptionBase* exceptionBase = toExceptionBase(exceptionValue)) errorMessage = exceptionBase->message() + ": " + exceptionBase->description(); else { // FIXME: <http://webkit.org/b/115087> Web Inspector: WebCore::reportException should not evaluate JavaScript handling exceptions // If this is a custon exception object, call toString on it to try and get a nice string representation for the exception. if (ErrorInstance* error = jsDynamicCast<ErrorInstance*>(exceptionValue)) errorMessage = error->sanitizedToString(exec); else errorMessage = exceptionValue.toString(exec)->value(exec); // We need to clear any new exception that may be thrown in the toString() call above. // reportException() is not supposed to be making new exceptions. exec->clearException(); exec->clearLastException(); } ScriptExecutionContext* scriptExecutionContext = globalObject->scriptExecutionContext(); scriptExecutionContext->reportException(errorMessage, lineNumber, columnNumber, exceptionSourceURL, callStack->size() ? callStack : 0, cachedScript); }
JSC::JSValue createWrapper(JSDOMGlobalObject& globalObject, NodeList& nodeList) { // FIXME: Adopt reportExtraMemoryVisited, and switch to reportExtraMemoryAllocated. // https://bugs.webkit.org/show_bug.cgi?id=142595 globalObject.vm().heap.deprecatedReportExtraMemory(nodeList.memoryCost()); return createNewWrapper<JSNodeList>(&globalObject, &nodeList); }
InjectedScript InjectedScriptHost::injectedScriptFor(ScriptState* scriptState) { JSLock lock(SilenceAssertionsOnly); JSDOMGlobalObject* globalObject = static_cast<JSDOMGlobalObject*>(scriptState->lexicalGlobalObject()); JSObject* injectedScript = globalObject->injectedScript(); if (injectedScript) return InjectedScript(ScriptObject(scriptState, injectedScript)); ASSERT(!m_injectedScriptSource.isEmpty()); ScriptObject injectedScriptObject = createInjectedScript(m_injectedScriptSource, this, scriptState, m_nextInjectedScriptId); globalObject->setInjectedScript(injectedScriptObject.jsObject()); InjectedScript result(injectedScriptObject); m_idToInjectedScript.set(m_nextInjectedScriptId, result); m_nextInjectedScriptId++; return result; }
void JSMutationCallback::call(const Vector<RefPtr<MutationRecord> >& mutations, MutationObserver* observer) { if (!canInvokeCallback()) return; RefPtr<JSMutationCallback> protect(this); JSLockHolder lock(m_isolatedWorld->globalData()); if (!m_callback) return; JSValue callback = m_callback.get(); CallData callData; CallType callType = getCallData(callback, callData); if (callType == CallTypeNone) { ASSERT_NOT_REACHED(); return; } ScriptExecutionContext* context = scriptExecutionContext(); if (!context) return; ASSERT(context->isDocument()); JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(context, m_isolatedWorld.get()); ExecState* exec = globalObject->globalExec(); JSValue jsObserver = toJS(exec, globalObject, observer); MarkedArgumentBuffer args; args.append(jsArray(exec, globalObject, mutations)); args.append(jsObserver); globalObject->globalData().timeoutChecker.start(); InspectorInstrumentationCookie cookie = JSMainThreadExecState::instrumentFunctionCall(context, callType, callData); JSMainThreadExecState::call(exec, callback, callType, callData, jsObserver, args); InspectorInstrumentation::didCallFunction(cookie); globalObject->globalData().timeoutChecker.stop(); if (exec->hadException()) reportCurrentException(exec); }
void JSMutationCallback::call(const Vector<RefPtr<MutationRecord>>& mutations, MutationObserver* observer) { if (!canInvokeCallback()) return; Ref<JSMutationCallback> protect(*this); JSLockHolder lock(m_isolatedWorld->vm()); if (!m_callback) return; JSValue callback = m_callback.get(); CallData callData; CallType callType = getCallData(callback, callData); if (callType == CallType::None) { ASSERT_NOT_REACHED(); return; } ScriptExecutionContext* context = scriptExecutionContext(); if (!context) return; ASSERT(context->isDocument()); JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(context, *m_isolatedWorld); ExecState* exec = globalObject->globalExec(); JSValue jsObserver = toJS(exec, globalObject, observer); MarkedArgumentBuffer args; args.append(jsArray(exec, globalObject, mutations)); args.append(jsObserver); InspectorInstrumentationCookie cookie = JSMainThreadExecState::instrumentFunctionCall(context, callType, callData); NakedPtr<Exception> exception; JSMainThreadExecState::profiledCall(exec, JSC::ProfilingReason::Other, callback, callType, callData, jsObserver, args, exception); InspectorInstrumentation::didCallFunction(cookie, context); if (exception) reportException(exec, exception); }
static inline bool checkReadableStream(JSDOMGlobalObject& globalObject, JSReadableStream* readableStream, JSC::JSValue function) { auto& state = *globalObject.globalExec(); ASSERT(function); JSC::MarkedArgumentBuffer arguments; arguments.append(readableStream); ASSERT(!arguments.hasOverflowed()); return ReadableStreamInternal::callFunction(state, function, JSC::jsUndefined(), arguments).isTrue(); }
void JSErrorHandler::handleEvent(ScriptExecutionContext* scriptExecutionContext, Event* event) { if (!event->hasInterface(eventNames().interfaceForErrorEvent)) return JSEventListener::handleEvent(scriptExecutionContext, event); ASSERT(scriptExecutionContext); if (!scriptExecutionContext) return; ErrorEvent* errorEvent = static_cast<ErrorEvent*>(event); JSLock lock(SilenceAssertionsOnly); JSObject* jsFunction = this->jsFunction(scriptExecutionContext); if (!jsFunction) return; JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(scriptExecutionContext, isolatedWorld()); if (!globalObject) return; ExecState* exec = globalObject->globalExec(); CallData callData; CallType callType = jsFunction->methodTable()->getCallData(jsFunction, callData); if (callType != CallTypeNone) { RefPtr<JSErrorHandler> protectedctor(this); Event* savedEvent = globalObject->currentEvent(); globalObject->setCurrentEvent(event); MarkedArgumentBuffer args; args.append(jsString(exec, errorEvent->message())); args.append(jsString(exec, errorEvent->filename())); args.append(jsNumber(errorEvent->lineno())); JSGlobalData& globalData = globalObject->globalData(); DynamicGlobalObjectScope globalObjectScope(globalData, globalData.dynamicGlobalObject ? globalData.dynamicGlobalObject : globalObject); JSValue thisValue = globalObject->methodTable()->toThisObject(globalObject, exec); globalData.timeoutChecker.start(); JSValue returnValue = scriptExecutionContext->isDocument() ? JSMainThreadExecState::call(exec, jsFunction, callType, callData, thisValue, args) : JSC::call(exec, jsFunction, callType, callData, thisValue, args); globalData.timeoutChecker.stop(); globalObject->setCurrentEvent(savedEvent); if (exec->hadException()) reportCurrentException(exec); else { if (returnValue.isTrue()) event->preventDefault(); } } }
void JSWorkerContextErrorHandler::handleEvent(ScriptExecutionContext* scriptExecutionContext, Event* event) { ASSERT(scriptExecutionContext); if (!scriptExecutionContext) return; JSLock lock(SilenceAssertionsOnly); JSObject* jsFunction = this->jsFunction(scriptExecutionContext); if (!jsFunction) return; JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(scriptExecutionContext, isolatedWorld()); if (!globalObject) return; ExecState* exec = globalObject->globalExec(); CallData callData; CallType callType = jsFunction->getCallData(callData); if (callType != CallTypeNone) { ref(); Event* savedEvent = globalObject->currentEvent(); globalObject->setCurrentEvent(event); ASSERT(event->isErrorEvent()); ErrorEvent* errorEvent = static_cast<ErrorEvent*>(event); MarkedArgumentBuffer args; args.append(jsString(exec, errorEvent->message())); args.append(jsString(exec, errorEvent->filename())); args.append(jsNumber(exec, errorEvent->lineno())); JSGlobalData* globalData = globalObject->globalData(); DynamicGlobalObjectScope globalObjectScope(exec, globalData->dynamicGlobalObject ? globalData->dynamicGlobalObject : globalObject); JSValue thisValue = globalObject->toThisObject(exec); globalData->timeoutChecker.start(); JSValue returnValue = JSC::call(exec, jsFunction, callType, callData, thisValue, args); globalData->timeoutChecker.stop(); globalObject->setCurrentEvent(savedEvent); if (exec->hadException()) reportCurrentException(exec); else { bool retvalbool; if (returnValue.getBoolean(retvalbool) && !retvalbool) event->preventDefault(); } deref(); } }
void JSDOMGlobalObject::visitChildren(JSCell* cell, SlotVisitor& visitor) { JSDOMGlobalObject* thisObject = jsCast<JSDOMGlobalObject*>(cell); ASSERT_GC_OBJECT_INHERITS(thisObject, info()); Base::visitChildren(thisObject, visitor); { auto locker = holdLock(thisObject->m_gcLock); for (auto& structure : thisObject->structures(locker).values()) visitor.append(&structure); for (auto& constructor : thisObject->constructors(locker).values()) visitor.append(&constructor); for (auto& deferredPromise : thisObject->deferredPromises(locker)) deferredPromise->visitAggregate(visitor); } thisObject->m_builtinInternalFunctions.visit(visitor); }
bool JSDatabaseCallback::handleEvent(ScriptExecutionContext* context, DatabaseSync* database) { ASSERT(m_data); ASSERT(context); RefPtr<JSDatabaseCallback> protect(this); JSLock lock(SilenceAssertionsOnly); JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(context, m_isolatedWorld.get()); if (!globalObject) return true; ExecState* exec = globalObject->globalExec(); MarkedArgumentBuffer args; args.append(toJS(exec, database)); bool raisedException = false; m_data->invokeCallback(args, &raisedException); return !raisedException; }