Changeset 135383 in webkit


Ignore:
Timestamp:
Nov 21, 2012 4:24:24 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

[V8] Add context checks to WorldContextHandle and V8DOMWindowShell
https://bugs.webkit.org/show_bug.cgi?id=101573

Patch by Dan Carney <dcarney@google.com> on 2012-11-21
Reviewed by Adam Barth.

Added a bunch of assertions to ensure the problems with IndexedDB
contexts cannot reemerge.

No new tests. No change in functionality.

  • bindings/v8/V8DOMWindowShell.cpp:

(WebCore):
(WebCore::V8DOMWindowShell::assertContextHasCorrectPrototype):

  • bindings/v8/V8DOMWindowShell.h:

(V8DOMWindowShell):
(WebCore::V8DOMWindowShell::isolated):

  • bindings/v8/WorldContextHandle.cpp:

(WebCore::WorldContextHandle::WorldContextHandle):

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r135379 r135383  
     12012-11-21  Dan Carney  <dcarney@google.com>
     2
     3        [V8] Add context checks to WorldContextHandle and V8DOMWindowShell
     4        https://bugs.webkit.org/show_bug.cgi?id=101573
     5
     6        Reviewed by Adam Barth.
     7
     8        Added a bunch of assertions to ensure the problems with IndexedDB
     9        contexts cannot reemerge.
     10
     11        No new tests. No change in functionality.
     12
     13        * bindings/v8/V8DOMWindowShell.cpp:
     14        (WebCore):
     15        (WebCore::V8DOMWindowShell::assertContextHasCorrectPrototype):
     16        * bindings/v8/V8DOMWindowShell.h:
     17        (V8DOMWindowShell):
     18        (WebCore::V8DOMWindowShell::isolated):
     19        * bindings/v8/WorldContextHandle.cpp:
     20        (WebCore::WorldContextHandle::WorldContextHandle):
     21
    1222012-11-21  Harald Alvestrand  <hta@google.com>
    223
  • trunk/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp

    r135377 r135383  
    6565
    6666namespace WebCore {
     67
     68#ifndef NDEBUG
     69void V8DOMWindowShell::assertContextHasCorrectPrototype()
     70{
     71    ASSERT(isMainThread());
     72    ASSERT(V8DOMWrapper::isWrapperOfType(toInnerGlobalObject(v8::Context::GetEntered()), &V8DOMWindow::info));
     73}
     74#endif
    6775
    6876static void checkDocumentWrapper(v8::Handle<v8::Object> wrapper, Document* document)
     
    329337
    330338    V8DOMWrapper::setDOMWrapper(v8::Handle<v8::Object>::Cast(windowWrapper->GetPrototype()), &V8DOMWindow::info, window);
    331     V8DOMWrapper::createDOMWrapper(PassRefPtr<DOMWindow>(window), &V8DOMWindow::info, windowWrapper);
    332339
    333340    // Install the windowWrapper as the prototype of the innerGlobalObject.
     
    347354    V8DOMWrapper::setDOMWrapper(innerGlobalObject, &V8DOMWindow::info, window);
    348355    innerGlobalObject->SetPrototype(windowWrapper);
     356    V8DOMWrapper::createDOMWrapper(PassRefPtr<DOMWindow>(window), &V8DOMWindow::info, windowWrapper);
    349357    return true;
    350358}
  • trunk/Source/WebCore/bindings/v8/V8DOMWindowShell.h

    r135309 r135383  
    8181    void destroyGlobal();
    8282
     83#ifndef NDEBUG
     84    static void assertContextHasCorrectPrototype();
     85#endif
     86
    8387    static V8DOMWindowShell* isolated(v8::Handle<v8::Context> context)
    8488    {
     89#ifndef NDEBUG
     90        assertContextHasCorrectPrototype();
     91#endif
    8592        return static_cast<V8DOMWindowShell*>(context->GetAlignedPointerFromEmbedderData(v8ContextIsolatedWindowShell));
    8693    }
  • trunk/Source/WebCore/bindings/v8/WorldContextHandle.cpp

    r135309 r135383  
    3636#include "V8DOMWindow.h"
    3737#include "V8DOMWindowShell.h"
     38#include "V8DedicatedWorkerContext.h"
     39#include "V8SharedWorkerContext.h"
    3840
    3941namespace WebCore {
     
    4244    : m_worldToUse(worldToUse)
    4345{
     46    ASSERT(worldToUse != UseWorkerWorld);
     47
    4448    if (worldToUse == UseMainWorld || worldToUse == UseWorkerWorld)
    4549        return;
    4650
    47     if (v8::Context::InContext()) {
    48         v8::Handle<v8::Context> context = v8::Context::GetCurrent();
     51    if (!v8::Context::InContext())
     52        CRASH();
     53
     54    v8::Handle<v8::Context> context = v8::Context::GetCurrent();
    4955#if ENABLE(WORKERS)
    50         if (UNLIKELY(!V8DOMWrapper::isWrapperOfType(toInnerGlobalObject(context), &V8DOMWindow::info))) {
    51             m_worldToUse = UseWorkerWorld;
    52             return;
    53         }
     56    if (UNLIKELY(!V8DOMWrapper::isWrapperOfType(toInnerGlobalObject(context), &V8DOMWindow::info))) {
     57#if ENABLE(SHARED_WORKERS)
     58        ASSERT(V8DOMWrapper::isWrapperOfType(toInnerGlobalObject(context)->GetPrototype(), &V8DedicatedWorkerContext::info) || V8DOMWrapper::isWrapperOfType(toInnerGlobalObject(context)->GetPrototype(), &V8SharedWorkerContext::info));
     59#else
     60        ASSERT(V8DOMWrapper::isWrapperOfType(toInnerGlobalObject(context)->GetPrototype(), &V8DedicatedWorkerContext::info));
    5461#endif
    55         if (V8DOMWindowShell::isolated(context)) {
    56             m_context = SharedPersistent<v8::Context>::create(context);
    57             return;
    58         }
     62        m_worldToUse = UseWorkerWorld;
     63        return;
     64    }
     65#endif
     66
     67    if (V8DOMWindowShell::isolated(context)) {
     68        m_context = SharedPersistent<v8::Context>::create(context);
     69        return;
    5970    }
    6071
Note: See TracChangeset for help on using the changeset viewer.