void ScriptRunner::notifyScriptReady(ScriptLoader* scriptLoader, ExecutionType executionType)
{
    RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(scriptLoader);
    switch (executionType) {
    case ASYNC_EXECUTION:
        // RELEASE_ASSERT makes us crash in a controlled way in error cases
        // where the ScriptLoader is associated with the wrong ScriptRunner
        // (otherwise we'd cause a use-after-free in ~ScriptRunner when it tries
        // to detach).
        RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(m_pendingAsyncScripts.contains(scriptLoader));

        m_pendingAsyncScripts.remove(scriptLoader);
        m_asyncScriptsToExecuteSoon.append(scriptLoader);

        postTask(BLINK_FROM_HERE);

        break;

    case IN_ORDER_EXECUTION:
        RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(m_numberOfInOrderScriptsWithPendingNotification > 0);
        m_numberOfInOrderScriptsWithPendingNotification--;

        while (!m_pendingInOrderScripts.isEmpty() && m_pendingInOrderScripts.first()->isReady()) {
            m_inOrderScriptsToExecuteSoon.append(m_pendingInOrderScripts.takeFirst());
            postTask(BLINK_FROM_HERE);
        }

        break;
    }
}
void ScriptRunner::notifyScriptLoadError(ScriptLoader* scriptLoader, ExecutionType executionType)
{
    switch (executionType) {
    case ASYNC_EXECUTION: {
        // RELEASE_ASSERT makes us crash in a controlled way in error cases
        // where the ScriptLoader is associated with the wrong ScriptRunner
        // (otherwise we'd cause a use-after-free in ~ScriptRunner when it tries
        // to detach).
        bool foundLoader = m_pendingAsyncScripts.contains(scriptLoader);
#if !ENABLE(OILPAN)
        // If the ScriptRunner has been disposed of, no pending scripts remain.
        foundLoader = foundLoader || m_isDisposed;
#endif
        RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(foundLoader);
        m_pendingAsyncScripts.remove(scriptLoader);
        break;
    }
    case IN_ORDER_EXECUTION:
        bool foundLoader = removePendingInOrderScript(scriptLoader);
#if !ENABLE(OILPAN)
        foundLoader = foundLoader || m_isDisposed;
#endif
        RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(foundLoader);
        break;
    }
    m_document->decrementLoadEventDelayCount();
}
v8::Handle<v8::Object> V8TestInterfaceDocument::createWrapper(PassRefPtrWillBeRawPtr<TestInterfaceDocument> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
{
    ASSERT(impl);
    ASSERT(!DOMDataStore::containsWrapper<V8TestInterfaceDocument>(impl.get(), isolate));
    if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) {
        const WrapperTypeInfo* actualInfo = ScriptWrappable::fromObject(impl.get())->typeInfo();
        // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapperTypeInfo. These will both have
        // the same object de-ref functions, though, so use that as the basis of the check.
        RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction);
    }

    if (LocalFrame* frame = impl->frame()) {
        if (frame->script().initializeMainWorld()) {
            // initializeMainWorld may have created a wrapper for the object, retry from the start.
            v8::Handle<v8::Object> wrapper = DOMDataStore::getWrapper<V8TestInterfaceDocument>(impl.get(), isolate);
            if (!wrapper.IsEmpty())
                return wrapper;
        }
    }
    v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &wrapperTypeInfo, toInternalPointer(impl.get()), isolate);
    if (UNLIKELY(wrapper.IsEmpty()))
        return wrapper;

    installPerContextEnabledProperties(wrapper, impl.get(), isolate);
    V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceDocument>(impl, &wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Dependent);
    return wrapper;
}
void ScriptRunner::notifyScriptLoadError(ScriptLoader* scriptLoader, ExecutionType executionType)
{
    switch (executionType) {
    case ASYNC_EXECUTION: {
        // RELEASE_ASSERT makes us crash in a controlled way in error cases
        // where the ScriptLoader is associated with the wrong ScriptRunner
        // (otherwise we'd cause a use-after-free in ~ScriptRunner when it tries
        // to detach).
        RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(m_pendingAsyncScripts.contains(scriptLoader));
        m_pendingAsyncScripts.remove(scriptLoader);
        break;
    }
    case IN_ORDER_EXECUTION:
        RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(removePendingInOrderScript(scriptLoader));
        break;
    }
    m_document->decrementLoadEventDelayCount();
}
void ScriptRunner::notifyScriptReady(ScriptLoader* scriptLoader, ExecutionType executionType)
{
    RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(scriptLoader);
    switch (executionType) {
    case ASYNC_EXECUTION:
        // RELEASE_ASSERT makes us crash in a controlled way in error cases
        // where the ScriptLoader is associated with the wrong ScriptRunner
        // (otherwise we'd cause a use-after-free in ~ScriptRunner when it tries
        // to detach).
        RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(m_pendingAsyncScripts.contains(scriptLoader));
        m_scriptsToExecuteSoon.append(scriptLoader);
        m_pendingAsyncScripts.remove(scriptLoader);
        break;

    case IN_ORDER_EXECUTION:
        RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(!m_scriptsToExecuteInOrder.isEmpty());
        break;
    }
    postTaskIfOneIsNotAlreadyInFlight();
}
bool ScriptRunner::removePendingInOrderScript(ScriptLoader* scriptLoader)
{
    for (auto it = m_pendingInOrderScripts.begin(); it != m_pendingInOrderScripts.end(); ++it) {
        if (*it == scriptLoader) {
            m_pendingInOrderScripts.remove(it);
            RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(m_numberOfInOrderScriptsWithPendingNotification > 0);
            m_numberOfInOrderScriptsWithPendingNotification--;
            return true;
        }
    }
    return false;
}
v8::Handle<v8::Object> V8TestException::createWrapper(PassRefPtr<TestException> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
{
    ASSERT(impl);
    ASSERT(!DOMDataStore::containsWrapper<V8TestException>(impl.get(), isolate));
    if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) {
        const WrapperTypeInfo* actualInfo = ScriptWrappable::fromObject(impl.get())->typeInfo();
        // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapperTypeInfo. These will both have
        // the same object de-ref functions, though, so use that as the basis of the check.
        RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction);
    }

    v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &wrapperTypeInfo, toInternalPointer(impl.get()), isolate);
    if (UNLIKELY(wrapper.IsEmpty()))
        return wrapper;

    installConditionallyEnabledProperties(wrapper, isolate);
    V8DOMWrapper::associateObjectWithWrapper<V8TestException>(impl, &wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Independent);
    return wrapper;
}
Beispiel #8
0
void NodeRareData::incrementConnectedSubframeCount(unsigned amount)
{
    RELEASE_ASSERT_WITH_SECURITY_IMPLICATION((m_connectedFrameCount + amount) <= FrameHost::maxNumberOfFrames);
    m_connectedFrameCount += amount;
}