void SuspendableScriptExecutor::run()
{
    ExecutionContext* context = getExecutionContext();
    DCHECK(context);
    if (!context->activeDOMObjectsAreSuspended()) {
        suspendIfNeeded();
        executeAndDestroySelf();
        return;
    }
    startOneShot(0, BLINK_FROM_HERE);
    suspendIfNeeded();
}
Exemplo n.º 2
0
FontFace::FontFace(ExecutionContext* context)
    : ActiveScriptWrappable(this)
    , ActiveDOMObject(context)
    , m_status(Unloaded)
{
    suspendIfNeeded();
}
Exemplo n.º 3
0
ExceptionOr<Ref<Worker>> Worker::create(ScriptExecutionContext& context, const String& url, JSC::RuntimeFlags runtimeFlags)
{
    ASSERT(isMainThread());

    // We don't currently support nested workers, so workers can only be created from documents.
    ASSERT_WITH_SECURITY_IMPLICATION(context.isDocument());

    auto worker = adoptRef(*new Worker(context, runtimeFlags));

    worker->suspendIfNeeded();

    bool shouldBypassMainWorldContentSecurityPolicy = context.shouldBypassMainWorldContentSecurityPolicy();
    auto scriptURL = worker->resolveURL(url, shouldBypassMainWorldContentSecurityPolicy);
    if (scriptURL.hasException())
        return scriptURL.releaseException();

    worker->m_shouldBypassMainWorldContentSecurityPolicy = shouldBypassMainWorldContentSecurityPolicy;

    // The worker context does not exist while loading, so we must ensure that the worker object is not collected, nor are its event listeners.
    worker->setPendingActivity(worker.ptr());

    worker->m_scriptLoader = WorkerScriptLoader::create();
    auto contentSecurityPolicyEnforcement = shouldBypassMainWorldContentSecurityPolicy ? ContentSecurityPolicyEnforcement::DoNotEnforce : ContentSecurityPolicyEnforcement::EnforceChildSrcDirective;
    worker->m_scriptLoader->loadAsynchronously(&context, scriptURL.releaseReturnValue(), FetchOptions::Mode::SameOrigin, contentSecurityPolicyEnforcement, worker->m_identifier, worker.ptr());
    return WTFMove(worker);
}
Exemplo n.º 4
0
IDBTransaction::IDBTransaction(IDBDatabase& database, const IDBTransactionInfo& info)
    : WebCore::IDBTransaction(database.scriptExecutionContext())
    , m_database(database)
    , m_info(info)
    , m_operationTimer(*this, &IDBTransaction::operationTimerFired)

{
    relaxAdoptionRequirement();

    if (m_info.mode() == IndexedDB::TransactionMode::VersionChange) {
        m_originalDatabaseInfo = std::make_unique<IDBDatabaseInfo>(m_database->info());
        m_startedOnServer = true;
    } else {
        activate();

        RefPtr<IDBTransaction> self;
        JSC::VM& vm = JSDOMWindowBase::commonVM();
        vm.whenIdle([self, this]() {
            deactivate();
        });

        establishOnServer();
    }

    suspendIfNeeded();
}
 LoaderClient(ExecutionContext* executionContext, BodyStreamBuffer* buffer, FetchDataLoader::Client* client)
     : ActiveDOMObject(executionContext)
     , m_buffer(buffer)
     , m_client(client)
 {
     suspendIfNeeded();
 }
IDBOpenDBRequest::IDBOpenDBRequest(IDBConnectionToServer& connection, ScriptExecutionContext* context, const IDBDatabaseIdentifier& databaseIdentifier, uint64_t version)
    : IDBRequest(connection, context)
    , m_databaseIdentifier(databaseIdentifier)
    , m_version(version)
{
    suspendIfNeeded();
}
Exemplo n.º 7
0
IDBRequest::IDBRequest(IDBConnectionToServer& connection, ScriptExecutionContext* context)
    : IDBOpenDBRequest(context)
    , m_connection(connection)
    , m_resourceIdentifier(connection)
{
    suspendIfNeeded();
}
Exemplo n.º 8
0
IDBTransaction::IDBTransaction(IDBDatabase& database, const IDBTransactionInfo& info, IDBOpenDBRequest* request)
    : WebCore::IDBTransaction(database.scriptExecutionContext())
    , m_database(database)
    , m_info(info)
    , m_operationTimer(*this, &IDBTransaction::operationTimerFired)
    , m_openDBRequest(request)

{
    LOG(IndexedDB, "IDBTransaction::IDBTransaction - %s", m_info.loggingString().utf8().data());

    relaxAdoptionRequirement();

    if (m_info.mode() == IndexedDB::TransactionMode::VersionChange) {
        ASSERT(m_openDBRequest);
        m_openDBRequest->setVersionChangeTransaction(*this);
        m_startedOnServer = true;
    } else {
        activate();

        RefPtr<IDBTransaction> self;
        JSC::VM& vm = JSDOMWindowBase::commonVM();
        vm.whenIdle([self, this]() {
            deactivate();
        });

        establishOnServer();
    }

    suspendIfNeeded();
}
Exemplo n.º 9
0
RefPtr<EventSource> EventSource::create(ScriptExecutionContext& context, const String& url, const Init& eventSourceInit, ExceptionCode& ec)
{
    if (url.isEmpty()) {
        ec = SYNTAX_ERR;
        return nullptr;
    }

    URL fullURL = context.completeURL(url);
    if (!fullURL.isValid()) {
        ec = SYNTAX_ERR;
        return nullptr;
    }

    // FIXME: Convert this to check the isolated world's Content Security Policy once webkit.org/b/104520 is solved.
    if (!context.contentSecurityPolicy()->allowConnectToSource(fullURL, context.shouldBypassMainWorldContentSecurityPolicy())) {
        // FIXME: Should this be throwing an exception?
        ec = SECURITY_ERR;
        return nullptr;
    }

    auto source = adoptRef(*new EventSource(context, fullURL, eventSourceInit));
    source->setPendingActivity(source.ptr());
    source->scheduleInitialConnect();
    source->suspendIfNeeded();
    return WTFMove(source);
}
Exemplo n.º 10
0
IDBIndex::IDBIndex(ScriptExecutionContext& context, const IDBIndexInfo& info, IDBObjectStore& objectStore)
    : ActiveDOMObject(&context)
    , m_info(info)
    , m_objectStore(objectStore)
{
    suspendIfNeeded();
}
Exemplo n.º 11
0
FontFaceSet::FontFaceSet(Document& document)
    : ActiveDOMObject(&document)
    , m_shouldFireLoadingEvent(false)
    , m_asyncRunner(this, &FontFaceSet::handlePendingEventsAndPromises)
{
    suspendIfNeeded();
}
Exemplo n.º 12
0
void SuspendableScriptExecutor::run()
{
    suspendIfNeeded();
    ExecutionContext* context = executionContext();
    ASSERT(context);
    if (context && !context->activeDOMObjectsAreSuspended())
        executeAndDestroySelf();
}
ScriptedIdleTaskController::ScriptedIdleTaskController(ExecutionContext* context)
    : ActiveDOMObject(context)
    , m_scheduler(Platform::current()->currentThread()->scheduler())
    , m_nextCallbackId(0)
    , m_suspended(false)
{
    suspendIfNeeded();
}
Exemplo n.º 14
0
ReadableStream::ReadableStream(ScriptExecutionContext& scriptExecutionContext)
    : ActiveDOMObject(&scriptExecutionContext)
{
#ifndef NDEBUG
    readableStreamCounter.increment();
#endif
    suspendIfNeeded();
}
Exemplo n.º 15
0
IDBRequest::IDBRequest(ScriptExecutionContext& context, IDBObjectStore& objectStore, IDBTransaction& transaction)
    : IDBOpenDBRequest(&context)
    , m_transaction(&transaction)
    , m_connection(transaction.serverConnection())
    , m_resourceIdentifier(transaction.serverConnection())
    , m_source(IDBAny::create(objectStore))
{
    suspendIfNeeded();
}
Exemplo n.º 16
0
IDBDatabase::IDBDatabase(ScriptExecutionContext& context, IDBConnectionToServer& connection, const IDBResultData& resultData)
    : WebCore::IDBDatabase(&context)
    , m_connection(connection)
    , m_info(resultData.databaseInfo())
{
    suspendIfNeeded();
    relaxAdoptionRequirement();
    m_connection->registerDatabaseConnection(*this);
}
Exemplo n.º 17
0
FontLoader::FontLoader(Document* document)
    : ActiveDOMObject(document)
    , m_document(document)
    , m_numLoadingFromCSS(0)
    , m_numLoadingFromJS(0)
    , m_pendingEventsTimer(*this, &FontLoader::pendingEventsTimerFired)
{
    suspendIfNeeded();
}
CanvasCaptureMediaStreamTrack::CanvasCaptureMediaStreamTrack(
    const CanvasCaptureMediaStreamTrack& track,
    MediaStreamComponent* component)
    : MediaStreamTrack(track.m_canvasElement->getExecutionContext(), component),
      m_canvasElement(track.m_canvasElement),
      m_drawListener(track.m_drawListener) {
  suspendIfNeeded();
  m_canvasElement->addListener(m_drawListener.get());
}
Exemplo n.º 19
0
FontFaceSet::FontFaceSet(Document& document)
    : ActiveDOMObject(&document)
    , m_shouldFireLoadingEvent(false)
    , m_isLoading(false)
    , m_ready(new ReadyProperty(executionContext(), this, ReadyProperty::Ready))
    , m_asyncRunner(this, &FontFaceSet::handlePendingEventsAndPromises)
{
    suspendIfNeeded();
}
CanvasCaptureMediaStreamTrack::CanvasCaptureMediaStreamTrack(
    MediaStreamComponent* component,
    HTMLCanvasElement* element,
    std::unique_ptr<WebCanvasCaptureHandler> handler)
    : MediaStreamTrack(element->getExecutionContext(), component),
      m_canvasElement(element) {
  suspendIfNeeded();
  m_drawListener = AutoCanvasDrawListener::create(std::move(handler));
  m_canvasElement->addListener(m_drawListener.get());
}
Exemplo n.º 21
0
IDBObjectStore::IDBObjectStore(ScriptExecutionContext& context, const IDBObjectStoreInfo& info, IDBTransaction& transaction)
    : ActiveDOMObject(&context)
    , m_info(info)
    , m_originalInfo(info)
    , m_transaction(transaction)
{
    ASSERT(currentThread() == m_transaction->database().originThreadID());

    suspendIfNeeded();
}
Exemplo n.º 22
0
IDBDatabase::IDBDatabase(ScriptExecutionContext& context, IDBClient::IDBConnectionProxy& connectionProxy, const IDBResultData& resultData)
    : IDBActiveDOMObject(&context)
    , m_connectionProxy(connectionProxy)
    , m_info(resultData.databaseInfo())
    , m_databaseConnectionIdentifier(resultData.databaseConnectionIdentifier())
{
    LOG(IndexedDB, "IDBDatabase::IDBDatabase - Creating database %s with version %" PRIu64 " connection %" PRIu64 " (%p)", m_info.name().utf8().data(), m_info.version(), m_databaseConnectionIdentifier, this);
    suspendIfNeeded();
    m_connectionProxy->registerDatabaseConnection(*this);
}
Exemplo n.º 23
0
IDBIndex::IDBIndex(ScriptExecutionContext& context, const IDBIndexInfo& info, IDBObjectStore& objectStore)
    : ActiveDOMObject(&context)
    , m_info(info)
    , m_originalInfo(info)
    , m_objectStore(objectStore)
{
    ASSERT(currentThread() == m_objectStore.transaction().database().originThreadID());

    suspendIfNeeded();
}
Exemplo n.º 24
0
MediaStreamTrack::MediaStreamTrack(MediaStreamTrack* other)
    : ActiveDOMObject(other->scriptExecutionContext())
    , m_privateTrack(*other->privateTrack().clone())
    , m_eventDispatchScheduled(false)
    , m_stoppingTrack(false)
{
    suspendIfNeeded();

    m_privateTrack->setClient(this);
}
Exemplo n.º 25
0
ReadableStream::ReadableStream(ScriptExecutionContext& scriptExecutionContext, Ref<ReadableStreamSource>&& source)
    : ActiveDOMObject(&scriptExecutionContext)
    , m_state(State::Readable)
    , m_source(WTF::move(source))
{
#ifndef NDEBUG
    readableStreamCounter.increment();
#endif
    suspendIfNeeded();
}
IDBDatabase::IDBDatabase(ScriptExecutionContext& context, IDBConnectionToServer& connection, const IDBResultData& resultData)
    : WebCore::IDBDatabase(&context)
    , m_serverConnection(connection)
    , m_info(resultData.databaseInfo())
    , m_databaseConnectionIdentifier(resultData.databaseConnectionIdentifier())
{
    LOG(IndexedDB, "IDBDatabase::IDBDatabase - Creating database %s with version %" PRIu64, m_info.name().utf8().data(), m_info.version());
    suspendIfNeeded();
    relaxAdoptionRequirement();
    m_serverConnection->registerDatabaseConnection(*this);
}
Exemplo n.º 27
0
ReadableStreamReader::ReadableStreamReader(ReadableStream& stream)
    : ActiveDOMObject(stream.scriptExecutionContext())
{
#ifndef NDEBUG
    readableStreamReaderCounter.increment();
#endif
    suspendIfNeeded();
    ASSERT_WITH_MESSAGE(!stream.reader(), "A ReadableStream cannot be locked by two readers at the same time.");
    m_stream = &stream;
    stream.lock(*this);
}
Exemplo n.º 28
0
ExceptionOr<Ref<OfflineAudioContext>> OfflineAudioContext::create(ScriptExecutionContext& context, unsigned numberOfChannels, size_t numberOfFrames, float sampleRate)
{
    // FIXME: Add support for workers.
    if (!is<Document>(context))
        return Exception { NOT_SUPPORTED_ERR };
    if (!numberOfChannels || numberOfChannels > 10 || !numberOfFrames || !isSampleRateRangeGood(sampleRate))
        return Exception { SYNTAX_ERR };
    auto audioContext = adoptRef(*new OfflineAudioContext(downcast<Document>(context), numberOfChannels, numberOfFrames, sampleRate));
    audioContext->suspendIfNeeded();
    return WTFMove(audioContext);
}
Exemplo n.º 29
0
MediaStreamTrack::MediaStreamTrack(ScriptExecutionContext& context, MediaStreamTrackPrivate& privateTrack)
    : RefCounted()
    , ActiveDOMObject(&context)
    , m_privateTrack(privateTrack)
    , m_eventDispatchScheduled(false)
    , m_stoppingTrack(false)
{
    suspendIfNeeded();

    m_privateTrack->setClient(this);
}
Exemplo n.º 30
0
ReadableStream::ReadableStream(ExecutionContext* executionContext, UnderlyingSource* source)
    : ActiveDOMObject(executionContext)
    , m_source(source)
    , m_isStarted(false)
    , m_isDraining(false)
    , m_isPulling(false)
    , m_state(Waiting)
    , m_ready(new WaitPromise(executionContext, this, WaitPromise::Ready))
    , m_closed(new ClosedPromise(executionContext, this, ClosedPromise::Closed))
{
    suspendIfNeeded();
}