Merge from Chromium at DEPS revision r207203

This commit was generated by merge_to_master.py.

Change-Id: Ia8a6c2a997232c94108d8937f8c2556f42be1c37
diff --git a/Source/bindings/v8/CustomElementHelpers.cpp b/Source/bindings/v8/CustomElementHelpers.cpp
index a55d062..9d4b40d 100644
--- a/Source/bindings/v8/CustomElementHelpers.cpp
+++ b/Source/bindings/v8/CustomElementHelpers.cpp
@@ -34,13 +34,19 @@
 
 #include "HTMLNames.h"
 #include "SVGNames.h"
-#include "V8CustomElementConstructor.h"
+#include "V8Document.h"
 #include "V8HTMLElementWrapperFactory.h"
 #include "V8SVGElementWrapperFactory.h"
 #include "bindings/v8/DOMDataStore.h"
 #include "bindings/v8/DOMWrapperWorld.h"
 #include "bindings/v8/ScriptController.h"
+#include "bindings/v8/ScriptState.h"
+#include "bindings/v8/UnsafePersistent.h"
+#include "bindings/v8/V8HiddenPropertyName.h"
+#include "bindings/v8/V8PerContextData.h"
 #include "core/dom/CustomElementRegistry.h"
+#include "core/dom/Element.h"
+#include "core/dom/ExceptionCode.h"
 #include "core/dom/Node.h"
 #include "core/html/HTMLElement.h"
 #include "core/html/HTMLUnknownElement.h"
@@ -48,18 +54,34 @@
 
 namespace WebCore {
 
+void CustomElementHelpers::didRegisterDefinition(CustomElementDefinition* definition, ScriptExecutionContext* executionContext, const HashSet<Element*>& upgradeCandidates, const ScriptValue& prototypeValue)
+{
+    ASSERT(v8::Isolate::GetCurrent());
+    v8::Handle<v8::Context> context = toV8Context(executionContext, mainThreadNormalWorld());
+    ASSERT(context == v8::Isolate::GetCurrent()->GetCurrentContext());
+
+    // Bindings retrieve the prototype when needed from per-context data.
+    v8::Handle<v8::Object> prototype = v8::Handle<v8::Object>::Cast(prototypeValue.v8Value());
+    v8::Persistent<v8::Object> persistentPrototype(context->GetIsolate(), prototype);
+    V8PerContextData::from(context)->customElementPrototypes()->add(definition->type(), UnsafePersistent<v8::Object>(persistentPrototype));
+
+    // Upgrade any wrappers already created for this definition
+    upgradeWrappers(context, upgradeCandidates, prototype);
+}
+
 v8::Handle<v8::Object> CustomElementHelpers::createWrapper(PassRefPtr<Element> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate, const CreateWrapperFunction& createTypeExtensionUpgradeCandidateWrapper)
 {
     ASSERT(impl);
 
-    // The constructor and registered lifecycle callbacks should be visible only from main world.
-    // FIXME: This shouldn't be needed once each custom element has its own FunctionTemplate
-    // https://bugs.webkit.org/show_bug.cgi?id=108138
-
     // FIXME: creationContext.IsEmpty() should never happen. Remove
     // this when callers (like InspectorController::inspect) are fixed
     // to never pass an empty creation context.
-    if (!CustomElementHelpers::isFeatureAllowed(creationContext.IsEmpty() ? v8::Context::GetCurrent() : creationContext->CreationContext())) {
+    v8::Handle<v8::Context> context = creationContext.IsEmpty() ? isolate->GetCurrentContext() : creationContext->CreationContext();
+
+    // The constructor and registered lifecycle callbacks should be visible only from main world.
+    // FIXME: This shouldn't be needed once each custom element has its own FunctionTemplate
+    // https://bugs.webkit.org/show_bug.cgi?id=108138
+    if (!CustomElementHelpers::isFeatureAllowed(context)) {
         v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &V8HTMLElement::info, impl.get(), isolate);
         if (!wrapper.IsEmpty())
             V8DOMWrapper::associateObjectWithWrapper(impl, &V8HTMLElement::info, wrapper, isolate, WrapperConfiguration::Dependent);
@@ -71,8 +93,7 @@
     if (!definition)
         return createUpgradeCandidateWrapper(impl, creationContext, isolate, createTypeExtensionUpgradeCandidateWrapper);
 
-    v8::Handle<v8::Object> prototype = v8::Handle<v8::Object>::Cast(definition->prototype().v8Value());
-
+    v8::Handle<v8::Object> prototype = V8PerContextData::from(context)->customElementPrototypes()->get(definition->type()).newLocal(isolate);
     WrapperTypeInfo* typeInfo = CustomElementHelpers::findWrapperType(prototype);
     if (!typeInfo) {
         // FIXME: When can this happen?
@@ -121,27 +142,79 @@
     }
 }
 
-bool CustomElementHelpers::initializeConstructorWrapper(CustomElementConstructor* constructor, const ScriptValue& prototype, ScriptState* state)
+static void constructCustomElement(const v8::FunctionCallbackInfo<v8::Value>& args)
 {
-    ASSERT(isFeatureAllowed(state));
-    ASSERT(!prototype.v8Value().IsEmpty() && prototype.v8Value()->IsObject());
-    v8::Handle<v8::Value> wrapperValue = toV8(constructor, state->context()->Global(), state->context()->GetIsolate());
-    if (wrapperValue.IsEmpty() || !wrapperValue->IsObject())
-        return false;
-    v8::Handle<v8::Function> wrapper = v8::Handle<v8::Function>::Cast(wrapperValue);
-    // - Object::ForceSet() nor Object::SetAccessor Doesn't work against the "prototype" property of function objects.
-    // - Set()-ing here is safe because
-    //   - Hooking Object.prototype's defineProperty() with "prototype" or "constructor" also doesn't affect on these properties of function objects and
-    //   - Using Set() is okay becaues each function has "prototype" property from start and Objects.prototype cannot intercept the property access.
-    v8::Handle<v8::String> prototypeKey = v8String("prototype", state->context()->GetIsolate());
-    ASSERT(wrapper->HasOwnProperty(prototypeKey));
-    wrapper->Set(prototypeKey, prototype.v8Value(), v8::ReadOnly);
+    v8::Isolate* isolate = args.GetIsolate();
 
-    v8::Handle<v8::String> constructorKey = v8String("constructor", state->context()->GetIsolate());
-    v8::Handle<v8::Object> prototypeObject = v8::Handle<v8::Object>::Cast(prototype.v8Value());
-    ASSERT(!prototypeObject->HasOwnProperty(constructorKey));
-    prototypeObject->ForceSet(constructorKey, wrapper, v8::ReadOnly);
-    return true;
+    if (!args.IsConstructCall()) {
+        throwTypeError("DOM object constructor cannot be called as a function.", isolate);
+        return;
+    }
+
+    if (args.Length() > 0) {
+        throwTypeError(0, isolate);
+        return;
+    }
+
+    Document* document = V8Document::toNative(v8::Handle<v8::Object>::Cast(args.Callee()->GetHiddenValue(V8HiddenPropertyName::document())));
+    V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, namespaceURI, args.Callee()->GetHiddenValue(V8HiddenPropertyName::namespaceURI()));
+    V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, name, args.Callee()->GetHiddenValue(V8HiddenPropertyName::name()));
+    v8::Handle<v8::Value> maybeType = args.Callee()->GetHiddenValue(V8HiddenPropertyName::type());
+    V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, type, maybeType);
+
+    ExceptionCode ec = 0;
+    CustomElementRegistry::CallbackDeliveryScope deliveryScope;
+    RefPtr<Element> element = document->createElementNS(namespaceURI, name, maybeType->IsNull() ? nullAtom : type, ec);
+    if (ec) {
+        setDOMException(ec, isolate);
+        return;
+    }
+    v8SetReturnValue(args, toV8Fast(element.release(), args, document));
+}
+
+ScriptValue CustomElementHelpers::createConstructor(ScriptState* state, const ScriptValue& prototypeValue, Document* document, const AtomicString& namespaceURI, const AtomicString& name, const AtomicString& type)
+{
+    v8::Isolate* isolate = state->isolate();
+
+    v8::HandleScope handleScope;
+    v8::TryCatch tryCatch;
+    v8::Local<v8::FunctionTemplate> constructorTemplate = v8::FunctionTemplate::New();
+    constructorTemplate->SetCallHandler(constructCustomElement);
+    v8::Handle<v8::Function> constructor = constructorTemplate->GetFunction();
+    if (tryCatch.HasCaught()) {
+        state->setException(tryCatch.Exception());
+        return ScriptValue();
+    }
+    if (constructor.IsEmpty()) {
+        state->setException(v8::Local<v8::Value>::New(setDOMException(INVALID_STATE_ERR, isolate)));
+        return ScriptValue();
+    }
+
+    v8::Handle<v8::String> v8Name = v8String(name, isolate);
+    v8::Handle<v8::Value> v8Type = v8StringOrNull(type, isolate);
+
+    constructor->SetName(v8Type->IsNull() ? v8Name : v8::Handle<v8::String>::Cast(v8Type));
+
+    V8HiddenPropertyName::setNamedHiddenReference(constructor, "document", toV8(document, state->context()->Global(), isolate));
+    V8HiddenPropertyName::setNamedHiddenReference(constructor, "namespaceURI", v8String(namespaceURI, isolate));
+    V8HiddenPropertyName::setNamedHiddenReference(constructor, "name", v8Name);
+    V8HiddenPropertyName::setNamedHiddenReference(constructor, "type", v8Type);
+
+    // Neither Object::ForceSet nor Object::SetAccessor can set the
+    // "prototype" property of function objects, so we use Set()
+    // instead. This is safe because each function has "prototype"
+    // property from birth so the Function, etc. prototypes will not
+    // intercept the property access.
+    v8::Handle<v8::Object> prototype = v8::Handle<v8::Object>::Cast(prototypeValue.v8Value());
+    v8::Handle<v8::String> prototypeKey = v8String("prototype", isolate);
+    ASSERT(constructor->HasOwnProperty(prototypeKey));
+    constructor->Set(prototypeKey, prototype, v8::ReadOnly);
+
+    prototype->ForceSet(v8String("constructor", isolate), constructor, v8::ReadOnly);
+
+    ASSERT(!tryCatch.HasCaught());
+
+    return ScriptValue(constructor);
 }
 
 static bool hasValidPrototypeChainFor(v8::Handle<v8::Object> prototypeObject, WrapperTypeInfo* typeInfo, v8::Handle<v8::Context> context)
@@ -236,17 +309,11 @@
     return 0;
 }
 
-void CustomElementHelpers::upgradeWrappers(ScriptExecutionContext* executionContext, const HashSet<Element*>& elements, const ScriptValue& prototype)
+void CustomElementHelpers::upgradeWrappers(v8::Handle<v8::Context> context, const HashSet<Element*>& elements, v8::Handle<v8::Object> prototype)
 {
     if (elements.isEmpty())
         return;
 
-    v8::HandleScope handleScope;
-    v8::Handle<v8::Context> context = toV8Context(executionContext, mainThreadNormalWorld());
-    v8::Context::Scope scope(context);
-
-    v8::Handle<v8::Value> v8Prototype = prototype.v8Value();
-
     for (HashSet<Element*>::const_iterator it = elements.begin(); it != elements.end(); ++it) {
         v8::Handle<v8::Object> wrapper = DOMDataStore::getWrapperForMainWorld(*it);
         if (wrapper.IsEmpty()) {
@@ -254,7 +321,7 @@
             // retrieved; we don't need to eagerly create the wrapper.
             continue;
         }
-        wrapper->SetPrototype(v8Prototype);
+        wrapper->SetPrototype(prototype);
     }
 }
 
diff --git a/Source/bindings/v8/CustomElementHelpers.h b/Source/bindings/v8/CustomElementHelpers.h
index dcd79e8..b6ed3f7 100644
--- a/Source/bindings/v8/CustomElementHelpers.h
+++ b/Source/bindings/v8/CustomElementHelpers.h
@@ -39,11 +39,12 @@
 #include "wtf/Forward.h"
 #include "wtf/HashSet.h"
 #include "wtf/PassRefPtr.h"
+#include "wtf/text/AtomicString.h"
 
 namespace WebCore {
 
-class CustomElementConstructor;
 class CustomElementInvocation;
+class Document;
 class HTMLElement;
 class QualifiedName;
 class SVGElement;
@@ -51,17 +52,21 @@
 
 class CustomElementHelpers {
 public:
-    static bool initializeConstructorWrapper(CustomElementConstructor*, const ScriptValue& prototype, ScriptState*);
+    static void didRegisterDefinition(CustomElementDefinition*, ScriptExecutionContext*, const HashSet<Element*>& upgradeCandidates, const ScriptValue& prototypeValue);
+
+    static ScriptValue createConstructor(ScriptState*, const ScriptValue& prototype, Document*, const AtomicString& namespaceURI, const AtomicString& name, const AtomicString& type);
+
     static bool isValidPrototypeParameter(const ScriptValue&, ScriptState*, AtomicString& namespaceURI);
     static bool isValidPrototypeParameter(const ScriptValue&, ScriptState*);
+
     static bool isFeatureAllowed(ScriptState*);
+    static bool isFeatureAllowed(v8::Handle<v8::Context>);
+
+    static WrapperTypeInfo* findWrapperType(v8::Handle<v8::Value> chain);
+
+    static const QualifiedName* findLocalName(v8::Handle<v8::Object> chain);
     static const QualifiedName* findLocalName(const ScriptValue& prototype);
 
-    static bool isFeatureAllowed(v8::Handle<v8::Context>);
-    static WrapperTypeInfo* findWrapperType(v8::Handle<v8::Value> chain);
-    static const QualifiedName* findLocalName(v8::Handle<v8::Object> chain);
-
-    static void upgradeWrappers(ScriptExecutionContext*, const HashSet<Element*>&, const ScriptValue& prototype);
     static void invokeReadyCallbacksIfNeeded(ScriptExecutionContext*, const Vector<CustomElementInvocation>&);
 
     typedef v8::Handle<v8::Object> (*CreateSVGWrapperFunction)(SVGElement*, v8::Handle<v8::Object> creationContext, v8::Isolate*);
@@ -91,9 +96,11 @@
     static v8::Handle<v8::Object> wrap(Element*, v8::Handle<v8::Object> creationContext, v8::Isolate*, const CreateWrapperFunction& createTypeExtensionUpgradeCandidateWrapper);
 
 private:
-    static void invokeReadyCallbackIfNeeded(Element*, v8::Handle<v8::Context>);
     static v8::Handle<v8::Object> createWrapper(PassRefPtr<Element>, v8::Handle<v8::Object>, v8::Isolate*, const CreateWrapperFunction& createTypeExtensionUpgradeCandidateWrapper);
     static v8::Handle<v8::Object> createUpgradeCandidateWrapper(PassRefPtr<Element>, v8::Handle<v8::Object> creationContext, v8::Isolate*, const CreateWrapperFunction& createTypeExtensionUpgradeCandidateWrapper);
+    static void upgradeWrappers(v8::Handle<v8::Context>, const HashSet<Element*>&, v8::Handle<v8::Object> prototype);
+
+    static void invokeReadyCallbackIfNeeded(Element*, v8::Handle<v8::Context>);
 };
 
 inline v8::Handle<v8::Object> CustomElementHelpers::wrap(Element* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate, const CreateWrapperFunction& createWrapper)
diff --git a/Source/bindings/v8/DOMDataStore.h b/Source/bindings/v8/DOMDataStore.h
index 33f5d6d..d5f458d 100644
--- a/Source/bindings/v8/DOMDataStore.h
+++ b/Source/bindings/v8/DOMDataStore.h
@@ -64,7 +64,7 @@
             if (ScriptWrappable::wrapperCanBeStoredInObject(object)) {
                 v8::Handle<v8::Object> result = ScriptWrappable::getUnsafeWrapperFromObject(object).handle();
                 // Security: always guard against malicious tampering.
-                RELEASE_ASSERT(result.IsEmpty() || result->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex) == static_cast<void*>(object));
+                RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(result.IsEmpty() || result->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex) == static_cast<void*>(object));
                 return result;
             }
             return mainWorldStore()->m_wrapperMap.get(object);
@@ -79,7 +79,7 @@
             if (LIKELY(!DOMWrapperWorld::isolatedWorldsExist())) {
                 v8::Handle<v8::Object> result = ScriptWrappable::getUnsafeWrapperFromObject(object).handle();
                 // Security: always guard against malicious tampering.
-                RELEASE_ASSERT(result.IsEmpty() || result->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex) == static_cast<void*>(object));
+                RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(result.IsEmpty() || result->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex) == static_cast<void*>(object));
                 return result;
             }
         }
diff --git a/Source/bindings/v8/DOMWrapperMap.h b/Source/bindings/v8/DOMWrapperMap.h
index 734ab09..aded4a0 100644
--- a/Source/bindings/v8/DOMWrapperMap.h
+++ b/Source/bindings/v8/DOMWrapperMap.h
@@ -66,9 +66,13 @@
         ASSERT(static_cast<KeyType*>(toNative(wrapper)) == key);
         v8::Persistent<v8::Object> persistent(m_isolate, wrapper);
         configuration.configureWrapper(&persistent, m_isolate);
-        persistent.MakeWeak(m_isolate, this, &makeWeakCallback);
-        typename MapType::AddResult result = m_map.set(key, UnsafePersistent<v8::Object>(persistent));
-        RELEASE_ASSERT(result.isNewEntry);
+        persistent.MakeWeak(this, &makeWeakCallback);
+        typename MapType::AddResult result = m_map.add(key, UnsafePersistent<v8::Object>());
+        ASSERT(result.isNewEntry);
+        // FIXME: Stop handling this case once duplicate wrappers are guaranteed not to be created.
+        if (!result.isNewEntry)
+            result.iterator->value.dispose();
+        result.iterator->value = UnsafePersistent<v8::Object>(persistent);
     }
 
     void clear()
diff --git a/Source/bindings/v8/DOMWrapperWorld.cpp b/Source/bindings/v8/DOMWrapperWorld.cpp
index 7b5f2fd..9127964 100644
--- a/Source/bindings/v8/DOMWrapperWorld.cpp
+++ b/Source/bindings/v8/DOMWrapperWorld.cpp
@@ -31,7 +31,7 @@
 #include "config.h"
 #include "bindings/v8/DOMWrapperWorld.h"
 
-#include "V8DOMWindow.h"
+#include "V8Window.h"
 #include "bindings/v8/DOMDataStore.h"
 #include "bindings/v8/V8Binding.h"
 #include "bindings/v8/V8DOMActivityLogger.h"
@@ -69,7 +69,7 @@
 {
     ASSERT(v8::Context::InContext());
     v8::Handle<v8::Context> context = v8::Context::GetCurrent();
-    if (!V8DOMWrapper::isWrapperOfType(toInnerGlobalObject(context), &V8DOMWindow::info))
+    if (!V8DOMWrapper::isWrapperOfType(toInnerGlobalObject(context), &V8Window::info))
         return 0;
     ASSERT(isMainThread());
     if (DOMWrapperWorld* world = isolatedWorld(context))
@@ -96,7 +96,7 @@
     ASSERT(isMainThread());
     if (initializingWindow)
         return true;
-    return V8DOMWrapper::isWrapperOfType(toInnerGlobalObject(context), &V8DOMWindow::info);
+    return V8DOMWrapper::isWrapperOfType(toInnerGlobalObject(context), &V8Window::info);
 }
 
 void DOMWrapperWorld::setIsolatedWorldField(v8::Handle<v8::Context> context)
diff --git a/Source/bindings/v8/Dictionary.cpp b/Source/bindings/v8/Dictionary.cpp
index 8119179..70c57c3 100644
--- a/Source/bindings/v8/Dictionary.cpp
+++ b/Source/bindings/v8/Dictionary.cpp
@@ -28,7 +28,6 @@
 
 #include "V8CSSFontFaceRule.h"
 #include "V8DOMError.h"
-#include "V8DOMWindow.h"
 #include "V8EventTarget.h"
 #include "V8IDBKeyRange.h"
 #include "V8MIDIPort.h"
@@ -39,6 +38,7 @@
 #include "V8Storage.h"
 #include "V8Uint8Array.h"
 #include "V8VoidCallback.h"
+#include "V8Window.h"
 #include "bindings/v8/ArrayValue.h"
 #include "bindings/v8/V8Binding.h"
 #include "bindings/v8/V8Utilities.h"
@@ -250,9 +250,9 @@
     value = 0;
     if (v8Value->IsObject()) {
         v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(v8Value);
-        v8::Handle<v8::Object> window = wrapper->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(m_isolate, worldTypeInMainThread(m_isolate)));
+        v8::Handle<v8::Object> window = wrapper->FindInstanceInPrototypeChain(V8Window::GetTemplate(m_isolate, worldTypeInMainThread(m_isolate)));
         if (!window.IsEmpty())
-            value = V8DOMWindow::toNative(window);
+            value = V8Window::toNative(window);
     }
     return true;
 }
@@ -430,7 +430,7 @@
     // exists on a prototype chain of v8Value.
     if (v8Value->IsObject()) {
         v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(v8Value);
-        v8::Handle<v8::Object> window = wrapper->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(m_isolate, worldTypeInMainThread(m_isolate)));
+        v8::Handle<v8::Object> window = wrapper->FindInstanceInPrototypeChain(V8Window::GetTemplate(m_isolate, worldTypeInMainThread(m_isolate)));
         if (!window.IsEmpty()) {
             value = toWrapperTypeInfo(window)->toEventTarget(window);
             return true;
diff --git a/Source/bindings/v8/PageScriptDebugServer.cpp b/Source/bindings/v8/PageScriptDebugServer.cpp
index 58c42f1..b537ada 100644
--- a/Source/bindings/v8/PageScriptDebugServer.cpp
+++ b/Source/bindings/v8/PageScriptDebugServer.cpp
@@ -32,11 +32,11 @@
 #include "bindings/v8/PageScriptDebugServer.h"
 
 
-#include "V8DOMWindow.h"
+#include "V8Window.h"
 #include "bindings/v8/ScriptController.h"
 #include "bindings/v8/V8Binding.h"
-#include "bindings/v8/V8DOMWindowShell.h"
 #include "bindings/v8/V8ScriptRunner.h"
+#include "bindings/v8/V8WindowShell.h"
 #include "core/inspector/InspectorInstrumentation.h"
 #include "core/inspector/ScriptDebugListener.h"
 #include "core/page/Frame.h"
@@ -57,7 +57,7 @@
     if (global.IsEmpty())
         return 0;
 
-    global = global->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(context->GetIsolate(), worldTypeInMainThread(context->GetIsolate())));
+    global = global->FindInstanceInPrototypeChain(V8Window::GetTemplate(context->GetIsolate(), worldTypeInMainThread(context->GetIsolate())));
     if (global.IsEmpty())
         return 0;
 
@@ -86,26 +86,27 @@
     v8::Local<v8::Context> debuggerContext = v8::Debug::GetDebugContext();
     v8::Context::Scope contextScope(debuggerContext);
 
+    v8::Local<v8::Object> debuggerScript = m_debuggerScript.newLocal(m_isolate);
     if (!m_listenersMap.size()) {
         ensureDebuggerScriptCompiled();
-        ASSERT(!m_debuggerScript.get()->IsUndefined());
+        ASSERT(!debuggerScript->IsUndefined());
         v8::Debug::SetDebugEventListener2(&PageScriptDebugServer::v8DebugEventCallback, v8::External::New(this));
     }
     m_listenersMap.set(page, listener);
 
-    V8DOMWindowShell* shell = scriptController->existingWindowShell(mainThreadNormalWorld());
+    V8WindowShell* shell = scriptController->existingWindowShell(mainThreadNormalWorld());
     if (!shell || !shell->isContextInitialized())
         return;
     v8::Local<v8::Context> context = shell->context();
-    v8::Handle<v8::Function> getScriptsFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::NewSymbol("getScripts")));
+    v8::Handle<v8::Function> getScriptsFunction = v8::Local<v8::Function>::Cast(debuggerScript->Get(v8::String::NewSymbol("getScripts")));
     v8::Handle<v8::Value> argv[] = { context->GetEmbedderData(0) };
-    v8::Handle<v8::Value> value = V8ScriptRunner::callInternalFunction(getScriptsFunction, m_debuggerScript.get(), WTF_ARRAY_LENGTH(argv), argv, m_isolate);
+    v8::Handle<v8::Value> value = V8ScriptRunner::callInternalFunction(getScriptsFunction, debuggerScript, WTF_ARRAY_LENGTH(argv), argv, m_isolate);
     if (value.IsEmpty())
         return;
     ASSERT(!value->IsUndefined() && value->IsArray());
     v8::Handle<v8::Array> scriptsArray = v8::Handle<v8::Array>::Cast(value);
     for (unsigned i = 0; i < scriptsArray->Length(); ++i)
-        dispatchDidParseSource(listener, v8::Handle<v8::Object>::Cast(scriptsArray->Get(v8Integer(i, context->GetIsolate()))));
+        dispatchDidParseSource(listener, v8::Handle<v8::Object>::Cast(scriptsArray->Get(v8Integer(i, m_isolate))));
 }
 
 void PageScriptDebugServer::removeListener(ScriptDebugListener* listener, Page* page)
diff --git a/Source/bindings/v8/ScheduledAction.cpp b/Source/bindings/v8/ScheduledAction.cpp
index 1127824..9215da7 100644
--- a/Source/bindings/v8/ScheduledAction.cpp
+++ b/Source/bindings/v8/ScheduledAction.cpp
@@ -88,7 +88,7 @@
 {
     v8::HandleScope handleScope(m_isolate);
 
-    v8::Handle<v8::Context> context = v8::Local<v8::Context>::New(m_context.get());
+    v8::Handle<v8::Context> context = m_context.newLocal(m_isolate);
     if (context.IsEmpty())
         return;
     v8::Context::Scope scope(context);
@@ -98,7 +98,7 @@
     if (!m_function.isEmpty()) {
         Vector<v8::Handle<v8::Value> > args;
         createLocalHandlesForArgs(&args);
-        frame->script()->callFunction(m_function.get(), context->Global(), args.size(), args.data());
+        frame->script()->callFunction(m_function.newLocal(m_isolate), context->Global(), args.size(), args.data());
     } else
         frame->script()->compileAndRunScript(m_code);
 
@@ -109,7 +109,7 @@
 {
     ASSERT(worker->thread()->isCurrentThread());
     v8::HandleScope handleScope(m_isolate);
-    v8::Handle<v8::Context> context = v8::Local<v8::Context>::New(m_context.get());
+    v8::Handle<v8::Context> context = m_context.newLocal(m_isolate);
     ASSERT(!context.IsEmpty());
     v8::Context::Scope scope(context);
     if (!m_function.isEmpty()) {
diff --git a/Source/bindings/v8/ScopedPersistent.h b/Source/bindings/v8/ScopedPersistent.h
index 0c3c26e..dea113f 100644
--- a/Source/bindings/v8/ScopedPersistent.h
+++ b/Source/bindings/v8/ScopedPersistent.h
@@ -71,6 +71,11 @@
     }
 
     bool isEmpty() const { return m_handle.IsEmpty(); }
+    bool isNull() { return get()->IsNull(); }
+    bool isUndefined() { return get()->IsUndefined(); }
+    bool isFunction() { return get()->IsFunction(); }
+    bool isObject() { return get()->IsObject(); }
+    bool isString() { return get()->IsString(); }
 
     void set(v8::Isolate* isolate, v8::Handle<T> handle)
     {
@@ -86,6 +91,11 @@
         m_handle.Clear();
     }
 
+    bool operator==(const ScopedPersistent<T>& other)
+    {
+        return m_handle == other.m_handle;
+    }
+
 private:
     v8::Persistent<T> m_handle;
 };
diff --git a/Source/bindings/v8/ScriptController.cpp b/Source/bindings/v8/ScriptController.cpp
index adafe8a..c687e1b 100644
--- a/Source/bindings/v8/ScriptController.cpp
+++ b/Source/bindings/v8/ScriptController.cpp
@@ -32,9 +32,9 @@
 #include "config.h"
 #include "bindings/v8/ScriptController.h"
 
-#include "V8DOMWindow.h"
 #include "V8Event.h"
 #include "V8HTMLElement.h"
+#include "V8Window.h"
 #include "bindings/v8/BindingSecurity.h"
 #include "bindings/v8/NPObjectWrapper.h"
 #include "bindings/v8/NPV8Object.h"
@@ -42,12 +42,12 @@
 #include "bindings/v8/ScriptSourceCode.h"
 #include "bindings/v8/ScriptValue.h"
 #include "bindings/v8/V8Binding.h"
-#include "bindings/v8/V8DOMWindowShell.h"
 #include "bindings/v8/V8GCController.h"
 #include "bindings/v8/V8HiddenPropertyName.h"
 #include "bindings/v8/V8NPObject.h"
 #include "bindings/v8/V8PerContextData.h"
 #include "bindings/v8/V8ScriptRunner.h"
+#include "bindings/v8/V8WindowShell.h"
 #include "bindings/v8/npruntime_impl.h"
 #include "bindings/v8/npruntime_priv.h"
 #include "core/dom/Document.h"
@@ -92,7 +92,7 @@
     : m_frame(frame)
     , m_sourceURL(0)
     , m_isolate(v8::Isolate::GetCurrent())
-    , m_windowShell(V8DOMWindowShell::create(frame, mainThreadNormalWorld(), m_isolate))
+    , m_windowShell(V8WindowShell::create(frame, mainThreadNormalWorld(), m_isolate))
     , m_paused(false)
     , m_wrappedWindowScriptNPObject(0)
 {
@@ -230,10 +230,11 @@
         tryCatch.SetVerbose(true);
 
         v8::Handle<v8::String> code = v8String(source.source(), m_isolate);
+        OwnPtr<v8::ScriptData> scriptData = V8ScriptRunner::precompileScript(code, source.cachedScript());
 
         // NOTE: For compatibility with WebCore, ScriptSourceCode's line starts at
         // 1, whereas v8 starts at 0.
-        v8::Handle<v8::Script> script = V8ScriptRunner::compileScript(code, source.url(), source.startPosition(), m_isolate);
+        v8::Handle<v8::Script> script = V8ScriptRunner::compileScript(code, source.url(), source.startPosition(), scriptData.get(), m_isolate);
 
         // Keep Frame (and therefore ScriptController) alive.
         RefPtr<Frame> protect(m_frame);
@@ -253,7 +254,7 @@
     return windowShell(mainThreadNormalWorld())->isContextInitialized();
 }
 
-V8DOMWindowShell* ScriptController::existingWindowShell(DOMWrapperWorld* world)
+V8WindowShell* ScriptController::existingWindowShell(DOMWrapperWorld* world)
 {
     ASSERT(world);
 
@@ -270,11 +271,11 @@
     return iter->value->isContextInitialized() ? iter->value.get() : 0;
 }
 
-V8DOMWindowShell* ScriptController::windowShell(DOMWrapperWorld* world)
+V8WindowShell* ScriptController::windowShell(DOMWrapperWorld* world)
 {
     ASSERT(world);
 
-    V8DOMWindowShell* shell = 0;
+    V8WindowShell* shell = 0;
     if (world->isMainWorld())
         shell = m_windowShell.get();
     else {
@@ -282,7 +283,7 @@
         if (iter != m_isolatedWorlds.end())
             shell = iter->value.get();
         else {
-            OwnPtr<V8DOMWindowShell> isolatedWorldShell = V8DOMWindowShell::create(m_frame, world, m_isolate);
+            OwnPtr<V8WindowShell> isolatedWorldShell = V8WindowShell::create(m_frame, world, m_isolate);
             shell = isolatedWorldShell.get();
             m_isolatedWorlds.set(world->worldId(), isolatedWorldShell.release());
         }
@@ -539,7 +540,7 @@
 {
     v8::HandleScope handleScope;
     for (IsolatedWorldMap::iterator it = m_isolatedWorlds.begin(); it != m_isolatedWorlds.end(); ++it) {
-        V8DOMWindowShell* isolatedWorldShell = it->value.get();
+        V8WindowShell* isolatedWorldShell = it->value.get();
         SecurityOrigin* origin = isolatedWorldShell->world()->isolatedWorldSecurityOrigin();
         if (!origin)
             continue;
@@ -698,7 +699,7 @@
     {
         v8::HandleScope evaluateHandleScope;
         RefPtr<DOMWrapperWorld> world = DOMWrapperWorld::ensureIsolatedWorld(worldID, extensionGroup);
-        V8DOMWindowShell* isolatedWorldShell = windowShell(world.get());
+        V8WindowShell* isolatedWorldShell = windowShell(world.get());
 
         if (!isolatedWorldShell->isContextInitialized())
             return;
diff --git a/Source/bindings/v8/ScriptController.h b/Source/bindings/v8/ScriptController.h
index ee68dd9..c2c8723 100644
--- a/Source/bindings/v8/ScriptController.h
+++ b/Source/bindings/v8/ScriptController.h
@@ -54,7 +54,7 @@
 class ScriptSourceCode;
 class ScriptState;
 class SecurityOrigin;
-class V8DOMWindowShell;
+class V8WindowShell;
 class Widget;
 
 typedef WTF::Vector<v8::Extension*> V8Extensions;
@@ -70,8 +70,8 @@
     ~ScriptController();
 
     bool initializeMainWorld();
-    V8DOMWindowShell* windowShell(DOMWrapperWorld*);
-    V8DOMWindowShell* existingWindowShell(DOMWrapperWorld*);
+    V8WindowShell* windowShell(DOMWrapperWorld*);
+    V8WindowShell* existingWindowShell(DOMWrapperWorld*);
 
     ScriptValue executeScript(const ScriptSourceCode&);
     ScriptValue executeScript(const String& script, bool forceUserGesture = false);
@@ -159,7 +159,7 @@
     static int contextDebugId(v8::Handle<v8::Context>);
 
 private:
-    typedef HashMap<int, OwnPtr<V8DOMWindowShell> > IsolatedWorldMap;
+    typedef HashMap<int, OwnPtr<V8WindowShell> > IsolatedWorldMap;
 
     void clearForClose(bool destroyGlobal);
 
@@ -167,7 +167,7 @@
     const String* m_sourceURL;
     v8::Isolate* m_isolate;
 
-    OwnPtr<V8DOMWindowShell> m_windowShell;
+    OwnPtr<V8WindowShell> m_windowShell;
     IsolatedWorldMap m_isolatedWorlds;
 
     bool m_paused;
diff --git a/Source/bindings/v8/ScriptDebugServer.cpp b/Source/bindings/v8/ScriptDebugServer.cpp
index 6cfc9f4..71c5598 100644
--- a/Source/bindings/v8/ScriptDebugServer.cpp
+++ b/Source/bindings/v8/ScriptDebugServer.cpp
@@ -147,7 +147,7 @@
     args->Set(v8::String::NewSymbol("columnNumber"), v8Integer(scriptBreakpoint.columnNumber, debuggerContext->GetIsolate()));
     args->Set(v8::String::NewSymbol("condition"), v8String(scriptBreakpoint.condition, debuggerContext->GetIsolate()));
 
-    v8::Handle<v8::Function> setBreakpointFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::NewSymbol("setBreakpoint")));
+    v8::Handle<v8::Function> setBreakpointFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.newLocal(m_isolate)->Get(v8::String::NewSymbol("setBreakpoint")));
     v8::Handle<v8::Value> breakpointId = v8::Debug::Call(setBreakpointFunction, args);
     if (!breakpointId->IsString())
         return "";
@@ -158,38 +158,38 @@
 
 void ScriptDebugServer::removeBreakpoint(const String& breakpointId)
 {
-    v8::HandleScope scope;
+    v8::HandleScope scope(m_isolate);
     v8::Local<v8::Context> debuggerContext = v8::Debug::GetDebugContext();
     v8::Context::Scope contextScope(debuggerContext);
 
     v8::Local<v8::Object> args = v8::Object::New();
     args->Set(v8::String::NewSymbol("breakpointId"), v8String(breakpointId, debuggerContext->GetIsolate()));
 
-    v8::Handle<v8::Function> removeBreakpointFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::NewSymbol("removeBreakpoint")));
+    v8::Handle<v8::Function> removeBreakpointFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.newLocal(m_isolate)->Get(v8::String::NewSymbol("removeBreakpoint")));
     v8::Debug::Call(removeBreakpointFunction, args);
 }
 
 void ScriptDebugServer::clearBreakpoints()
 {
     ensureDebuggerScriptCompiled();
-    v8::HandleScope scope;
+    v8::HandleScope scope(m_isolate);
     v8::Local<v8::Context> debuggerContext = v8::Debug::GetDebugContext();
     v8::Context::Scope contextScope(debuggerContext);
 
-    v8::Handle<v8::Function> clearBreakpoints = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::NewSymbol("clearBreakpoints")));
+    v8::Handle<v8::Function> clearBreakpoints = v8::Local<v8::Function>::Cast(m_debuggerScript.newLocal(m_isolate)->Get(v8::String::NewSymbol("clearBreakpoints")));
     v8::Debug::Call(clearBreakpoints);
 }
 
 void ScriptDebugServer::setBreakpointsActivated(bool activated)
 {
     ensureDebuggerScriptCompiled();
-    v8::HandleScope scope;
+    v8::HandleScope scope(m_isolate);
     v8::Local<v8::Context> debuggerContext = v8::Debug::GetDebugContext();
     v8::Context::Scope contextScope(debuggerContext);
 
     v8::Local<v8::Object> args = v8::Object::New();
     args->Set(v8::String::NewSymbol("enabled"), v8::Boolean::New(activated));
-    v8::Handle<v8::Function> setBreakpointsActivated = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::NewSymbol("setBreakpointsActivated")));
+    v8::Handle<v8::Function> setBreakpointsActivated = v8::Local<v8::Function>::Cast(m_debuggerScript.newLocal(m_isolate)->Get(v8::String::NewSymbol("setBreakpointsActivated")));
     v8::Debug::Call(setBreakpointsActivated, args);
 
     m_breakpointsActivated = activated;
@@ -198,7 +198,7 @@
 ScriptDebugServer::PauseOnExceptionsState ScriptDebugServer::pauseOnExceptionsState()
 {
     ensureDebuggerScriptCompiled();
-    v8::HandleScope scope;
+    v8::HandleScope scope(m_isolate);
     v8::Context::Scope contextScope(v8::Debug::GetDebugContext());
 
     v8::Handle<v8::Value> argv[] = { v8Undefined() };
@@ -209,7 +209,7 @@
 void ScriptDebugServer::setPauseOnExceptionsState(PauseOnExceptionsState pauseOnExceptionsState)
 {
     ensureDebuggerScriptCompiled();
-    v8::HandleScope scope;
+    v8::HandleScope scope(m_isolate);
     v8::Context::Scope contextScope(v8::Debug::GetDebugContext());
 
     v8::Handle<v8::Value> argv[] = { v8::Int32::New(pauseOnExceptionsState) };
@@ -226,25 +226,33 @@
         v8::Debug::CancelDebugBreak(m_isolate);
 }
 
-void ScriptDebugServer::breakProgram()
+bool ScriptDebugServer::canBreakProgram()
 {
     if (!m_breakpointsActivated)
-        return;
+        return false;
 
+    // FIXME: Remove this check once m_isolate->GetCurrentContext() does not crash.
     if (!v8::Context::InContext())
+        return false;
+
+    v8::HandleScope scope(m_isolate);
+    return !m_isolate->GetCurrentContext().IsEmpty();
+}
+
+void ScriptDebugServer::breakProgram()
+{
+    if (!canBreakProgram())
         return;
 
-    if (m_breakProgramCallbackTemplate.get().IsEmpty()) {
-        m_breakProgramCallbackTemplate.set(m_isolate, v8::FunctionTemplate::New());
-        m_breakProgramCallbackTemplate.get()->SetCallHandler(&ScriptDebugServer::breakProgramCallback, v8::External::New(this));
+    v8::HandleScope scope(m_isolate);
+    if (m_breakProgramCallbackTemplate.isEmpty()) {
+        v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New();
+        templ->SetCallHandler(&ScriptDebugServer::breakProgramCallback, v8::External::New(this));
+        m_breakProgramCallbackTemplate.set(m_isolate, templ);
     }
 
-    v8::Handle<v8::Context> context = v8::Context::GetCurrent();
-    if (context.IsEmpty())
-        return;
-
-    m_pausedContext = context;
-    v8::Handle<v8::Function> breakProgramFunction = m_breakProgramCallbackTemplate.get()->GetFunction();
+    m_pausedContext = m_isolate->GetCurrentContext();
+    v8::Handle<v8::Function> breakProgramFunction = m_breakProgramCallbackTemplate.newLocal(m_isolate)->GetFunction();
     v8::Debug::Call(breakProgramFunction);
     m_pausedContext.Clear();
 }
@@ -568,7 +576,7 @@
 
     v8::Handle<v8::String> source = v8String(expression, isolate);
     v8::TryCatch tryCatch;
-    v8::Local<v8::Script> script = V8ScriptRunner::compileScript(source, sourceURL, TextPosition(), isolate);
+    v8::Local<v8::Script> script = V8ScriptRunner::compileScript(source, sourceURL, TextPosition(), 0, isolate);
     if (tryCatch.HasCaught()) {
         v8::Local<v8::Message> message = tryCatch.Message();
         if (!message.IsEmpty())
diff --git a/Source/bindings/v8/ScriptDebugServer.h b/Source/bindings/v8/ScriptDebugServer.h
index 7f34c7e..746c666 100644
--- a/Source/bindings/v8/ScriptDebugServer.h
+++ b/Source/bindings/v8/ScriptDebugServer.h
@@ -66,6 +66,7 @@
     void setPauseOnExceptionsState(PauseOnExceptionsState pauseOnExceptionsState);
 
     void setPauseOnNextStatement(bool pause);
+    bool canBreakProgram();
     void breakProgram();
     void continueProgram();
     void stepIntoStatement();
diff --git a/Source/bindings/v8/ScriptEventListener.cpp b/Source/bindings/v8/ScriptEventListener.cpp
index df7eb87..5d32319 100644
--- a/Source/bindings/v8/ScriptEventListener.cpp
+++ b/Source/bindings/v8/ScriptEventListener.cpp
@@ -35,7 +35,7 @@
 #include "bindings/v8/ScriptScope.h"
 #include "bindings/v8/V8AbstractEventListener.h"
 #include "bindings/v8/V8Binding.h"
-#include "bindings/v8/V8DOMWindowShell.h"
+#include "bindings/v8/V8WindowShell.h"
 #include "core/dom/Document.h"
 #include "core/dom/DocumentParser.h"
 #include "core/dom/EventListener.h"
diff --git a/Source/bindings/v8/ScriptProfiler.cpp b/Source/bindings/v8/ScriptProfiler.cpp
index fabbb06..fca8197 100644
--- a/Source/bindings/v8/ScriptProfiler.cpp
+++ b/Source/bindings/v8/ScriptProfiler.cpp
@@ -32,8 +32,8 @@
 #include "bindings/v8/ScriptProfiler.h"
 
 #include "V8ArrayBufferView.h"
-#include "V8DOMWindow.h"
 #include "V8Node.h"
+#include "V8Window.h"
 #include "bindings/v8/RetainedDOMInfo.h"
 #include "bindings/v8/ScriptObject.h"
 #include "bindings/v8/V8Binding.h"
@@ -167,8 +167,8 @@
 public:
     virtual const char* GetName(v8::Handle<v8::Object> object)
     {
-        if (V8DOMWrapper::isWrapperOfType(object, &V8DOMWindow::info)) {
-            DOMWindow* window = V8DOMWindow::toNative(object);
+        if (V8DOMWrapper::isWrapperOfType(object, &V8Window::info)) {
+            DOMWindow* window = V8Window::toNative(object);
             if (window) {
                 CString url = window->document()->url().string().utf8();
                 m_strings.append(url);
diff --git a/Source/bindings/v8/ScriptSourceCode.h b/Source/bindings/v8/ScriptSourceCode.h
index 4c40df2..cff6050 100644
--- a/Source/bindings/v8/ScriptSourceCode.h
+++ b/Source/bindings/v8/ScriptSourceCode.h
@@ -33,12 +33,13 @@
 
 #include "core/loader/cache/CachedResourceHandle.h"
 #include "core/loader/cache/CachedScript.h"
-#include "core/platform/KURL.h"
-#include <v8.h>
+#include "weborigin/KURL.h"
 #include "wtf/PassOwnPtr.h"
 #include "wtf/text/TextPosition.h"
 #include "wtf/text/WTFString.h"
 
+#include <v8.h>
+
 namespace WebCore {
 
 class ScriptSourceCode {
diff --git a/Source/bindings/v8/ScriptState.cpp b/Source/bindings/v8/ScriptState.cpp
index 1841dd7..ab081e9 100644
--- a/Source/bindings/v8/ScriptState.cpp
+++ b/Source/bindings/v8/ScriptState.cpp
@@ -31,7 +31,7 @@
 #include "config.h"
 #include "bindings/v8/ScriptState.h"
 
-#include "V8DOMWindow.h"
+#include "V8Window.h"
 #include "V8WorkerContext.h"
 #include "bindings/v8/ScriptController.h"
 #include "bindings/v8/V8HiddenPropertyName.h"
@@ -47,7 +47,7 @@
     : m_context(context)
     , m_isolate(context->GetIsolate())
 {
-    m_context.getUnsafe().MakeWeak(context->GetIsolate(), this, &makeWeakCallback);
+    m_context.getUnsafe().MakeWeak(this, &makeWeakCallback);
 }
 
 ScriptState::~ScriptState()
@@ -56,14 +56,14 @@
 
 DOMWindow* ScriptState::domWindow() const
 {
-    v8::HandleScope handleScope;
-    return toDOMWindow(m_context.get());
+    v8::HandleScope handleScope(m_isolate);
+    return toDOMWindow(m_context.newLocal(m_isolate));
 }
 
 ScriptExecutionContext* ScriptState::scriptExecutionContext() const
 {
-    v8::HandleScope handleScope;
-    return toScriptExecutionContext(m_context.get());
+    v8::HandleScope handleScope(m_isolate);
+    return toScriptExecutionContext(m_context.newLocal(m_isolate));
 }
 
 ScriptState* ScriptState::forContext(v8::Handle<v8::Context> context)
diff --git a/Source/bindings/v8/custom/V8DOMStringMapCustom.cpp b/Source/bindings/v8/ScriptString.cpp
similarity index 68%
copy from Source/bindings/v8/custom/V8DOMStringMapCustom.cpp
copy to Source/bindings/v8/ScriptString.cpp
index 6b6ee5f..317c53b 100644
--- a/Source/bindings/v8/custom/V8DOMStringMapCustom.cpp
+++ b/Source/bindings/v8/ScriptString.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2013 Google Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -29,20 +29,27 @@
  */
 
 #include "config.h"
-#include "V8DOMStringMap.h"
-
-#include "V8Element.h"
-#include "bindings/v8/V8Binding.h"
-#include "bindings/v8/V8DOMWrapper.h"
-#include "core/dom/DOMStringMap.h"
+#include "bindings/v8/ScriptString.h"
 
 namespace WebCore {
 
-v8::Handle<v8::Integer> V8DOMStringMap::namedPropertyQuery(v8::Local<v8::String> name, const v8::AccessorInfo& info)
+ScriptString ScriptString::concatenateWith(const String& string)
 {
-    if (V8DOMStringMap::toNative(info.Holder())->contains(toWebCoreString(name)))
-        return v8Integer(0, info.GetIsolate());
-    return v8::Handle<v8::Integer>();
+    v8::HandleScope handleScope;
+    v8::Handle<v8::String> b = v8String(string, v8::Isolate::GetCurrent());
+    if (hasNoValue())
+        return ScriptString(b);
+    v8::Handle<v8::String> a = v8::Handle<v8::String>::Cast(v8Value());
+    return ScriptString(v8::String::Concat(a, b));
+}
+
+String ScriptString::flattenToString() const
+{
+    if (hasNoValue())
+        return String();
+    v8::HandleScope handleScope;
+    v8::Handle<v8::String> value = v8::Handle<v8::String>::Cast(v8Value());
+    return v8StringToWebCoreString<String>(value, Externalize);
 }
 
 } // namespace WebCore
diff --git a/Source/bindings/v8/custom/V8DOMStringMapCustom.cpp b/Source/bindings/v8/ScriptString.h
similarity index 75%
rename from Source/bindings/v8/custom/V8DOMStringMapCustom.cpp
rename to Source/bindings/v8/ScriptString.h
index 6b6ee5f..14467c7 100644
--- a/Source/bindings/v8/custom/V8DOMStringMapCustom.cpp
+++ b/Source/bindings/v8/ScriptString.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2013 Google Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -28,21 +28,24 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "config.h"
-#include "V8DOMStringMap.h"
+#ifndef ScriptString_h
+#define ScriptString_h
 
-#include "V8Element.h"
+#include "bindings/v8/ScriptValue.h"
 #include "bindings/v8/V8Binding.h"
-#include "bindings/v8/V8DOMWrapper.h"
-#include "core/dom/DOMStringMap.h"
+#include "wtf/text/WTFString.h"
 
 namespace WebCore {
 
-v8::Handle<v8::Integer> V8DOMStringMap::namedPropertyQuery(v8::Local<v8::String> name, const v8::AccessorInfo& info)
-{
-    if (V8DOMStringMap::toNative(info.Holder())->contains(toWebCoreString(name)))
-        return v8Integer(0, info.GetIsolate());
-    return v8::Handle<v8::Integer>();
-}
+class ScriptString : public ScriptValue {
+public:
+    ScriptString() { }
+    explicit ScriptString(v8::Handle<v8::String> value) : ScriptValue(value) { }
+
+    ScriptString concatenateWith(const String&);
+    String flattenToString() const;
+};
 
 } // namespace WebCore
+
+#endif // ScriptString_h
diff --git a/Source/bindings/v8/ScriptValue.cpp b/Source/bindings/v8/ScriptValue.cpp
index 6318188..676ba6d 100644
--- a/Source/bindings/v8/ScriptValue.cpp
+++ b/Source/bindings/v8/ScriptValue.cpp
@@ -47,13 +47,13 @@
 PassRefPtr<SerializedScriptValue> ScriptValue::serialize(ScriptState* scriptState)
 {
     ScriptScope scope(scriptState);
-    return SerializedScriptValue::create(v8ValueRaw());
+    return SerializedScriptValue::create(v8Value());
 }
 
 PassRefPtr<SerializedScriptValue> ScriptValue::serialize(ScriptState* scriptState, MessagePortArray* messagePorts, ArrayBufferArray* arrayBuffers, bool& didThrow)
 {
     ScriptScope scope(scriptState);
-    return SerializedScriptValue::create(v8ValueRaw(), messagePorts, arrayBuffers, didThrow);
+    return SerializedScriptValue::create(v8Value(), messagePorts, arrayBuffers, didThrow);
 }
 
 ScriptValue ScriptValue::deserialize(ScriptState* scriptState, SerializedScriptValue* value)
@@ -62,22 +62,23 @@
     return ScriptValue(value->deserialize());
 }
 
-bool ScriptValue::getString(String& result) const
+bool ScriptValue::getString(String& result, v8::Isolate* isolate) const
 {
     if (hasNoValue())
         return false;
 
-    if (!v8ValueRaw()->IsString())
+    if (!m_value->isString())
         return false;
 
-    result = toWebCoreString(v8ValueRaw());
+    v8::HandleScope handleScope(isolate);
+    result = toWebCoreString(v8Value());
     return true;
 }
 
 String ScriptValue::toString(ScriptState*) const
 {
     v8::TryCatch block;
-    v8::Handle<v8::String> string = v8ValueRaw()->ToString();
+    v8::Handle<v8::String> string = v8Value()->ToString();
     if (block.HasCaught())
         return String();
     return v8StringToWebCoreString<String>(string, DoNotExternalize);
@@ -138,10 +139,10 @@
 
 PassRefPtr<InspectorValue> ScriptValue::toInspectorValue(ScriptState* scriptState) const
 {
-    v8::HandleScope handleScope;
+    v8::HandleScope handleScope(scriptState->isolate());
     // v8::Object::GetPropertyNames() expects current context to be not null.
     v8::Context::Scope contextScope(scriptState->context());
-    return v8ToInspectorValue(v8ValueRaw(), InspectorValue::maxDepth);
+    return v8ToInspectorValue(v8Value(), InspectorValue::maxDepth);
 }
 
 } // namespace WebCore
diff --git a/Source/bindings/v8/ScriptValue.h b/Source/bindings/v8/ScriptValue.h
index dd86be4..1a8039c 100644
--- a/Source/bindings/v8/ScriptValue.h
+++ b/Source/bindings/v8/ScriptValue.h
@@ -79,7 +79,11 @@
 
     bool operator==(const ScriptValue& value) const
     {
-        return v8ValueRaw() == value.v8ValueRaw();
+        if (hasNoValue())
+            return value.hasNoValue();
+        if (value.hasNoValue())
+            return false;
+        return *m_value == *value.m_value;
     }
 
     bool isEqual(ScriptState*, const ScriptValue& value) const
@@ -90,7 +94,7 @@
     bool isFunction() const
     {
         ASSERT(!hasNoValue());
-        return v8ValueRaw()->IsFunction();
+        return m_value->isFunction();
     }
 
     bool operator!=(const ScriptValue& value) const
@@ -101,24 +105,24 @@
     bool isNull() const
     {
         ASSERT(!hasNoValue());
-        return v8ValueRaw()->IsNull();
+        return m_value->isNull();
     }
 
     bool isUndefined() const
     {
         ASSERT(!hasNoValue());
-        return v8ValueRaw()->IsUndefined();
+        return m_value->isUndefined();
     }
 
     bool isObject() const
     {
         ASSERT(!hasNoValue());
-        return v8ValueRaw()->IsObject();
+        return m_value->isObject();
     }
 
     bool hasNoValue() const
     {
-        return !m_value.get() || m_value->get().IsEmpty();
+        return !m_value.get() || m_value->isEmpty();
     }
 
     PassRefPtr<SerializedScriptValue> serialize(ScriptState*);
@@ -132,17 +136,12 @@
 
     v8::Handle<v8::Value> v8Value() const
     {
-        return v8::Local<v8::Value>::New(v8ValueRaw());
+        return m_value.get() ? m_value->newLocal(v8::Isolate::GetCurrent()) : v8::Handle<v8::Value>();
     }
 
-    // FIXME: This function should be private. 
-    v8::Handle<v8::Value> v8ValueRaw() const
-    {
-        return m_value.get() ? m_value->get() : v8::Handle<v8::Value>();
-    }
-
-    bool getString(ScriptState*, String& result) const { return getString(result); }
-    bool getString(String& result) const;
+    bool getString(ScriptState* scriptState, String& result) const { return getString(result, scriptState->isolate()); }
+    bool getString(String& result) const { return getString(result, v8::Isolate::GetCurrent()); }
+    bool getString(String& result, v8::Isolate*) const;
     String toString(ScriptState*) const;
 
     PassRefPtr<InspectorValue> toInspectorValue(ScriptState*) const;
diff --git a/Source/bindings/v8/ScriptWrappable.h b/Source/bindings/v8/ScriptWrappable.h
index 43befba..9a0333a 100644
--- a/Source/bindings/v8/ScriptWrappable.h
+++ b/Source/bindings/v8/ScriptWrappable.h
@@ -71,7 +71,7 @@
         }
         v8::Persistent<v8::Object> persistent(isolate, wrapper);
         configuration.configureWrapper(&persistent, isolate);
-        persistent.MakeWeak(isolate, this, &makeWeakCallback);
+        persistent.MakeWeak(this, &makeWeakCallback);
         m_wrapperOrTypeInfo = reinterpret_cast<uintptr_t>(persistent.ClearAndLeak()) | 1;
         ASSERT(containsWrapper());
     }
diff --git a/Source/bindings/v8/SharedPersistent.h b/Source/bindings/v8/SharedPersistent.h
index 4b3d57f..420f40d 100644
--- a/Source/bindings/v8/SharedPersistent.h
+++ b/Source/bindings/v8/SharedPersistent.h
@@ -40,15 +40,30 @@
 
     template <typename T>
     class SharedPersistent : public RefCounted<SharedPersistent<T> > {
+    WTF_MAKE_NONCOPYABLE(SharedPersistent);
     public:
         static PassRefPtr<SharedPersistent<T> > create(v8::Handle<T> value)
         {
             return adoptRef(new SharedPersistent<T>(value));
         }
-        inline v8::Handle<T> get()
+
+        v8::Local<T> newLocal(v8::Isolate* isolate) const
         {
-            return m_value.get();
+            return m_value.newLocal(isolate);
         }
+
+        bool isEmpty() { return m_value.isEmpty(); }
+        bool isNull() { return m_value.isNull(); }
+        bool isUndefined() { return m_value.isUndefined(); }
+        bool isFunction() { return m_value.isFunction(); }
+        bool isString() { return m_value.isString(); }
+        bool isObject() { return m_value.isObject(); }
+
+        bool operator==(const SharedPersistent<T>& other)
+        {
+            return m_value == other.m_value;
+        }
+
     private:
         explicit SharedPersistent(v8::Handle<T> value) : m_value(value) { }
         ScopedPersistent<T> m_value;
diff --git a/Source/bindings/v8/V8AbstractEventListener.cpp b/Source/bindings/v8/V8AbstractEventListener.cpp
index 18fcc76..08d61f4 100644
--- a/Source/bindings/v8/V8AbstractEventListener.cpp
+++ b/Source/bindings/v8/V8AbstractEventListener.cpp
@@ -58,8 +58,8 @@
 V8AbstractEventListener::~V8AbstractEventListener()
 {
     if (!m_listener.isEmpty()) {
-        v8::HandleScope scope;
-        V8EventListenerList::clearWrapper(v8::Local<v8::Object>::New(m_listener.get()), m_isAttribute);
+        v8::HandleScope scope(m_isolate);
+        V8EventListenerList::clearWrapper(m_listener.newLocal(m_isolate), m_isAttribute);
     }
     ThreadLocalInspectorCounters::current().decrementCounter(ThreadLocalInspectorCounters::JSEventListenerCounter);
 }
@@ -96,7 +96,7 @@
 void V8AbstractEventListener::setListenerObject(v8::Handle<v8::Object> listener)
 {
     m_listener.set(m_isolate, listener);
-    m_listener.getUnsafe().MakeWeak(m_isolate, this, &makeWeakCallback);
+    m_listener.getUnsafe().MakeWeak(this, &makeWeakCallback);
 }
 
 void V8AbstractEventListener::invokeEventHandler(ScriptExecutionContext* context, Event* event, v8::Local<v8::Value> jsEvent)
diff --git a/Source/bindings/v8/V8AbstractEventListener.h b/Source/bindings/v8/V8AbstractEventListener.h
index 0ed3dbc..6a2806d 100644
--- a/Source/bindings/v8/V8AbstractEventListener.h
+++ b/Source/bindings/v8/V8AbstractEventListener.h
@@ -109,7 +109,7 @@
             m_listener.clear();
         }
 
-        DOMWrapperWorld* world() const { return m_world.get(); }
+        virtual DOMWrapperWorld* world() const OVERRIDE FINAL { return m_world.get(); }
 
     protected:
         V8AbstractEventListener(bool isAttribute, PassRefPtr<DOMWrapperWorld>, v8::Isolate*);
diff --git a/Source/bindings/v8/V8AdaptorFunction.cpp b/Source/bindings/v8/V8AdaptorFunction.cpp
deleted file mode 100644
index ff47f19..0000000
--- a/Source/bindings/v8/V8AdaptorFunction.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "bindings/v8/V8AdaptorFunction.h"
-
-#include "bindings/v8/V8PerIsolateData.h"
-#include "bindings/v8/V8ScriptRunner.h"
-#include "wtf/Vector.h"
-
-namespace WebCore {
-
-WrapperTypeInfo V8AdaptorFunction::info = { V8AdaptorFunction::getTemplate, 0, 0, 0, 0, 0, 0, WrapperTypeObjectPrototype };
-
-v8::Handle<v8::FunctionTemplate> V8AdaptorFunction::getTemplate(v8::Isolate* isolate, WrapperWorldType worldType)
-{
-    ASSERT(isolate);
-    V8PerIsolateData* data = V8PerIsolateData::from(isolate);
-    V8PerIsolateData::TemplateMap::iterator result = data->rawTemplateMap(worldType).find(&info);
-    if (result != data->rawTemplateMap(worldType).end())
-        return result->value.newLocal(isolate);
-    // The lifetime is of newTemplate is delegated to the TemplateMap thus this won't be leaked.
-    v8::Handle<v8::FunctionTemplate> newTemplate = configureTemplate(v8::FunctionTemplate::New());
-    data->rawTemplateMap(worldType).add(&info, UnsafePersistent<v8::FunctionTemplate>(isolate, newTemplate));
-    return newTemplate;
-}
-
-v8::Handle<v8::FunctionTemplate> V8AdaptorFunction::configureTemplate(v8::Handle<v8::FunctionTemplate> functionTemplate)
-{
-    functionTemplate->SetCallHandler(&V8AdaptorFunction::invocationCallback);
-    return functionTemplate;
-}
-
-void V8AdaptorFunction::invocationCallback(const v8::FunctionCallbackInfo<v8::Value>& args)
-{
-    v8::Handle<v8::Object> wrapped = v8::Handle<v8::Object>::Cast(args.Callee()->GetHiddenValue(V8HiddenPropertyName::adaptorFunctionPeer()));
-    // FIXME: This can be faster if we can access underlying native callback directly.
-    // We won't need this once https://bugs.webkit.org/show_bug.cgi?id=108138 is addressed.
-    Vector<v8::Handle<v8::Value> > argArray(args.Length());
-    for (int i = 0; i < args.Length(); ++i)
-        argArray.append(args[i]);
-    if (args.IsConstructCall()) {
-        v8SetReturnValue(args, V8ScriptRunner::callAsConstructor(wrapped, argArray.size(), argArray.data()));
-        return;
-    }
-    v8SetReturnValue(args, V8ScriptRunner::callAsFunction(wrapped, args.This(), argArray.size(), argArray.data()));
-}
-
-v8::Handle<v8::Function> V8AdaptorFunction::wrap(v8::Handle<v8::Object> object, const AtomicString& name, v8::Isolate* isolate)
-{
-    if (object.IsEmpty() || !object->IsObject())
-        return v8::Handle<v8::Function>();
-    v8::Handle<v8::Function> adaptor = v8::Handle<v8::Function>::Cast(getTemplate(isolate, worldType(isolate))->GetFunction()->Clone());
-    if (adaptor.IsEmpty())
-        return v8::Handle<v8::Function>();
-    adaptor->SetName(v8String(name.string(), isolate));
-    adaptor->SetHiddenValue(V8HiddenPropertyName::adaptorFunctionPeer(), object);
-    object->SetHiddenValue(V8HiddenPropertyName::adaptorFunctionPeer(), adaptor);
-    return adaptor;
-}
-
-} // namespace WebCore
diff --git a/Source/bindings/v8/V8AdaptorFunction.h b/Source/bindings/v8/V8AdaptorFunction.h
deleted file mode 100644
index d071a4a..0000000
--- a/Source/bindings/v8/V8AdaptorFunction.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef V8AdaptorFunction_h
-#define V8AdaptorFunction_h
-
-#include "bindings/v8/V8Binding.h"
-#include "bindings/v8/V8HiddenPropertyName.h"
-#include "bindings/v8/WrapperTypeInfo.h"
-#include "wtf/PassRefPtr.h"
-
-namespace WebCore {
-
-//
-// FIXME(https://bugs.webkit.org/show_bug.cgi?id=108138):
-// V8AdaptorFunction class and V8WrapAsFunction IDL attribute are needed for two reasons:
-// - 1) V8 doesn't allow expanding the internal field of function objects. https://code.google.com/p/v8/issues/detail?id=837
-//      WebKit need it to associate each wrapper to its backing C++ object. We store it in a hidden property of the wrapped object.
-// - 2) Binding codebase assumes every wrapper object is created through ObjectTemplate::NewInstance(), not FunctionTemplate::GetFunction().
-// Once 1) is addresssed, we could attack 2) with it. 
-//
-class V8AdaptorFunction {
-public:
-    static WrapperTypeInfo info;
-    static v8::Handle<v8::Object> unwrap(v8::Handle<v8::Function>);
-    static v8::Handle<v8::Function> wrap(v8::Handle<v8::Object>, const AtomicString& name, v8::Isolate*);
-    static v8::Handle<v8::Function> get(v8::Handle<v8::Object>);
-
-    static v8::Handle<v8::FunctionTemplate> getTemplate(v8::Isolate*, WrapperWorldType);
-    static v8::Handle<v8::FunctionTemplate> configureTemplate(v8::Handle<v8::FunctionTemplate>);
-    static void invocationCallback(const v8::FunctionCallbackInfo<v8::Value>&);
-};
-
-inline v8::Handle<v8::Object> V8AdaptorFunction::unwrap(v8::Handle<v8::Function> function)
-{
-    v8::Handle<v8::Value> wrapped = function->GetHiddenValue(V8HiddenPropertyName::adaptorFunctionPeer());
-    ASSERT(!wrapped.IsEmpty());
-    ASSERT(wrapped->IsObject());
-    return v8::Handle<v8::Object>::Cast(wrapped);
-}
-
-inline v8::Handle<v8::Function> V8AdaptorFunction::get(v8::Handle<v8::Object> object)
-{
-    v8::Handle<v8::Value> adaptorFunction = object->GetHiddenValue(V8HiddenPropertyName::adaptorFunctionPeer());
-    ASSERT(!adaptorFunction.IsEmpty());
-    ASSERT(adaptorFunction->IsFunction());
-    return v8::Handle<v8::Function>::Cast(adaptorFunction);
-}
-
-} // namespace WebCore
-
-#endif // V8AdaptorFunction_h
diff --git a/Source/bindings/v8/V8Binding.cpp b/Source/bindings/v8/V8Binding.cpp
index 9bd2b00..58be354 100644
--- a/Source/bindings/v8/V8Binding.cpp
+++ b/Source/bindings/v8/V8Binding.cpp
@@ -32,14 +32,14 @@
 #include "bindings/v8/V8Binding.h"
 
 #include "V8DOMStringList.h"
-#include "V8DOMWindow.h"
 #include "V8Element.h"
+#include "V8Window.h"
 #include "V8WorkerContext.h"
 #include "V8XPathNSResolver.h"
 #include "bindings/v8/ScriptController.h"
-#include "bindings/v8/V8DOMWindowShell.h"
 #include "bindings/v8/V8NodeFilterCondition.h"
 #include "bindings/v8/V8ObjectConstructor.h"
+#include "bindings/v8/V8WindowShell.h"
 #include "bindings/v8/WorkerScriptController.h"
 #include "bindings/v8/custom/V8CustomXPathNSResolver.h"
 #include "core/dom/DOMStringList.h"
@@ -115,6 +115,9 @@
     return NodeFilter::create(V8NodeFilterCondition::create(callback));
 }
 
+static const int8_t kMaxInt8 = 127;
+static const int8_t kMinInt8 = -128;
+static const uint8_t kMaxUInt8 = 255;
 const int32_t kMaxInt32 = 0x7fffffff;
 const int32_t kMinInt32 = -kMaxInt32 - 1;
 const uint32_t kMaxUInt32 = 0xffffffff;
@@ -134,6 +137,79 @@
     return x;
 }
 
+int8_t toInt8(v8::Handle<v8::Value> value, IntegerConversionConfiguration configuration, bool& ok)
+{
+    ok = true;
+
+    // Fast case. The value is already a 32-bit integer in the right range.
+    if (value->IsInt32()) {
+        int32_t result = value->Int32Value();
+        if (result >= kMinInt8 && result <= kMaxInt8)
+            return static_cast<int8_t>(result);
+        if (configuration == EnforceRange) {
+            ok = false;
+            return 0;
+        }
+        result %= 256; // 2^8.
+        return static_cast<int8_t>(result > kMaxInt8 ? result - 256 : result);
+    }
+
+    // Can the value be converted to a number?
+    v8::Local<v8::Number> numberObject = value->ToNumber();
+    if (numberObject.IsEmpty()) {
+        ok = false;
+        return 0;
+    }
+
+    if (configuration == EnforceRange)
+        return enforceRange(numberObject->Value(), kMinInt8, kMaxInt8, ok);
+
+    double numberValue = numberObject->Value();
+    if (std::isnan(numberValue) || std::isinf(numberValue) || !numberValue)
+        return 0;
+
+    numberValue = numberValue < 0 ? -floor(abs(numberValue)) : floor(abs(numberValue));
+    numberValue = fmod(numberValue, 256); // 2^8.
+
+    return static_cast<int8_t>(numberValue > kMaxInt8 ? numberValue - 256 : numberValue);
+}
+
+uint8_t toUInt8(v8::Handle<v8::Value> value, IntegerConversionConfiguration configuration, bool& ok)
+{
+    ok = true;
+
+    // Fast case. The value is a 32-bit signed integer - possibly positive?
+    if (value->IsInt32()) {
+        int32_t result = value->Int32Value();
+        if (result >= 0 && result <= kMaxUInt8)
+            return static_cast<uint8_t>(result);
+        if (configuration == EnforceRange) {
+            ok = false;
+            return 0;
+        }
+        // Converting to uint8_t will cause the resulting value to be the value modulo 2^8.
+        return static_cast<uint8_t>(result);
+    }
+
+    // Can the value be converted to a number?
+    v8::Local<v8::Number> numberObject = value->ToNumber();
+    if (numberObject.IsEmpty()) {
+        ok = false;
+        return 0;
+    }
+
+    if (configuration == EnforceRange)
+        return enforceRange(numberObject->Value(), 0, kMaxUInt8, ok);
+
+    // Does the value convert to nan or to an infinity?
+    double numberValue = numberObject->Value();
+    if (std::isnan(numberValue) || std::isinf(numberValue) || !numberValue)
+        return 0;
+
+    numberValue = numberValue < 0 ? -floor(abs(numberValue)) : floor(abs(numberValue));
+    return static_cast<uint8_t>(fmod(numberValue, 256)); // 2^8.
+}
+
 int32_t toInt32(v8::Handle<v8::Value> value, IntegerConversionConfiguration configuration, bool& ok)
 {
     ok = true;
@@ -307,23 +383,23 @@
 {
     v8::Handle<v8::Object> global = context->Global();
     ASSERT(!global.IsEmpty());
-    v8::Handle<v8::Object> window = global->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(context->GetIsolate(), MainWorld));
+    v8::Handle<v8::Object> window = global->FindInstanceInPrototypeChain(V8Window::GetTemplate(context->GetIsolate(), MainWorld));
     if (!window.IsEmpty())
-        return V8DOMWindow::toNative(window);
-    window = global->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(context->GetIsolate(), IsolatedWorld));
+        return V8Window::toNative(window);
+    window = global->FindInstanceInPrototypeChain(V8Window::GetTemplate(context->GetIsolate(), IsolatedWorld));
     ASSERT(!window.IsEmpty());
-    return V8DOMWindow::toNative(window);
+    return V8Window::toNative(window);
 }
 
 ScriptExecutionContext* toScriptExecutionContext(v8::Handle<v8::Context> context)
 {
     v8::Handle<v8::Object> global = context->Global();
-    v8::Handle<v8::Object> windowWrapper = global->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(context->GetIsolate(), MainWorld));
+    v8::Handle<v8::Object> windowWrapper = global->FindInstanceInPrototypeChain(V8Window::GetTemplate(context->GetIsolate(), MainWorld));
     if (!windowWrapper.IsEmpty())
-        return V8DOMWindow::toNative(windowWrapper)->scriptExecutionContext();
-    windowWrapper = global->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(context->GetIsolate(), IsolatedWorld));
+        return V8Window::toNative(windowWrapper)->scriptExecutionContext();
+    windowWrapper = global->FindInstanceInPrototypeChain(V8Window::GetTemplate(context->GetIsolate(), IsolatedWorld));
     if (!windowWrapper.IsEmpty())
-        return V8DOMWindow::toNative(windowWrapper)->scriptExecutionContext();
+        return V8Window::toNative(windowWrapper)->scriptExecutionContext();
     v8::Handle<v8::Object> workerWrapper = global->FindInstanceInPrototypeChain(V8WorkerContext::GetTemplate(context->GetIsolate(), WorkerWorld));
     if (!workerWrapper.IsEmpty())
         return V8WorkerContext::toNative(workerWrapper)->scriptExecutionContext();
@@ -433,4 +509,15 @@
     return MainWorld;
 }
 
+DOMWrapperWorld* isolatedWorldForIsolate(v8::Isolate* isolate)
+{
+    V8PerIsolateData* data = V8PerIsolateData::from(isolate);
+    if (data->workerDOMDataStore())
+        return 0;
+    if (!DOMWrapperWorld::isolatedWorldsExist())
+        return 0;
+    ASSERT(!v8::Context::GetEntered().IsEmpty());
+    return DOMWrapperWorld::isolatedWorld(v8::Context::GetEntered());
+}
+
 } // namespace WebCore
diff --git a/Source/bindings/v8/V8Binding.h b/Source/bindings/v8/V8Binding.h
index e2c8c94..f884fcd 100644
--- a/Source/bindings/v8/V8Binding.h
+++ b/Source/bindings/v8/V8Binding.h
@@ -282,6 +282,32 @@
         // FIXME: Implement Clamp
     };
 
+    // Convert a value to a 8-bit signed integer. The conversion fails if the
+    // value cannot be converted to a number or the range violated per WebIDL:
+    // http://www.w3.org/TR/WebIDL/#es-byte
+    int8_t toInt8(v8::Handle<v8::Value>, IntegerConversionConfiguration, bool& ok);
+    inline int8_t toInt8(v8::Handle<v8::Value> value, bool& ok) { return toInt8(value, NormalConversion, ok); }
+
+    // Convert a value to a 8-bit integer assuming the conversion cannot fail.
+    inline int8_t toInt8(v8::Handle<v8::Value> value)
+    {
+        bool ok;
+        return toInt8(value, NormalConversion, ok);
+    }
+
+    // Convert a value to a 8-bit unsigned integer. The conversion fails if the
+    // value cannot be converted to a number or the range violated per WebIDL:
+    // http://www.w3.org/TR/WebIDL/#es-octet
+    uint8_t toUInt8(v8::Handle<v8::Value>, IntegerConversionConfiguration, bool& ok);
+    inline uint8_t toUInt8(v8::Handle<v8::Value> value, bool& ok) { return toUInt8(value, NormalConversion, ok); }
+
+    // Convert a value to a 8-bit unsigned integer assuming the conversion cannot fail.
+    inline uint8_t toUInt8(v8::Handle<v8::Value> value)
+    {
+        bool ok;
+        return toUInt8(value, NormalConversion, ok);
+    }
+
     // Convert a value to a 32-bit signed integer. The conversion fails if the
     // value cannot be converted to a number or the range violated per WebIDL:
     // http://www.w3.org/TR/WebIDL/#es-long
@@ -340,6 +366,8 @@
     WrapperWorldType worldType(v8::Isolate*);
     WrapperWorldType worldTypeInMainThread(v8::Isolate*);
 
+    DOMWrapperWorld* isolatedWorldForIsolate(v8::Isolate*);
+
     template<class T> struct NativeValueTraits;
 
     template<>
diff --git a/Source/bindings/v8/V8Collection.h b/Source/bindings/v8/V8Collection.h
index 1f9d3b2..5cb1718 100644
--- a/Source/bindings/v8/V8Collection.h
+++ b/Source/bindings/v8/V8Collection.h
@@ -59,7 +59,7 @@
 }
 
 // Get an array containing the names of indexed properties of HTMLSelectElement and HTMLFormElement.
-template<class Collection> static v8::Handle<v8::Array> nodeCollectionIndexedPropertyEnumerator(const v8::AccessorInfo& info)
+template<class Collection> static void nodeCollectionIndexedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& info)
 {
     ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));
     Collection* collection = toNativeCollection<Collection>(info.Holder());
@@ -70,7 +70,7 @@
         v8::Handle<v8::Integer> integer = v8Integer(i, info.GetIsolate());
         properties->Set(integer, integer);
     }
-    return properties;
+    v8SetReturnValue(info, properties);
 }
 
 v8::Handle<v8::Value> toOptionsCollectionSetter(uint32_t index, v8::Handle<v8::Value>, HTMLSelectElement*, v8::Isolate*);
diff --git a/Source/bindings/v8/V8DOMWrapper.cpp b/Source/bindings/v8/V8DOMWrapper.cpp
index 36bc2e2..4b1e0b1 100644
--- a/Source/bindings/v8/V8DOMWrapper.cpp
+++ b/Source/bindings/v8/V8DOMWrapper.cpp
@@ -31,10 +31,9 @@
 #include "config.h"
 #include "bindings/v8/V8DOMWrapper.h"
 
-#include "V8DOMWindow.h"
 #include "V8HTMLCollection.h"
 #include "V8HTMLDocument.h"
-#include "bindings/v8/V8AdaptorFunction.h"
+#include "V8Window.h"
 #include "bindings/v8/V8Binding.h"
 #include "bindings/v8/V8HiddenPropertyName.h"
 #include "bindings/v8/V8ObjectConstructor.h"
@@ -171,21 +170,4 @@
     return typeInfo == type;
 }
 
-v8::Handle<v8::Function> V8DOMWrapper::toFunction(v8::Handle<v8::Value> object)
-{
-    return V8AdaptorFunction::get(v8::Handle<v8::Object>::Cast(object));
-}
-
-v8::Handle<v8::Function> V8DOMWrapper::toFunction(v8::Handle<v8::Object> object, const AtomicString& name, v8::Isolate* isolate)
-{
-    return V8AdaptorFunction::wrap(object, name, isolate);
-}
-
-v8::Handle<v8::Object> V8DOMWrapper::fromFunction(v8::Handle<v8::Object> object)
-{
-    if (!object->IsFunction())
-        return object;
-    return V8AdaptorFunction::unwrap(v8::Handle<v8::Function>::Cast(object));
-}
-
 }  // namespace WebCore
diff --git a/Source/bindings/v8/V8DOMWrapper.h b/Source/bindings/v8/V8DOMWrapper.h
index ab47334..9e274d7 100644
--- a/Source/bindings/v8/V8DOMWrapper.h
+++ b/Source/bindings/v8/V8DOMWrapper.h
@@ -56,11 +56,6 @@
 
         static bool isDOMWrapper(v8::Handle<v8::Value>);
         static bool isWrapperOfType(v8::Handle<v8::Value>, WrapperTypeInfo*);
-
-        // Used for V8WrapAsFunction, which is used only by CUSTOM_ELEMENTS
-        static v8::Handle<v8::Function> toFunction(v8::Handle<v8::Value>);
-        static v8::Handle<v8::Function> toFunction(v8::Handle<v8::Object>, const AtomicString& name, v8::Isolate*);
-        static v8::Handle<v8::Object> fromFunction(v8::Handle<v8::Object>);
     };
 
     inline void V8DOMWrapper::setNativeInfo(v8::Handle<v8::Object> wrapper, WrapperTypeInfo* type, void* object)
diff --git a/Source/bindings/v8/V8EventListenerList.cpp b/Source/bindings/v8/V8EventListenerList.cpp
index b3ecffb..85c0962 100644
--- a/Source/bindings/v8/V8EventListenerList.cpp
+++ b/Source/bindings/v8/V8EventListenerList.cpp
@@ -31,7 +31,7 @@
 #include "config.h"
 #include "bindings/v8/V8EventListenerList.h"
 
-#include "V8DOMWindow.h"
+#include "V8Window.h"
 #include "bindings/v8/V8Binding.h"
 #include "bindings/v8/V8WorkerContextEventListener.h"
 
@@ -44,7 +44,7 @@
         return 0;
     if (lookup == ListenerFindOnly)
         return V8EventListenerList::findWrapper(value, isAttribute);
-    if (V8DOMWrapper::isWrapperOfType(toInnerGlobalObject(context), &V8DOMWindow::info))
+    if (V8DOMWrapper::isWrapperOfType(toInnerGlobalObject(context), &V8Window::info))
         return V8EventListenerList::findOrCreateWrapper<V8EventListener>(value, isAttribute);
     return V8EventListenerList::findOrCreateWrapper<V8WorkerContextEventListener>(value, isAttribute);
 }
diff --git a/Source/bindings/v8/V8GCController.cpp b/Source/bindings/v8/V8GCController.cpp
index 718d857..b4e3c63 100644
--- a/Source/bindings/v8/V8GCController.cpp
+++ b/Source/bindings/v8/V8GCController.cpp
@@ -84,7 +84,7 @@
     // The same special handling is in V8GCController::gcTree().
     // Maybe should image elements be active DOM nodes?
     // See https://code.google.com/p/chromium/issues/detail?id=164882
-    if (node->inDocument() || (node->hasTagName(HTMLNames::imgTag) && static_cast<HTMLImageElement*>(node)->hasPendingActivity()))
+    if (node->inDocument() || (node->hasTagName(HTMLNames::imgTag) && toHTMLImageElement(node)->hasPendingActivity()))
         return node->document();
 
     if (node->isAttributeNode()) {
@@ -171,7 +171,7 @@
                 // The same special handling is in V8GCController::opaqueRootForGC().
                 // Maybe should image elements be active DOM nodes?
                 // See https://code.google.com/p/chromium/issues/detail?id=164882
-                if (!node->isV8CollectableDuringMinorGC() || (node->hasTagName(HTMLNames::imgTag) && static_cast<HTMLImageElement*>(node)->hasPendingActivity())) {
+                if (!node->isV8CollectableDuringMinorGC() || (node->hasTagName(HTMLNames::imgTag) && toHTMLImageElement(node)->hasPendingActivity())) {
                     // This node is not in the new space of V8. This indicates that
                     // the minor GC cannot anyway judge reachability of this DOM tree.
                     // Thus we give up traversing the DOM tree.
diff --git a/Source/bindings/v8/V8HiddenPropertyName.h b/Source/bindings/v8/V8HiddenPropertyName.h
index 3462345..182ff23 100644
--- a/Source/bindings/v8/V8HiddenPropertyName.h
+++ b/Source/bindings/v8/V8HiddenPropertyName.h
@@ -36,17 +36,20 @@
 namespace WebCore {
 
 #define V8_HIDDEN_PROPERTIES(V) \
+    V(adaptorFunctionPeer) \
     V(attributeListener) \
     V(callback) \
     V(detail) \
     V(document) \
     V(event) \
     V(listener) \
+    V(name) \
+    V(namespaceURI) \
     V(scriptState) \
     V(sleepFunction) \
     V(state) \
-    V(adaptorFunctionPeer) \
     V(toStringString) \
+    V(type) \
     V(typedArrayHiddenCopyMethod)
 
 class V8HiddenPropertyName {
diff --git a/Source/bindings/v8/V8Initializer.cpp b/Source/bindings/v8/V8Initializer.cpp
index 86cb134..6e8509b 100644
--- a/Source/bindings/v8/V8Initializer.cpp
+++ b/Source/bindings/v8/V8Initializer.cpp
@@ -26,9 +26,9 @@
 #include "config.h"
 #include "bindings/v8/V8Initializer.h"
 
-#include "V8DOMWindow.h"
 #include "V8History.h"
 #include "V8Location.h"
+#include "V8Window.h"
 #include "bindings/v8/ScriptCallStackFactory.h"
 #include "bindings/v8/ScriptProfiler.h"
 #include "bindings/v8/V8Binding.h"
@@ -49,11 +49,11 @@
 {
     WrapperTypeInfo* type = WrapperTypeInfo::unwrap(data);
 
-    if (V8DOMWindow::info.equals(type)) {
-        v8::Handle<v8::Object> windowWrapper = host->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(isolate, worldTypeInMainThread(isolate)));
+    if (V8Window::info.equals(type)) {
+        v8::Handle<v8::Object> windowWrapper = host->FindInstanceInPrototypeChain(V8Window::GetTemplate(isolate, worldTypeInMainThread(isolate)));
         if (windowWrapper.IsEmpty())
             return 0;
-        return V8DOMWindow::toNative(windowWrapper)->frame();
+        return V8Window::toNative(windowWrapper)->frame();
     }
 
     if (V8History::info.equals(type))
diff --git a/Source/bindings/v8/V8LazyEventListener.cpp b/Source/bindings/v8/V8LazyEventListener.cpp
index fc2d400..27c320f 100644
--- a/Source/bindings/v8/V8LazyEventListener.cpp
+++ b/Source/bindings/v8/V8LazyEventListener.cpp
@@ -164,7 +164,7 @@
 
     v8::Handle<v8::String> codeExternalString = v8String(code, isolate);
 
-    v8::Local<v8::Value> result = V8ScriptRunner::compileAndRunInternalScript(codeExternalString, isolate, m_sourceURL, m_position);
+    v8::Local<v8::Value> result = V8ScriptRunner::compileAndRunInternalScript(codeExternalString, isolate, m_sourceURL, m_position, 0);
     if (result.IsEmpty())
         return;
 
diff --git a/Source/bindings/v8/V8MutationCallback.cpp b/Source/bindings/v8/V8MutationCallback.cpp
index 3dc105c..38976b8 100644
--- a/Source/bindings/v8/V8MutationCallback.cpp
+++ b/Source/bindings/v8/V8MutationCallback.cpp
@@ -42,7 +42,7 @@
     , m_world(DOMWrapperWorld::current())
 {
     owner->SetHiddenValue(V8HiddenPropertyName::callback(), callback);
-    m_callback.getUnsafe().MakeWeak(isolate, this, &makeWeakCallback);
+    m_callback.getUnsafe().MakeWeak(this, &makeWeakCallback);
 }
 
 void V8MutationCallback::call(const Vector<RefPtr<MutationRecord> >& mutations, MutationObserver* observer)
@@ -59,7 +59,7 @@
     v8::Context::Scope scope(v8Context);
     v8::Isolate* isolate = v8Context->GetIsolate();
 
-    v8::Handle<v8::Function> callback = v8::Local<v8::Function>::New(isolate, m_callback.get());
+    v8::Handle<v8::Function> callback = m_callback.newLocal(isolate);
     if (callback.IsEmpty())
         return;
 
diff --git a/Source/bindings/v8/V8NPObject.cpp b/Source/bindings/v8/V8NPObject.cpp
index 1df4445..dd78ded 100644
--- a/Source/bindings/v8/V8NPObject.cpp
+++ b/Source/bindings/v8/V8NPObject.cpp
@@ -183,7 +183,7 @@
     {
         ASSERT(!m_map.contains(key));
         v8::Persistent<v8::FunctionTemplate> wrapper(m_isolate, handle);
-        wrapper.MakeWeak(m_isolate, key, &makeWeakCallback);
+        wrapper.MakeWeak(key, &makeWeakCallback);
         m_map.set(key, UnsafePersistent<v8::FunctionTemplate>(wrapper));
     }
 
@@ -272,34 +272,36 @@
     return v8Undefined();
 }
 
-v8::Handle<v8::Value> npObjectNamedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
+void npObjectNamedPropertyGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
 {
     NPIdentifier identifier = getStringIdentifier(name);
-    return npObjectGetProperty(info.Holder(), identifier, name, info.GetIsolate());
+    v8SetReturnValue(info, npObjectGetProperty(info.Holder(), identifier, name, info.GetIsolate()));
 }
 
-v8::Handle<v8::Value> npObjectIndexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info)
+void npObjectIndexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info)
 {
     NPIdentifier identifier = _NPN_GetIntIdentifier(index);
-    return npObjectGetProperty(info.Holder(), identifier, v8::Number::New(index), info.GetIsolate());
+    v8SetReturnValue(info, npObjectGetProperty(info.Holder(), identifier, v8::Number::New(index), info.GetIsolate()));
 }
 
-v8::Handle<v8::Value> npObjectGetNamedProperty(v8::Local<v8::Object> self, v8::Local<v8::String> name, const v8::AccessorInfo& info)
+void npObjectGetNamedProperty(v8::Local<v8::Object> self, v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
 {
     NPIdentifier identifier = getStringIdentifier(name);
-    return npObjectGetProperty(self, identifier, name, info.GetIsolate());
+    v8SetReturnValue(info, npObjectGetProperty(self, identifier, name, info.GetIsolate()));
 }
 
-v8::Handle<v8::Value> npObjectGetIndexedProperty(v8::Local<v8::Object> self, uint32_t index, const v8::AccessorInfo& info)
+void npObjectGetIndexedProperty(v8::Local<v8::Object> self, uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info)
 {
     NPIdentifier identifier = _NPN_GetIntIdentifier(index);
-    return npObjectGetProperty(self, identifier, v8::Number::New(index), info.GetIsolate());
+    v8SetReturnValue(info, npObjectGetProperty(self, identifier, v8::Number::New(index), info.GetIsolate()));
 }
 
-v8::Handle<v8::Integer> npObjectQueryProperty(v8::Local<v8::String> name, const v8::AccessorInfo& info)
+void npObjectQueryProperty(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Integer>& info)
 {
     NPIdentifier identifier = getStringIdentifier(name);
-    return npObjectGetProperty(info.Holder(), identifier, name, info.GetIsolate()).IsEmpty() ? v8::Handle<v8::Integer>() : v8Integer(0, info.GetIsolate());
+    if (npObjectGetProperty(info.Holder(), identifier, name, info.GetIsolate()).IsEmpty())
+        return;
+    v8SetReturnValueInt(info, 0);
 }
 
 static v8::Handle<v8::Value> npObjectSetProperty(v8::Local<v8::Object> self, NPIdentifier identifier, v8::Local<v8::Value> value, v8::Isolate* isolate)
@@ -328,32 +330,32 @@
 }
 
 
-v8::Handle<v8::Value> npObjectNamedPropertySetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
+void npObjectNamedPropertySetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<v8::Value>& info)
 {
     NPIdentifier identifier = getStringIdentifier(name);
-    return npObjectSetProperty(info.Holder(), identifier, value, info.GetIsolate());
+    v8SetReturnValue(info, npObjectSetProperty(info.Holder(), identifier, value, info.GetIsolate()));
 }
 
 
-v8::Handle<v8::Value> npObjectIndexedPropertySetter(uint32_t index, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
+void npObjectIndexedPropertySetter(uint32_t index, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<v8::Value>& info)
 {
     NPIdentifier identifier = _NPN_GetIntIdentifier(index);
-    return npObjectSetProperty(info.Holder(), identifier, value, info.GetIsolate());
+    v8SetReturnValue(info, npObjectSetProperty(info.Holder(), identifier, value, info.GetIsolate()));
 }
 
-v8::Handle<v8::Value> npObjectSetNamedProperty(v8::Local<v8::Object> self, v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
+void npObjectSetNamedProperty(v8::Local<v8::Object> self, v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<v8::Value>& info)
 {
     NPIdentifier identifier = getStringIdentifier(name);
-    return npObjectSetProperty(self, identifier, value, info.GetIsolate());
+    v8SetReturnValue(info, npObjectSetProperty(self, identifier, value, info.GetIsolate()));
 }
 
-v8::Handle<v8::Value> npObjectSetIndexedProperty(v8::Local<v8::Object> self, uint32_t index, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
+void npObjectSetIndexedProperty(v8::Local<v8::Object> self, uint32_t index, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<v8::Value>& info)
 {
     NPIdentifier identifier = _NPN_GetIntIdentifier(index);
-    return npObjectSetProperty(self, identifier, value, info.GetIsolate());
+    v8SetReturnValue(info, npObjectSetProperty(self, identifier, value, info.GetIsolate()));
 }
 
-v8::Handle<v8::Array> npObjectPropertyEnumerator(const v8::AccessorInfo& info, bool namedProperty)
+void npObjectPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& info, bool namedProperty)
 {
     NPObject* npObject = v8ObjectToNPObject(info.Holder());
 
@@ -375,21 +377,20 @@
                     properties->Set(v8Integer(i, info.GetIsolate()), v8Integer(identifier->number(), info.GetIsolate()));
             }
 
-            return properties;
+            v8SetReturnValue(info, properties);
+            return;
         }
     }
-
-    return v8::Handle<v8::Array>();
 }
 
-v8::Handle<v8::Array> npObjectNamedPropertyEnumerator(const v8::AccessorInfo& info)
+void npObjectNamedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& info)
 {
-    return npObjectPropertyEnumerator(info, true);
+    npObjectPropertyEnumerator(info, true);
 }
 
-v8::Handle<v8::Array> npObjectIndexedPropertyEnumerator(const v8::AccessorInfo& info)
+void npObjectIndexedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& info)
 {
-    return npObjectPropertyEnumerator(info, false);
+    npObjectPropertyEnumerator(info, false);
 }
 
 static DOMWrapperMap<NPObject>& staticNPObjectMap()
diff --git a/Source/bindings/v8/V8NPObject.h b/Source/bindings/v8/V8NPObject.h
index 5756c7e..cd8d403 100644
--- a/Source/bindings/v8/V8NPObject.h
+++ b/Source/bindings/v8/V8NPObject.h
@@ -38,16 +38,16 @@
 
 // These functions can be replaced by normal JS operation.
 // Getters
-v8::Handle<v8::Value> npObjectNamedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo&);
-v8::Handle<v8::Value> npObjectIndexedPropertyGetter(uint32_t index, const v8::AccessorInfo&);
-v8::Handle<v8::Value> npObjectGetNamedProperty(v8::Local<v8::Object> self, v8::Local<v8::String> name, const v8::AccessorInfo&);
-v8::Handle<v8::Value> npObjectGetIndexedProperty(v8::Local<v8::Object> self, uint32_t index, const v8::AccessorInfo&);
+void npObjectNamedPropertyGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>&);
+void npObjectIndexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>&);
+void npObjectGetNamedProperty(v8::Local<v8::Object> self, v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>&);
+void npObjectGetIndexedProperty(v8::Local<v8::Object> self, uint32_t index, const v8::PropertyCallbackInfo<v8::Value>&);
 
 // Setters
-v8::Handle<v8::Value> npObjectNamedPropertySetter(v8::Local<v8::String> name, v8::Local<v8::Value>, const v8::AccessorInfo&);
-v8::Handle<v8::Value> npObjectIndexedPropertySetter(uint32_t index, const v8::AccessorInfo&);
-v8::Handle<v8::Value> npObjectSetNamedProperty(v8::Local<v8::Object> self, v8::Local<v8::String> name, v8::Local<v8::Value>, const v8::AccessorInfo&);
-v8::Handle<v8::Value> npObjectSetIndexedProperty(v8::Local<v8::Object> self, uint32_t index, v8::Local<v8::Value>, const v8::AccessorInfo&);
+void npObjectNamedPropertySetter(v8::Local<v8::String> name, v8::Local<v8::Value>, const v8::PropertyCallbackInfo<v8::Value>&);
+void npObjectIndexedPropertySetter(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>&);
+void npObjectSetNamedProperty(v8::Local<v8::Object> self, v8::Local<v8::String> name, v8::Local<v8::Value>, const v8::PropertyCallbackInfo<v8::Value>&);
+void npObjectSetIndexedProperty(v8::Local<v8::Object> self, uint32_t index, v8::Local<v8::Value>, const v8::PropertyCallbackInfo<v8::Value>&);
 
 void npObjectInvokeDefaultHandler(const v8::FunctionCallbackInfo<v8::Value>&);
 
diff --git a/Source/bindings/v8/V8PerContextData.cpp b/Source/bindings/v8/V8PerContextData.cpp
index 6ff19dc..95943da 100644
--- a/Source/bindings/v8/V8PerContextData.cpp
+++ b/Source/bindings/v8/V8PerContextData.cpp
@@ -37,30 +37,30 @@
 
 namespace WebCore {
 
+template<typename Map>
+static void disposeMapWithUnsafePersistentValues(Map* map)
+{
+    typename Map::iterator it = map->begin();
+    for (; it != map->end(); ++it)
+        it->value.dispose();
+    map->clear();
+}
+
 void V8PerContextData::dispose()
 {
     v8::HandleScope handleScope(m_isolate);
     v8::Local<v8::Context>::New(m_isolate, m_context)->SetAlignedPointerInEmbedderData(v8ContextPerContextDataIndex, 0);
 
-    {
-        WrapperBoilerplateMap::iterator it = m_wrapperBoilerplates.begin();
-        for (; it != m_wrapperBoilerplates.end(); ++it)
-            it->value.dispose();
-        m_wrapperBoilerplates.clear();
-    }
+    disposeMapWithUnsafePersistentValues(&m_wrapperBoilerplates);
+    disposeMapWithUnsafePersistentValues(&m_constructorMap);
+    disposeMapWithUnsafePersistentValues(&m_customElementPrototypeMap);
 
-    {
-        ConstructorMap::iterator it = m_constructorMap.begin();
-        for (; it != m_constructorMap.end(); ++it)
-            it->value.dispose();
-        m_constructorMap.clear();
-    }
     m_context.Dispose();
 }
 
 #define V8_STORE_PRIMORDIAL(name, Name) \
 { \
-    ASSERT(m_##name##Prototype.get().IsEmpty()); \
+    ASSERT(m_##name##Prototype.isEmpty()); \
     v8::Handle<v8::String> symbol = v8::String::NewSymbol(#Name); \
     if (symbol.IsEmpty()) \
         return false; \
@@ -123,7 +123,7 @@
             prototypeObject->SetAlignedPointerInInternalField(v8PrototypeTypeIndex, type);
         type->installPerContextPrototypeProperties(prototypeObject, m_isolate);
         if (type->wrapperTypePrototype == WrapperTypeErrorPrototype)
-            prototypeObject->SetPrototype(m_errorPrototype.get());
+            prototypeObject->SetPrototype(m_errorPrototype.newLocal(m_isolate));
     }
 
     m_constructorMap.set(type, UnsafePersistent<v8::Function>(m_isolate, function));
diff --git a/Source/bindings/v8/V8PerContextData.h b/Source/bindings/v8/V8PerContextData.h
index fbdfeba..b4fc464 100644
--- a/Source/bindings/v8/V8PerContextData.h
+++ b/Source/bindings/v8/V8PerContextData.h
@@ -39,6 +39,8 @@
 #include "wtf/HashMap.h"
 #include "wtf/PassOwnPtr.h"
 #include "wtf/Vector.h"
+#include "wtf/text/AtomicString.h"
+#include "wtf/text/AtomicStringHash.h"
 
 namespace WebCore {
 
@@ -105,6 +107,13 @@
         m_activityLogger = logger;
     }
 
+    typedef WTF::HashMap<AtomicString, UnsafePersistent<v8::Object> > CustomElementPrototypeMap;
+
+    CustomElementPrototypeMap* customElementPrototypes()
+    {
+        return &m_customElementPrototypeMap;
+    }
+
 private:
     explicit V8PerContextData(v8::Handle<v8::Context> context)
         : m_activityLogger(0)
@@ -134,6 +143,8 @@
     v8::Isolate* m_isolate;
     v8::Persistent<v8::Context> m_context;
     ScopedPersistent<v8::Value> m_errorPrototype;
+
+    CustomElementPrototypeMap m_customElementPrototypeMap;
 };
 
 class V8PerContextDebugData {
diff --git a/Source/bindings/v8/V8PerIsolateData.cpp b/Source/bindings/v8/V8PerIsolateData.cpp
index 08ea2ac..a19e98b 100644
--- a/Source/bindings/v8/V8PerIsolateData.cpp
+++ b/Source/bindings/v8/V8PerIsolateData.cpp
@@ -103,7 +103,7 @@
 {
     if (m_toStringTemplate.isEmpty())
         m_toStringTemplate.set(m_isolate, v8::FunctionTemplate::New(constructorOfToString));
-    return v8::Local<v8::FunctionTemplate>::New(m_toStringTemplate.get());
+    return m_toStringTemplate.newLocal(m_isolate);
 }
 
 void V8PerIsolateData::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
@@ -166,7 +166,7 @@
         v8::HandleScope handleScope(m_isolate);
         m_regexContext.set(m_isolate, v8::Context::New(m_isolate));
     }
-    return v8::Local<v8::Context>::New(m_regexContext.get());
+    return m_regexContext.newLocal(m_isolate);
 }
 
 bool V8PerIsolateData::hasInstance(WrapperTypeInfo* info, v8::Handle<v8::Value> value, WrapperWorldType currentWorldType)
diff --git a/Source/bindings/v8/V8ScriptRunner.cpp b/Source/bindings/v8/V8ScriptRunner.cpp
index 62dc752..515ee0d 100644
--- a/Source/bindings/v8/V8ScriptRunner.cpp
+++ b/Source/bindings/v8/V8ScriptRunner.cpp
@@ -36,14 +36,40 @@
 
 namespace WebCore {
 
-v8::Local<v8::Script> V8ScriptRunner::compileScript(v8::Handle<v8::String> code, const String& fileName, const TextPosition& scriptStartPosition, v8::Isolate* isolate)
+PassOwnPtr<v8::ScriptData> V8ScriptRunner::precompileScript(v8::Handle<v8::String> code, CachedScript* cachedScript)
+{
+    TRACE_EVENT0("v8", "v8.compile");
+    // A pseudo-randomly chosen ID used to store and retrieve V8 ScriptData from
+    // the CachedScript. If the format changes, this ID should be changed too.
+    static const unsigned dataTypeID = 0xECC13BD7;
+
+    // Very small scripts are not worth the effort to preparse.
+    static const int minPreparseLength = 1024;
+
+    if (!cachedScript || code->Length() < minPreparseLength)
+        return nullptr;
+
+    CachedMetadata* cachedMetadata = cachedScript->cachedMetadata(dataTypeID);
+    if (cachedMetadata)
+        return adoptPtr(v8::ScriptData::New(cachedMetadata->data(), cachedMetadata->size()));
+
+    OwnPtr<v8::ScriptData> scriptData = adoptPtr(v8::ScriptData::PreCompile(code));
+    if (!scriptData)
+        return nullptr;
+
+    cachedScript->setCachedMetadata(dataTypeID, scriptData->Data(), scriptData->Length());
+
+    return scriptData.release();
+}
+
+v8::Local<v8::Script> V8ScriptRunner::compileScript(v8::Handle<v8::String> code, const String& fileName, const TextPosition& scriptStartPosition, v8::ScriptData* scriptData, v8::Isolate* isolate)
 {
     TRACE_EVENT0("v8", "v8.compile");
     v8::Handle<v8::String> name = v8String(fileName, isolate);
     v8::Handle<v8::Integer> line = v8Integer(scriptStartPosition.m_line.zeroBasedInt(), isolate);
     v8::Handle<v8::Integer> column = v8Integer(scriptStartPosition.m_column.zeroBasedInt(), isolate);
     v8::ScriptOrigin origin(name, line, column);
-    return v8::Script::Compile(code, &origin);
+    return v8::Script::Compile(code, &origin, scriptData);
 }
 
 v8::Local<v8::Value> V8ScriptRunner::runCompiledScript(v8::Handle<v8::Script> script, ScriptExecutionContext* context)
@@ -76,10 +102,10 @@
     return result;
 }
 
-v8::Local<v8::Value> V8ScriptRunner::compileAndRunInternalScript(v8::Handle<v8::String> source, v8::Isolate* isolate, const String& fileName, const TextPosition& scriptStartPosition)
+v8::Local<v8::Value> V8ScriptRunner::compileAndRunInternalScript(v8::Handle<v8::String> source, v8::Isolate* isolate, const String& fileName, const TextPosition& scriptStartPosition, v8::ScriptData* scriptData)
 {
     TRACE_EVENT0("v8", "v8.run");
-    v8::Handle<v8::Script> script = V8ScriptRunner::compileScript(source, fileName, scriptStartPosition, isolate);
+    v8::Handle<v8::Script> script = V8ScriptRunner::compileScript(source, fileName, scriptStartPosition, scriptData, isolate);
     if (script.IsEmpty())
         return v8::Local<v8::Value>();
 
diff --git a/Source/bindings/v8/V8ScriptRunner.h b/Source/bindings/v8/V8ScriptRunner.h
index 9f98e9a..2cb4090 100644
--- a/Source/bindings/v8/V8ScriptRunner.h
+++ b/Source/bindings/v8/V8ScriptRunner.h
@@ -40,9 +40,10 @@
 public:
     // For the following methods, the caller sites have to hold
     // a HandleScope and a ContextScope.
-    static v8::Local<v8::Script> compileScript(v8::Handle<v8::String>, const String&, const TextPosition&, v8::Isolate*);
+    static PassOwnPtr<v8::ScriptData> precompileScript(v8::Handle<v8::String>, CachedScript*);
+    static v8::Local<v8::Script> compileScript(v8::Handle<v8::String>, const String&, const TextPosition&, v8::ScriptData*, v8::Isolate*);
     static v8::Local<v8::Value> runCompiledScript(v8::Handle<v8::Script>, ScriptExecutionContext*);
-    static v8::Local<v8::Value> compileAndRunInternalScript(v8::Handle<v8::String>, v8::Isolate*, const String& = String(), const TextPosition& = TextPosition());
+    static v8::Local<v8::Value> compileAndRunInternalScript(v8::Handle<v8::String>, v8::Isolate*, const String& = String(), const TextPosition& = TextPosition(), v8::ScriptData* = 0);
     static v8::Local<v8::Value> callInternalFunction(v8::Handle<v8::Function>, v8::Handle<v8::Object>, int argc, v8::Handle<v8::Value> args[], v8::Isolate*);
     static v8::Local<v8::Value> callFunction(v8::Handle<v8::Function>, ScriptExecutionContext*, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Value> args[]);
     static v8::Local<v8::Value> callAsFunction(v8::Handle<v8::Object>, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Value> args[]);
diff --git a/Source/bindings/v8/V8ValueCache.cpp b/Source/bindings/v8/V8ValueCache.cpp
index 618e55e..07d4cfc 100644
--- a/Source/bindings/v8/V8ValueCache.cpp
+++ b/Source/bindings/v8/V8ValueCache.cpp
@@ -98,7 +98,7 @@
 
     stringImpl->ref();
     wrapper.MarkIndependent(isolate);
-    wrapper.MakeWeak(isolate, stringImpl, &makeWeakCallback);
+    wrapper.MakeWeak(stringImpl, &makeWeakCallback);
     m_lastV8String = UnsafePersistent<v8::String>(wrapper);
     m_stringCache.set(stringImpl, m_lastV8String);
 
diff --git a/Source/bindings/v8/V8DOMWindowShell.cpp b/Source/bindings/v8/V8WindowShell.cpp
similarity index 89%
rename from Source/bindings/v8/V8DOMWindowShell.cpp
rename to Source/bindings/v8/V8WindowShell.cpp
index 6cc480b..22a9a1c 100644
--- a/Source/bindings/v8/V8DOMWindowShell.cpp
+++ b/Source/bindings/v8/V8WindowShell.cpp
@@ -29,18 +29,13 @@
  */
 
 #include "config.h"
-#include "bindings/v8/V8DOMWindowShell.h"
+#include "bindings/v8/V8WindowShell.h"
 
-#include <v8-debug.h>
-#include <v8-i18n/include/extension.h>
-#include <v8.h>
-#include <algorithm>
-#include <utility>
 #include "RuntimeEnabledFeatures.h"
-#include "V8DOMWindow.h"
 #include "V8Document.h"
 #include "V8HTMLCollection.h"
 #include "V8HTMLDocument.h"
+#include "V8Window.h"
 #include "bindings/v8/DOMWrapperWorld.h"
 #include "bindings/v8/DateExtension.h"
 #include "bindings/v8/ScriptController.h"
@@ -65,6 +60,11 @@
 #include "wtf/OwnArrayPtr.h"
 #include "wtf/StringExtras.h"
 #include "wtf/text/CString.h"
+#include <algorithm>
+#include <utility>
+#include <v8-debug.h>
+#include <v8-i18n/include/extension.h>
+#include <v8.h>
 
 namespace WebCore {
 
@@ -79,19 +79,19 @@
     V8PerContextDebugData::setContextDebugData(targetContext, "injected", debugId);
 }
 
-PassOwnPtr<V8DOMWindowShell> V8DOMWindowShell::create(Frame* frame, PassRefPtr<DOMWrapperWorld> world, v8::Isolate* isolate)
+PassOwnPtr<V8WindowShell> V8WindowShell::create(Frame* frame, PassRefPtr<DOMWrapperWorld> world, v8::Isolate* isolate)
 {
-    return adoptPtr(new V8DOMWindowShell(frame, world, isolate));
+    return adoptPtr(new V8WindowShell(frame, world, isolate));
 }
 
-V8DOMWindowShell::V8DOMWindowShell(Frame* frame, PassRefPtr<DOMWrapperWorld> world, v8::Isolate* isolate)
+V8WindowShell::V8WindowShell(Frame* frame, PassRefPtr<DOMWrapperWorld> world, v8::Isolate* isolate)
     : m_frame(frame)
     , m_world(world)
     , m_isolate(isolate)
 {
 }
 
-void V8DOMWindowShell::disposeContext()
+void V8WindowShell::disposeContext()
 {
     m_perContextData.clear();
 
@@ -110,7 +110,7 @@
     V8GCForContextDispose::instance().notifyContextDisposed(isMainFrame);
 }
 
-void V8DOMWindowShell::clearForClose(bool destroyGlobal)
+void V8WindowShell::clearForClose(bool destroyGlobal)
 {
     if (destroyGlobal)
         m_global.clear();
@@ -122,7 +122,7 @@
     disposeContext();
 }
 
-void V8DOMWindowShell::clearForNavigation()
+void V8WindowShell::clearForNavigation()
 {
     if (m_context.isEmpty())
         return;
@@ -138,7 +138,7 @@
     // will be protected by the security checks on the DOMWindow wrapper.
     clearDocumentProperty();
 
-    v8::Handle<v8::Object> windowWrapper = m_global.newLocal(m_isolate)->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(m_isolate, worldTypeInMainThread(m_isolate)));
+    v8::Handle<v8::Object> windowWrapper = m_global.newLocal(m_isolate)->FindInstanceInPrototypeChain(V8Window::GetTemplate(m_isolate, worldTypeInMainThread(m_isolate)));
     ASSERT(!windowWrapper.IsEmpty());
     windowWrapper->TurnOnAccessCheck();
     context->DetachGlobal();
@@ -180,7 +180,7 @@
 // the frame. However, a new inner window is created for the new page.
 // If there are JS code holds a closure to the old inner window,
 // it won't be able to reach the outer window via its global object.
-bool V8DOMWindowShell::initializeIfNeeded()
+bool V8WindowShell::initializeIfNeeded()
 {
     if (!m_context.isEmpty())
         return true;
@@ -210,7 +210,7 @@
     }
 
     if (!isMainWorld) {
-        V8DOMWindowShell* mainWindow = m_frame->script()->existingWindowShell(mainThreadNormalWorld());
+        V8WindowShell* mainWindow = m_frame->script()->existingWindowShell(mainThreadNormalWorld());
         if (mainWindow && !mainWindow->context().IsEmpty())
             setInjectedScriptContextDebugId(context, m_frame->script()->contextDebugId(mainWindow->context()));
     }
@@ -253,7 +253,7 @@
     return true;
 }
 
-void V8DOMWindowShell::createContext()
+void V8WindowShell::createContext()
 {
     // The activeDocumentLoader pointer could be 0 during frame shutdown.
     // FIXME: Can we remove this check?
@@ -262,7 +262,7 @@
 
     // Create a new environment using an empty template for the shadow
     // object. Reuse the global object if one has been created earlier.
-    v8::Handle<v8::ObjectTemplate> globalTemplate = V8DOMWindow::GetShadowObjectTemplate(m_isolate, m_world->isMainWorld() ? MainWorld : IsolatedWorld);
+    v8::Handle<v8::ObjectTemplate> globalTemplate = V8Window::GetShadowObjectTemplate(m_isolate, m_world->isMainWorld() ? MainWorld : IsolatedWorld);
     if (globalTemplate.IsEmpty())
         return;
 
@@ -295,23 +295,23 @@
     m_context.set(m_isolate, v8::Context::New(m_isolate, &extensionConfiguration, globalTemplate, m_global.newLocal(m_isolate)));
 
     double contextCreationDurationInMilliseconds = (currentTime() - contextCreationStartInSeconds) * 1000;
-    const char* histogramName = "WebCore.V8DOMWindowShell.createContext.MainWorld";
+    const char* histogramName = "WebCore.V8WindowShell.createContext.MainWorld";
     if (!m_world->isMainWorld())
-        histogramName = "WebCore.V8DOMWindowShell.createContext.IsolatedWorld";
+        histogramName = "WebCore.V8WindowShell.createContext.IsolatedWorld";
     HistogramSupport::histogramCustomCounts(histogramName, contextCreationDurationInMilliseconds, 0, 10000, 50);
 }
 
-bool V8DOMWindowShell::installDOMWindow()
+bool V8WindowShell::installDOMWindow()
 {
     DOMWrapperWorld::setInitializingWindow(true);
     DOMWindow* window = m_frame->document()->domWindow();
-    v8::Local<v8::Object> windowWrapper = V8ObjectConstructor::newInstance(V8PerContextData::from(m_context.get())->constructorForType(&V8DOMWindow::info));
+    v8::Local<v8::Object> windowWrapper = V8ObjectConstructor::newInstance(V8PerContextData::from(m_context.get())->constructorForType(&V8Window::info));
     if (windowWrapper.IsEmpty())
         return false;
 
-    V8DOMWindow::installPerContextProperties(windowWrapper, window, m_isolate);
+    V8Window::installPerContextProperties(windowWrapper, window, m_isolate);
 
-    V8DOMWrapper::setNativeInfo(v8::Handle<v8::Object>::Cast(windowWrapper->GetPrototype()), &V8DOMWindow::info, window);
+    V8DOMWrapper::setNativeInfo(v8::Handle<v8::Object>::Cast(windowWrapper->GetPrototype()), &V8Window::info, window);
 
     // Install the windowWrapper as the prototype of the innerGlobalObject.
     // The full structure of the global object is as follows:
@@ -327,20 +327,20 @@
     //       JavaScript object.
     //
     v8::Handle<v8::Object> innerGlobalObject = toInnerGlobalObject(m_context.newLocal(m_isolate));
-    V8DOMWrapper::setNativeInfo(innerGlobalObject, &V8DOMWindow::info, window);
+    V8DOMWrapper::setNativeInfo(innerGlobalObject, &V8Window::info, window);
     innerGlobalObject->SetPrototype(windowWrapper);
-    V8DOMWrapper::associateObjectWithWrapper(PassRefPtr<DOMWindow>(window), &V8DOMWindow::info, windowWrapper, m_isolate, WrapperConfiguration::Dependent);
+    V8DOMWrapper::associateObjectWithWrapper(PassRefPtr<DOMWindow>(window), &V8Window::info, windowWrapper, m_isolate, WrapperConfiguration::Dependent);
     DOMWrapperWorld::setInitializingWindow(false);
     return true;
 }
 
-void V8DOMWindowShell::updateDocumentWrapper(v8::Handle<v8::Object> wrapper)
+void V8WindowShell::updateDocumentWrapper(v8::Handle<v8::Object> wrapper)
 {
     ASSERT(m_world->isMainWorld());
     m_document.set(m_isolate, wrapper);
 }
 
-void V8DOMWindowShell::updateDocumentProperty()
+void V8WindowShell::updateDocumentProperty()
 {
     if (!m_world->isMainWorld())
         return;
@@ -370,7 +370,7 @@
     toInnerGlobalObject(context)->SetHiddenValue(V8HiddenPropertyName::document(), documentWrapper);
 }
 
-void V8DOMWindowShell::clearDocumentProperty()
+void V8WindowShell::clearDocumentProperty()
 {
     ASSERT(!m_context.isEmpty());
     if (!m_world->isMainWorld())
@@ -379,7 +379,7 @@
     m_context.newLocal(m_isolate)->Global()->ForceDelete(v8::String::NewSymbol("document"));
 }
 
-void V8DOMWindowShell::setSecurityToken()
+void V8WindowShell::setSecurityToken()
 {
     ASSERT(m_world->isMainWorld());
 
@@ -417,7 +417,7 @@
     context->SetSecurityToken(v8::String::NewSymbol(utf8Token.data(), utf8Token.length()));
 }
 
-void V8DOMWindowShell::updateDocument()
+void V8WindowShell::updateDocument()
 {
     ASSERT(m_world->isMainWorld());
     if (m_global.isEmpty())
@@ -465,7 +465,7 @@
     }
 }
 
-void V8DOMWindowShell::namedItemAdded(HTMLDocument* document, const AtomicString& name)
+void V8WindowShell::namedItemAdded(HTMLDocument* document, const AtomicString& name)
 {
     ASSERT(m_world->isMainWorld());
 
@@ -473,7 +473,7 @@
         return;
 
     v8::HandleScope handleScope(m_isolate);
-    v8::Context::Scope contextScope(m_context.get());
+    v8::Context::Scope contextScope(m_context.newLocal(m_isolate));
 
     ASSERT(!m_document.isEmpty());
     v8::Handle<v8::Object> documentHandle = m_document.newLocal(m_isolate);
@@ -481,7 +481,7 @@
     documentHandle->SetAccessor(v8String(name, m_isolate), getter);
 }
 
-void V8DOMWindowShell::namedItemRemoved(HTMLDocument* document, const AtomicString& name)
+void V8WindowShell::namedItemRemoved(HTMLDocument* document, const AtomicString& name)
 {
     ASSERT(m_world->isMainWorld());
 
@@ -492,7 +492,7 @@
         return;
 
     v8::HandleScope handleScope(m_isolate);
-    v8::Context::Scope contextScope(m_context.get());
+    v8::Context::Scope contextScope(m_context.newLocal(m_isolate));
 
     ASSERT(!m_document.isEmpty());
     v8::Handle<v8::Object> documentHandle = m_document.newLocal(m_isolate);
@@ -500,7 +500,7 @@
     documentHandle->Delete(v8String(name, m_isolate));
 }
 
-void V8DOMWindowShell::updateSecurityOrigin()
+void V8WindowShell::updateSecurityOrigin()
 {
     ASSERT(m_world->isMainWorld());
     if (m_context.isEmpty())
diff --git a/Source/bindings/v8/V8DOMWindowShell.h b/Source/bindings/v8/V8WindowShell.h
similarity index 88%
rename from Source/bindings/v8/V8DOMWindowShell.h
rename to Source/bindings/v8/V8WindowShell.h
index 9e52918..44de752 100644
--- a/Source/bindings/v8/V8DOMWindowShell.h
+++ b/Source/bindings/v8/V8WindowShell.h
@@ -1,10 +1,10 @@
 /*
  * Copyright (C) 2009 Google Inc. All rights reserved.
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
  * met:
- * 
+ *
  *     * Redistributions of source code must retain the above copyright
  * notice, this list of conditions and the following disclaimer.
  *     * Redistributions in binary form must reproduce the above
@@ -14,7 +14,7 @@
  *     * Neither the name of Google Inc. nor the names of its
  * contributors may be used to endorse or promote products derived from
  * this software without specific prior written permission.
- * 
+ *
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -28,21 +28,21 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef V8DOMWindowShell_h
-#define V8DOMWindowShell_h
+#ifndef V8WindowShell_h
+#define V8WindowShell_h
 
 #include "bindings/v8/DOMWrapperWorld.h"
 #include "bindings/v8/ScopedPersistent.h"
 #include "bindings/v8/V8PerContextData.h"
 #include "bindings/v8/WrapperTypeInfo.h"
 #include "weborigin/SecurityOrigin.h"
-#include <v8.h>
 #include "wtf/Forward.h"
 #include "wtf/HashMap.h"
 #include "wtf/PassRefPtr.h"
 #include "wtf/RefCounted.h"
 #include "wtf/RefPtr.h"
 #include "wtf/text/AtomicString.h"
+#include <v8.h>
 
 namespace WebCore {
 
@@ -52,11 +52,11 @@
 
 // V8WindowShell represents all the per-global object state for a Frame that
 // persist between navigations.
-class V8DOMWindowShell {
+class V8WindowShell {
 public:
-    static PassOwnPtr<V8DOMWindowShell> create(Frame*, PassRefPtr<DOMWrapperWorld>, v8::Isolate*);
+    static PassOwnPtr<V8WindowShell> create(Frame*, PassRefPtr<DOMWrapperWorld>, v8::Isolate*);
 
-    v8::Local<v8::Context> context() const { return v8::Local<v8::Context>::New(m_context.get()); }
+    v8::Local<v8::Context> context() const { return m_context.newLocal(m_isolate); }
 
     // Update document object of the frame.
     void updateDocument();
@@ -80,7 +80,7 @@
     DOMWrapperWorld* world() { return m_world.get(); }
 
 private:
-    V8DOMWindowShell(Frame*, PassRefPtr<DOMWrapperWorld>, v8::Isolate*);
+    V8WindowShell(Frame*, PassRefPtr<DOMWrapperWorld>, v8::Isolate*);
 
     void disposeContext();
 
@@ -96,7 +96,7 @@
     void createContext();
     bool installDOMWindow();
 
-    static V8DOMWindowShell* enteredIsolatedWorldContext();
+    static V8WindowShell* enteredIsolatedWorldContext();
 
     Frame* m_frame;
     RefPtr<DOMWrapperWorld> m_world;
@@ -111,4 +111,4 @@
 
 } // namespace WebCore
 
-#endif // V8DOMWindowShell_h
+#endif // V8WindowShell_h
diff --git a/Source/bindings/v8/WorkerScriptController.cpp b/Source/bindings/v8/WorkerScriptController.cpp
index 0933ec9..5feb28c 100644
--- a/Source/bindings/v8/WorkerScriptController.cpp
+++ b/Source/bindings/v8/WorkerScriptController.cpp
@@ -99,7 +99,7 @@
         return false;
 
     // Starting from now, use local context only.
-    v8::Local<v8::Context> context = v8::Local<v8::Context>::New(m_context.get());
+    v8::Local<v8::Context> context = m_context.newLocal(m_isolate);
 
     v8::Context::Scope scope(context);
 
@@ -141,19 +141,19 @@
     if (!initializeContextIfNeeded())
         return ScriptValue();
 
+    v8::Handle<v8::Context> context = m_context.newLocal(m_isolate);
     if (!m_disableEvalPending.isEmpty()) {
-        m_context.get()->AllowCodeGenerationFromStrings(false);
-        m_context.get()->SetErrorMessageForCodeGenerationFromStrings(v8String(m_disableEvalPending, m_isolate));
+        context->AllowCodeGenerationFromStrings(false);
+        context->SetErrorMessageForCodeGenerationFromStrings(v8String(m_disableEvalPending, m_isolate));
         m_disableEvalPending = String();
     }
 
-    v8::Handle<v8::Context> context = m_context.newLocal(m_isolate);
     v8::Context::Scope scope(context);
 
     v8::TryCatch block;
 
     v8::Handle<v8::String> scriptString = v8String(script, m_isolate);
-    v8::Handle<v8::Script> compiledScript = V8ScriptRunner::compileScript(scriptString, fileName, scriptStartPosition, m_isolate);
+    v8::Handle<v8::Script> compiledScript = V8ScriptRunner::compileScript(scriptString, fileName, scriptStartPosition, 0, m_isolate);
     v8::Local<v8::Value> result = V8ScriptRunner::runCompiledScript(compiledScript, m_workerContext);
 
     if (!block.CanContinue()) {
diff --git a/Source/bindings/v8/WorkerScriptController.h b/Source/bindings/v8/WorkerScriptController.h
index eee144d..46aef4f 100644
--- a/Source/bindings/v8/WorkerScriptController.h
+++ b/Source/bindings/v8/WorkerScriptController.h
@@ -91,7 +91,7 @@
         ScriptValue evaluate(const String& script, const String& fileName, const TextPosition& scriptStartPosition, WorkerContextExecutionState*);
 
         // Returns a local handle of the context.
-        v8::Local<v8::Context> context() { return v8::Local<v8::Context>::New(m_context.get()); }
+        v8::Local<v8::Context> context() { return m_context.newLocal(v8::Isolate::GetCurrent()); }
 
     private:
         bool initializeContextIfNeeded();
diff --git a/Source/bindings/v8/WorkerScriptDebugServer.cpp b/Source/bindings/v8/WorkerScriptDebugServer.cpp
index b6a7200..ab02e01 100644
--- a/Source/bindings/v8/WorkerScriptDebugServer.cpp
+++ b/Source/bindings/v8/WorkerScriptDebugServer.cpp
@@ -53,7 +53,7 @@
 
 void WorkerScriptDebugServer::addListener(ScriptDebugListener* listener)
 {
-    v8::HandleScope scope;
+    v8::HandleScope scope(m_isolate);
     v8::Local<v8::Context> debuggerContext = v8::Debug::GetDebugContext();
     v8::Context::Scope contextScope(debuggerContext);
 
@@ -61,17 +61,18 @@
     m_listener = listener;
 
     ensureDebuggerScriptCompiled();
-    ASSERT(!m_debuggerScript.get()->IsUndefined());
+    v8::Local<v8::Object> debuggerScript = m_debuggerScript.newLocal(m_isolate);
+    ASSERT(!debuggerScript->IsUndefined());
     v8::Debug::SetDebugEventListener2(&WorkerScriptDebugServer::v8DebugEventCallback, v8::External::New(this));
     
-    v8::Handle<v8::Function> getScriptsFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::NewSymbol("getWorkerScripts")));
-    v8::Handle<v8::Value> value = V8ScriptRunner::callInternalFunction(getScriptsFunction, m_debuggerScript.get(), 0, 0, debuggerContext->GetIsolate());
+    v8::Handle<v8::Function> getScriptsFunction = v8::Local<v8::Function>::Cast(debuggerScript->Get(v8::String::NewSymbol("getWorkerScripts")));
+    v8::Handle<v8::Value> value = V8ScriptRunner::callInternalFunction(getScriptsFunction, debuggerScript, 0, 0, m_isolate);
     if (value.IsEmpty())
         return;
     ASSERT(!value->IsUndefined() && value->IsArray());
     v8::Handle<v8::Array> scriptsArray = v8::Handle<v8::Array>::Cast(value);
     for (unsigned i = 0; i < scriptsArray->Length(); ++i)
-        dispatchDidParseSource(listener, v8::Handle<v8::Object>::Cast(scriptsArray->Get(v8Integer(i, debuggerContext->GetIsolate()))));
+        dispatchDidParseSource(listener, v8::Handle<v8::Object>::Cast(scriptsArray->Get(v8Integer(i, m_isolate))));
 }
 
 void WorkerScriptDebugServer::removeListener(ScriptDebugListener* listener)
diff --git a/Source/bindings/v8/custom/V8CSSRuleCustom.cpp b/Source/bindings/v8/custom/V8CSSRuleCustom.cpp
index e8e505f..8bbd685 100644
--- a/Source/bindings/v8/custom/V8CSSRuleCustom.cpp
+++ b/Source/bindings/v8/custom/V8CSSRuleCustom.cpp
@@ -32,21 +32,18 @@
 #include "V8CSSRule.h"
 
 #include "V8CSSCharsetRule.h"
-#include "V8CSSFilterRule.h"
 #include "V8CSSFontFaceRule.h"
 #include "V8CSSHostRule.h"
 #include "V8CSSImportRule.h"
-#include "V8CSSKeyframeRule.h"
-#include "V8CSSKeyframesRule.h"
 #include "V8CSSMediaRule.h"
 #include "V8CSSPageRule.h"
-#include "V8CSSRegionRule.h"
 #include "V8CSSStyleRule.h"
 #include "V8CSSSupportsRule.h"
-
-#if ENABLE(CSS_DEVICE_ADAPTATION)
 #include "V8CSSViewportRule.h"
-#endif
+#include "V8WebKitCSSFilterRule.h"
+#include "V8WebKitCSSKeyframeRule.h"
+#include "V8WebKitCSSKeyframesRule.h"
+#include "V8WebKitCSSRegionRule.h"
 
 namespace WebCore {
 
@@ -77,10 +74,8 @@
         return wrap(static_cast<CSSKeyframesRule*>(impl), creationContext, isolate);
     case CSSRule::SUPPORTS_RULE:
         return wrap(static_cast<CSSSupportsRule*>(impl), creationContext, isolate);
-#if ENABLE(CSS_DEVICE_ADAPTATION)
-    case CSSRule::WEBKIT_VIEWPORT_RULE:
-        return wrap(static_cast<WebKitCSSViewportRule*>(impl), creationContext, isolate);
-#endif
+    case CSSRule::VIEWPORT_RULE:
+        return wrap(static_cast<CSSViewportRule*>(impl), creationContext, isolate);
     case CSSRule::WEBKIT_REGION_RULE:
         return wrap(static_cast<CSSRegionRule*>(impl), creationContext, isolate);
     case CSSRule::HOST_RULE:
diff --git a/Source/bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp b/Source/bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp
index a1e33a0..b81df69 100644
--- a/Source/bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp
+++ b/Source/bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp
@@ -154,7 +154,7 @@
     return propInfo;
 }
 
-v8::Handle<v8::Array> V8CSSStyleDeclaration::namedPropertyEnumerator(const v8::AccessorInfo& info)
+void V8CSSStyleDeclaration::namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& info)
 {
     typedef Vector<String, numCSSProperties - 1> PreAllocatedPropertyVector;
     DEFINE_STATIC_LOCAL(PreAllocatedPropertyVector, propertyNames, ());
@@ -177,67 +177,58 @@
         properties->Set(v8Integer(i, info.GetIsolate()), v8String(key, info.GetIsolate()));
     }
 
-    return properties;
+    v8SetReturnValue(info, properties);
 }
 
-v8::Handle<v8::Integer> V8CSSStyleDeclaration::namedPropertyQuery(v8::Local<v8::String> v8Name, const v8::AccessorInfo& info)
+void V8CSSStyleDeclaration::namedPropertyQuery(v8::Local<v8::String> v8Name, const v8::PropertyCallbackInfo<v8::Integer>& info)
 {
     // NOTE: cssPropertyInfo lookups incur several mallocs.
     // Successful lookups have the same cost the first time, but are cached.
-    if (cssPropertyInfo(v8Name))
-        return v8Integer(0, info.GetIsolate());
-
-    return v8::Handle<v8::Integer>();
+    if (cssPropertyInfo(v8Name)) {
+        v8SetReturnValueInt(info, 0);
+        return;
+    }
 }
 
-v8::Handle<v8::Value> V8CSSStyleDeclaration::namedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
+void V8CSSStyleDeclaration::namedPropertyGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
 {
     // First look for API defined attributes on the style declaration object.
-    if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty())
-        return v8Undefined();
     if (info.Holder()->HasRealNamedCallbackProperty(name))
-        return v8Undefined();
-    if (info.Holder()->HasRealNamedProperty(name))
-        return v8Undefined();
+        return;
 
     // Search the style declaration.
     CSSPropertyInfo* propInfo = cssPropertyInfo(name);
 
     // Do not handle non-property names.
     if (!propInfo)
-        return v8Undefined();
+        return;
 
     CSSStyleDeclaration* imp = V8CSSStyleDeclaration::toNative(info.Holder());
     RefPtr<CSSValue> cssValue = imp->getPropertyCSSValueInternal(static_cast<CSSPropertyID>(propInfo->propID));
     if (cssValue) {
         if (propInfo->hadPixelOrPosPrefix
             && cssValue->isPrimitiveValue()) {
-            return v8::Number::New(static_cast<CSSPrimitiveValue*>(
+            v8SetReturnValue(info, static_cast<CSSPrimitiveValue*>(
                 cssValue.get())->getFloatValue(CSSPrimitiveValue::CSS_PX));
+            return;
         }
-        return v8StringOrNull(cssValue->cssText(), info.GetIsolate());
+        v8SetReturnValue(info, v8StringOrNull(cssValue->cssText(), info.GetIsolate()));
+        return;
     }
 
     String result = imp->getPropertyValueInternal(static_cast<CSSPropertyID>(propInfo->propID));
     if (result.isNull())
         result = ""; // convert null to empty string.
 
-    return v8String(result, info.GetIsolate());
+    v8SetReturnValue(info, v8String(result, info.GetIsolate()));
 }
 
-v8::Handle<v8::Value> V8CSSStyleDeclaration::namedPropertySetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
+void V8CSSStyleDeclaration::namedPropertySetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<v8::Value>& info)
 {
-    if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty())
-        return v8Undefined();
-    if (info.Holder()->HasRealNamedCallbackProperty(name))
-        return v8Undefined();
-    if (info.Holder()->HasRealNamedProperty(name))
-        return v8Undefined();
-
     CSSStyleDeclaration* imp = V8CSSStyleDeclaration::toNative(info.Holder());
     CSSPropertyInfo* propInfo = cssPropertyInfo(name);
     if (!propInfo)
-        return v8Undefined();
+        return;
 
     String propertyValue = toWebCoreStringWithNullCheck(value);
     if (propInfo->hadPixelOrPosPrefix)
@@ -246,10 +237,12 @@
     ExceptionCode ec = 0;
     imp->setPropertyInternal(static_cast<CSSPropertyID>(propInfo->propID), propertyValue, false, ec);
 
-    if (ec)
+    if (ec) {
         setDOMException(ec, info.GetIsolate());
+        return;
+    }
 
-    return value;
+    v8SetReturnValue(info, value);
 }
 
 } // namespace WebCore
diff --git a/Source/bindings/v8/custom/V8CSSValueCustom.cpp b/Source/bindings/v8/custom/V8CSSValueCustom.cpp
index 46c3991..0c862c4 100644
--- a/Source/bindings/v8/custom/V8CSSValueCustom.cpp
+++ b/Source/bindings/v8/custom/V8CSSValueCustom.cpp
@@ -31,14 +31,13 @@
 #include "config.h"
 #include "V8CSSValue.h"
 
-
-#include "V8CSSFilterValue.h"
-#include "V8CSSMixFunctionValue.h"
 #include "V8CSSPrimitiveValue.h"
-#include "V8CSSTransformValue.h"
 #include "V8CSSValueList.h"
 #include "V8SVGColor.h"
 #include "V8SVGPaint.h"
+#include "V8WebKitCSSFilterValue.h"
+#include "V8WebKitCSSMixFunctionValue.h"
+#include "V8WebKitCSSTransformValue.h"
 #include "core/css/CSSMixFunctionValue.h"
 
 namespace WebCore {
diff --git a/Source/bindings/v8/custom/V8ClipboardCustom.cpp b/Source/bindings/v8/custom/V8ClipboardCustom.cpp
index e8dd649..d3f1a4c 100644
--- a/Source/bindings/v8/custom/V8ClipboardCustom.cpp
+++ b/Source/bindings/v8/custom/V8ClipboardCustom.cpp
@@ -105,7 +105,7 @@
     }
 
     if (toElement(node)->hasTagName(HTMLNames::imgTag) && !node->inDocument())
-        clipboard->setDragImage(static_cast<HTMLImageElement*>(node)->cachedImage(), IntPoint(x, y));
+        clipboard->setDragImage(toHTMLImageElement(node)->cachedImage(), IntPoint(x, y));
     else
         clipboard->setDragImageElement(node, IntPoint(x, y));
 }
diff --git a/Source/bindings/v8/custom/V8CryptoCustom.cpp b/Source/bindings/v8/custom/V8CryptoCustom.cpp
index f2d28e8..1d44dee 100644
--- a/Source/bindings/v8/custom/V8CryptoCustom.cpp
+++ b/Source/bindings/v8/custom/V8CryptoCustom.cpp
@@ -29,12 +29,15 @@
 #include "bindings/v8/V8Binding.h"
 #include "bindings/v8/V8Utilities.h"
 #include "core/dom/ExceptionCode.h"
-#include "core/page/Crypto.h"
+#include "modules/crypto/Crypto.h"
 
 #include "wtf/ArrayBufferView.h"
 
 namespace WebCore {
 
+// This custom binding is shared by V8WorkerCrypto. As such:
+//   * Do not call V8Crypto::toNative()
+//   * Must be threadsafe
 void V8Crypto::getRandomValuesMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
 {
     if (args.Length() < 1) {
@@ -51,9 +54,8 @@
     ArrayBufferView* arrayBufferView = V8ArrayBufferView::toNative(v8::Handle<v8::Object>::Cast(buffer));
     ASSERT(arrayBufferView);
 
-    Crypto* crypto = V8Crypto::toNative(args.Holder());
     ExceptionCode ec = 0;
-    crypto->getRandomValues(arrayBufferView, ec);
+    Crypto::getRandomValues(arrayBufferView, ec);
 
     if (ec) {
         setDOMException(ec, args.GetIsolate());
diff --git a/Source/bindings/v8/custom/V8CustomElementConstructorCustom.cpp b/Source/bindings/v8/custom/V8CustomElementConstructorCustom.cpp
deleted file mode 100644
index 1b9e38c..0000000
--- a/Source/bindings/v8/custom/V8CustomElementConstructorCustom.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
-* Copyright (C) 2012 Google Inc. All rights reserved.
-* 
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are
-* met:
-* 
-*     * Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-*     * Redistributions in binary form must reproduce the above
-* copyright notice, this list of conditions and the following disclaimer
-* in the documentation and/or other materials provided with the
-* distribution.
-*     * Neither the name of Google Inc. nor the names of its
-* contributors may be used to endorse or promote products derived from
-* this software without specific prior written permission.
-* 
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#include "config.h"
-
-#include "V8CustomElementConstructor.h"
-
-#include "V8Element.h"
-#include "bindings/v8/CustomElementHelpers.h"
-#include "bindings/v8/V8Binding.h"
-#include "bindings/v8/V8ObjectConstructor.h"
-#include "core/dom/CustomElementConstructor.h"
-
-namespace WebCore {
-
-void V8CustomElementConstructor::legacyCallCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
-{
-    if (!args.IsConstructCall()) {
-        throwTypeError("DOM object constructor cannot be called as a function.", args.GetIsolate());
-        return;
-    }
-    if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) {
-        v8SetReturnValue(args, args.Holder());
-        return;
-    }
-
-    CustomElementConstructor* impl = toNative(args.Holder());
-    ExceptionCode ec = 0;
-    RefPtr<Element> element = impl->createElement(ec);
-    if (ec) {
-        setDOMException(ec, args.GetIsolate());
-        return;
-    }
-
-    v8SetReturnValue(args, toV8(element.get(), args.Holder(), args.GetIsolate()));
-}
-
-} // namespace WebCore
diff --git a/Source/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp b/Source/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp
index 66d97e2..2d9fa2e 100644
--- a/Source/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp
+++ b/Source/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp
@@ -45,7 +45,8 @@
     if (!canInvokeCallback())
         return true;
 
-    v8::HandleScope handleScope;
+    v8::Isolate* isolate = v8::Isolate::GetCurrent();
+    v8::HandleScope handleScope(isolate);
 
     v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_world.get());
     if (v8Context.IsEmpty())
@@ -54,7 +55,7 @@
     v8::Context::Scope scope(v8Context);
 
     v8::Handle<v8::Value> transactionHandle = toV8(transaction, v8::Handle<v8::Object>(), v8Context->GetIsolate());
-    v8::Handle<v8::Value> errorHandle = toV8(error, v8::Handle<v8::Object>(), v8Context->GetIsolate());
+    v8::Handle<v8::Value> errorHandle = toV8(error, v8::Handle<v8::Object>(), isolate);
     if (transactionHandle.IsEmpty() || errorHandle.IsEmpty()) {
         if (!isScriptControllerTerminating())
             CRASH();
@@ -71,7 +72,7 @@
     // statement, if any, or onto the next overall step otherwise. Otherwise,
     // the error callback did not return false, or there was no error callback.
     // Jump to the last step in the overall steps.
-    return invokeCallback(m_callback.get(), 2, argv, callbackReturnValue, scriptExecutionContext()) || callbackReturnValue;
+    return invokeCallback(m_callback.newLocal(isolate), 2, argv, callbackReturnValue, scriptExecutionContext()) || callbackReturnValue;
 }
 
 } // namespace WebCore
diff --git a/Source/bindings/v8/custom/V8DataViewCustom.cpp b/Source/bindings/v8/custom/V8DataViewCustom.cpp
index 8935270..b8120e9 100644
--- a/Source/bindings/v8/custom/V8DataViewCustom.cpp
+++ b/Source/bindings/v8/custom/V8DataViewCustom.cpp
@@ -57,76 +57,4 @@
     return V8DataView::createWrapper(impl, creationContext, isolate);
 }
 
-void V8DataView::getInt8MethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
-{
-    if (args.Length() < 1) {
-        throwNotEnoughArgumentsError(args.GetIsolate());
-        return;
-    }
-
-    DataView* imp = V8DataView::toNative(args.Holder());
-    ExceptionCode ec = 0;
-    V8TRYCATCH_VOID(unsigned, byteOffset, toUInt32(args[0]));
-    int8_t result = imp->getInt8(byteOffset, ec);
-    if (UNLIKELY(ec)) {
-        setDOMException(ec, args.GetIsolate());
-        return;
-    }
-    v8SetReturnValue(args, result);
-}
-
-void V8DataView::getUint8MethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
-{
-    if (args.Length() < 1) {
-        throwNotEnoughArgumentsError(args.GetIsolate());
-        return;
-    }
-
-    DataView* imp = V8DataView::toNative(args.Holder());
-    ExceptionCode ec = 0;
-    V8TRYCATCH_VOID(unsigned, byteOffset, toUInt32(args[0]));
-    uint8_t result = imp->getUint8(byteOffset, ec);
-    if (UNLIKELY(ec)) {
-        setDOMException(ec, args.GetIsolate());
-        return;
-    }
-    v8SetReturnValue(args, result);
-}
-
-void V8DataView::setInt8MethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
-{
-    if (args.Length() < 2) {
-        throwNotEnoughArgumentsError(args.GetIsolate());
-        return;
-    }
-
-    DataView* imp = V8DataView::toNative(args.Holder());
-    ExceptionCode ec = 0;
-    V8TRYCATCH_VOID(unsigned, byteOffset, toUInt32(args[0]));
-    V8TRYCATCH_VOID(int, value, toInt32(args[1]));
-    imp->setInt8(byteOffset, static_cast<int8_t>(value), ec);
-    if (UNLIKELY(ec)) {
-        setDOMException(ec, args.GetIsolate());
-        return;
-    }
-}
-
-void V8DataView::setUint8MethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
-{
-    if (args.Length() < 2) {
-        throwNotEnoughArgumentsError(args.GetIsolate());
-        return;
-    }
-
-    DataView* imp = V8DataView::toNative(args.Holder());
-    ExceptionCode ec = 0;
-    V8TRYCATCH_VOID(unsigned, byteOffset, toUInt32(args[0]));
-    V8TRYCATCH_VOID(int, value, toInt32(args[1]));
-    imp->setUint8(byteOffset, static_cast<uint8_t>(value), ec);
-    if (UNLIKELY(ec)) {
-        setDOMException(ec, args.GetIsolate());
-        return;
-    }
-}
-
 } // namespace WebCore
diff --git a/Source/bindings/v8/custom/V8DocumentCustom.cpp b/Source/bindings/v8/custom/V8DocumentCustom.cpp
index 8d22885..45a5932 100644
--- a/Source/bindings/v8/custom/V8DocumentCustom.cpp
+++ b/Source/bindings/v8/custom/V8DocumentCustom.cpp
@@ -52,8 +52,8 @@
 #include "V8XPathNSResolver.h"
 #include "V8XPathResult.h"
 #include "bindings/v8/V8Binding.h"
-#include "bindings/v8/V8DOMWindowShell.h"
 #include "bindings/v8/V8DOMWrapper.h"
+#include "bindings/v8/V8WindowShell.h"
 #include "bindings/v8/custom/V8CustomXPathNSResolver.h"
 
 #include "wtf/RefPtr.h"
diff --git a/Source/bindings/v8/custom/V8HTMLDocumentCustom.cpp b/Source/bindings/v8/custom/V8HTMLDocumentCustom.cpp
index d6e819e..afeade8 100644
--- a/Source/bindings/v8/custom/V8HTMLDocumentCustom.cpp
+++ b/Source/bindings/v8/custom/V8HTMLDocumentCustom.cpp
@@ -32,13 +32,13 @@
 #include "V8HTMLDocument.h"
 
 #include "HTMLNames.h"
-#include "V8DOMWindow.h"
 #include "V8HTMLAllCollection.h"
 #include "V8HTMLCollection.h"
 #include "V8Node.h"
+#include "V8Window.h"
 #include "bindings/v8/ScriptController.h"
 #include "bindings/v8/V8Binding.h"
-#include "bindings/v8/V8DOMWindowShell.h"
+#include "bindings/v8/V8WindowShell.h"
 #include "core/html/HTMLAllCollection.h"
 #include "core/html/HTMLCollection.h"
 #include "core/html/HTMLDocument.h"
diff --git a/Source/bindings/v8/custom/V8HTMLPlugInElementCustom.cpp b/Source/bindings/v8/custom/V8HTMLPlugInElementCustom.cpp
index 97633ca..a368803 100644
--- a/Source/bindings/v8/custom/V8HTMLPlugInElementCustom.cpp
+++ b/Source/bindings/v8/custom/V8HTMLPlugInElementCustom.cpp
@@ -44,61 +44,61 @@
 // to match JSC bindings naming convention.
 
 template <class C>
-static v8::Handle<v8::Value> npObjectNamedGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
+static void npObjectNamedGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
 {
     HTMLPlugInElement* imp = C::toNative(info.Holder());
     ScriptInstance scriptInstance = imp->getInstance();
     if (!scriptInstance)
-        return v8Undefined();
+        return;
 
     v8::Local<v8::Object> instance = scriptInstance->newLocal(v8::Isolate::GetCurrent());
     if (instance.IsEmpty())
-        return v8Undefined();
+        return;
 
-    return npObjectGetNamedProperty(instance, name, info);
+    npObjectGetNamedProperty(instance, name, info);
 }
 
 template <class C>
-static v8::Handle<v8::Value> npObjectNamedSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
+static void npObjectNamedSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<v8::Value>& info)
 {
     HTMLPlugInElement* imp = C::toNative(info.Holder());
     ScriptInstance scriptInstance = imp->getInstance();
     if (!scriptInstance)
-        return v8Undefined();
+        return;
 
     v8::Local<v8::Object> instance = scriptInstance->newLocal(v8::Isolate::GetCurrent());
     if (instance.IsEmpty())
-        return v8Undefined();
+        return;
 
-    return npObjectSetNamedProperty(instance, name, value, info);
+    npObjectSetNamedProperty(instance, name, value, info);
 }
 
-v8::Handle<v8::Value> V8HTMLAppletElement::namedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
+void V8HTMLAppletElement::namedPropertyGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
 {
-    return npObjectNamedGetter<V8HTMLAppletElement>(name, info);
+    npObjectNamedGetter<V8HTMLAppletElement>(name, info);
 }
 
-v8::Handle<v8::Value> V8HTMLEmbedElement::namedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
+void V8HTMLEmbedElement::namedPropertyGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
 {
-    return npObjectNamedGetter<V8HTMLEmbedElement>(name, info);
+    npObjectNamedGetter<V8HTMLEmbedElement>(name, info);
 }
 
-v8::Handle<v8::Value> V8HTMLObjectElement::namedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
+void V8HTMLObjectElement::namedPropertyGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
 {
-    return npObjectNamedGetter<V8HTMLObjectElement>(name, info);
+    npObjectNamedGetter<V8HTMLObjectElement>(name, info);
 }
 
-v8::Handle<v8::Value> V8HTMLAppletElement::namedPropertySetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
+void V8HTMLAppletElement::namedPropertySetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<v8::Value>& info)
 {
-    return npObjectNamedSetter<V8HTMLAppletElement>(name, value, info);
+    npObjectNamedSetter<V8HTMLAppletElement>(name, value, info);
 }
 
-v8::Handle<v8::Value> V8HTMLEmbedElement::namedPropertySetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
+void V8HTMLEmbedElement::namedPropertySetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<v8::Value>& info)
 {
-    return npObjectNamedSetter<V8HTMLEmbedElement>(name, value, info);
+    npObjectNamedSetter<V8HTMLEmbedElement>(name, value, info);
 }
 
-v8::Handle<v8::Value> V8HTMLObjectElement::namedPropertySetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
+void V8HTMLObjectElement::namedPropertySetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<v8::Value>& info)
 {
     return npObjectNamedSetter<V8HTMLObjectElement>(name, value, info);
 }
@@ -119,63 +119,63 @@
 }
 
 template <class C>
-v8::Handle<v8::Value> npObjectIndexedGetter(uint32_t index, const v8::AccessorInfo& info)
+void npObjectIndexedGetter(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info)
 {
     HTMLPlugInElement* imp = C::toNative(info.Holder());
     ScriptInstance scriptInstance = imp->getInstance();
     if (!scriptInstance)
-        return v8Undefined();
+        return;
 
     v8::Local<v8::Object> instance = scriptInstance->newLocal(v8::Isolate::GetCurrent());
     if (instance.IsEmpty())
-        return v8Undefined();
+        return;
 
-    return npObjectGetIndexedProperty(instance, index, info);
+    npObjectGetIndexedProperty(instance, index, info);
 }
 
 template <class C>
-v8::Handle<v8::Value> npObjectIndexedSetter(uint32_t index, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
+void npObjectIndexedSetter(uint32_t index, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<v8::Value>& info)
 {
     HTMLPlugInElement* imp = C::toNative(info.Holder());
     ScriptInstance scriptInstance = imp->getInstance();
     if (!scriptInstance)
-        return v8Undefined();
+        return;
 
     v8::Local<v8::Object> instance = scriptInstance->newLocal(v8::Isolate::GetCurrent());
     if (instance.IsEmpty())
-        return v8Undefined();
+        return;
 
-    return npObjectSetIndexedProperty(instance, index, value, info);
+    npObjectSetIndexedProperty(instance, index, value, info);
 }
 
-v8::Handle<v8::Value> V8HTMLAppletElement::indexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info)
+void V8HTMLAppletElement::indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info)
 {
-    return npObjectIndexedGetter<V8HTMLAppletElement>(index, info);
+    npObjectIndexedGetter<V8HTMLAppletElement>(index, info);
 }
 
-v8::Handle<v8::Value> V8HTMLEmbedElement::indexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info)
+void V8HTMLEmbedElement::indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info)
 {
-    return npObjectIndexedGetter<V8HTMLEmbedElement>(index, info);
+    npObjectIndexedGetter<V8HTMLEmbedElement>(index, info);
 }
 
-v8::Handle<v8::Value> V8HTMLObjectElement::indexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info)
+void V8HTMLObjectElement::indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info)
 {
-    return npObjectIndexedGetter<V8HTMLObjectElement>(index, info);
+    npObjectIndexedGetter<V8HTMLObjectElement>(index, info);
 }
 
-v8::Handle<v8::Value> V8HTMLAppletElement::indexedPropertySetter(uint32_t index, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
+void V8HTMLAppletElement::indexedPropertySetter(uint32_t index, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<v8::Value>& info)
 {
-    return npObjectIndexedSetter<V8HTMLAppletElement>(index, value, info);
+    npObjectIndexedSetter<V8HTMLAppletElement>(index, value, info);
 }
 
-v8::Handle<v8::Value> V8HTMLEmbedElement::indexedPropertySetter(uint32_t index, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
+void V8HTMLEmbedElement::indexedPropertySetter(uint32_t index, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<v8::Value>& info)
 {
-    return npObjectIndexedSetter<V8HTMLEmbedElement>(index, value, info);
+    npObjectIndexedSetter<V8HTMLEmbedElement>(index, value, info);
 }
 
-v8::Handle<v8::Value> V8HTMLObjectElement::indexedPropertySetter(uint32_t index, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
+void V8HTMLObjectElement::indexedPropertySetter(uint32_t index, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<v8::Value>& info)
 {
-    return npObjectIndexedSetter<V8HTMLObjectElement>(index, value, info);
+    npObjectIndexedSetter<V8HTMLObjectElement>(index, value, info);
 }
 
 } // namespace WebCore
diff --git a/Source/bindings/v8/custom/V8HistoryCustom.cpp b/Source/bindings/v8/custom/V8HistoryCustom.cpp
index 2299108..14b51bf 100644
--- a/Source/bindings/v8/custom/V8HistoryCustom.cpp
+++ b/Source/bindings/v8/custom/V8HistoryCustom.cpp
@@ -31,7 +31,7 @@
 #include "config.h"
 #include "V8History.h"
 
-#include "V8DOMWindow.h"
+#include "V8Window.h"
 #include "bindings/v8/SerializedScriptValue.h"
 #include "bindings/v8/V8Binding.h"
 #include "bindings/v8/V8HiddenPropertyName.h"
diff --git a/Source/bindings/v8/custom/V8InjectedScriptHostCustom.cpp b/Source/bindings/v8/custom/V8InjectedScriptHostCustom.cpp
index b9e1381..a08dbb7 100644
--- a/Source/bindings/v8/custom/V8InjectedScriptHostCustom.cpp
+++ b/Source/bindings/v8/custom/V8InjectedScriptHostCustom.cpp
@@ -65,7 +65,8 @@
 {
     if (!value.isObject() || value.isNull())
         return 0;
-    return V8Node::toNative(v8::Handle<v8::Object>::Cast(value.v8ValueRaw()));
+    v8::HandleScope scope(v8::Isolate::GetCurrent());
+    return V8Node::toNative(v8::Handle<v8::Object>::Cast(value.v8Value()));
 }
 
 ScriptValue InjectedScriptHost::nodeAsScriptValue(ScriptState* state, Node* node)
@@ -370,7 +371,6 @@
     v8::Handle<v8::Value> fn = args[0];
     if (!fn->IsFunction())
         return false;
-    v8::HandleScope handleScope;
     v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(fn);
     *lineNumber = function->GetScriptLineNumber();
     *columnNumber = function->GetScriptColumnNumber();
@@ -380,7 +380,7 @@
     return true;
 }
 
-void V8InjectedScriptHost::setBreakpointMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+void V8InjectedScriptHost::debugFunctionMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
 {
     String scriptId;
     int lineNumber;
@@ -389,10 +389,10 @@
         return;
 
     InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holder());
-    host->setBreakpoint(scriptId, lineNumber, columnNumber);
+    host->debugFunction(scriptId, lineNumber, columnNumber);
 }
 
-void V8InjectedScriptHost::removeBreakpointMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+void V8InjectedScriptHost::undebugFunctionMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
 {
     String scriptId;
     int lineNumber;
@@ -401,9 +401,41 @@
         return;
 
     InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holder());
-    host->removeBreakpoint(scriptId, lineNumber, columnNumber);
+    host->undebugFunction(scriptId, lineNumber, columnNumber);
 }
 
+void V8InjectedScriptHost::monitorFunctionMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+{
+    String scriptId;
+    int lineNumber;
+    int columnNumber;
+    if (!getFunctionLocation(args, &scriptId, &lineNumber, &columnNumber))
+        return;
+
+    v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(args[0]);
+    v8::Handle<v8::Value> name;
+    if (args.Length() > 0 && args[0]->IsFunction()) {
+        v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(args[0]);
+        name = function->GetName();
+        if (!name->IsString() || !v8::Handle<v8::String>::Cast(name)->Length())
+            name = function->GetInferredName();
+    }
+
+    InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holder());
+    host->monitorFunction(scriptId, lineNumber, columnNumber, toWebCoreStringWithUndefinedOrNullCheck(name));
+}
+
+void V8InjectedScriptHost::unmonitorFunctionMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+{
+    String scriptId;
+    int lineNumber;
+    int columnNumber;
+    if (!getFunctionLocation(args, &scriptId, &lineNumber, &columnNumber))
+        return;
+
+    InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holder());
+    host->unmonitorFunction(scriptId, lineNumber, columnNumber);
+}
 
 } // namespace WebCore
 
diff --git a/Source/bindings/v8/custom/V8InjectedScriptManager.cpp b/Source/bindings/v8/custom/V8InjectedScriptManager.cpp
index 7acccd3..199b84c 100644
--- a/Source/bindings/v8/custom/V8InjectedScriptManager.cpp
+++ b/Source/bindings/v8/custom/V8InjectedScriptManager.cpp
@@ -31,8 +31,8 @@
 #include "config.h"
 #include "core/inspector/InjectedScriptManager.h"
 
-#include "V8DOMWindow.h"
 #include "V8InjectedScriptHost.h"
+#include "V8Window.h"
 #include "bindings/v8/BindingSecurity.h"
 #include "bindings/v8/ScriptDebugServer.h"
 #include "bindings/v8/ScriptObject.h"
@@ -62,7 +62,7 @@
     // InspectorBackend when the wrapper is garbage collected.
     host->ref();
     v8::Persistent<v8::Object> weakHandle(isolate, instance);
-    weakHandle.MakeWeak(isolate, host, &InjectedScriptManager::makeWeakCallback);
+    weakHandle.MakeWeak(host, &InjectedScriptManager::makeWeakCallback);
     return instance;
 }
 
@@ -104,12 +104,12 @@
     v8::Local<v8::Object> global = context->Global();
     if (global.IsEmpty())
         return false;
-    v8::Handle<v8::Object> holder = global->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(context->GetIsolate(), MainWorld));
+    v8::Handle<v8::Object> holder = global->FindInstanceInPrototypeChain(V8Window::GetTemplate(context->GetIsolate(), MainWorld));
     if (holder.IsEmpty())
-        holder = global->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(context->GetIsolate(), IsolatedWorld));
+        holder = global->FindInstanceInPrototypeChain(V8Window::GetTemplate(context->GetIsolate(), IsolatedWorld));
     if (holder.IsEmpty())
         return false;
-    Frame* frame = V8DOMWindow::toNative(holder)->frame();
+    Frame* frame = V8Window::toNative(holder)->frame();
 
     v8::Context::Scope contextScope(context);
     return BindingSecurity::shouldAllowAccessToFrame(frame, DoNotReportSecurityError);
diff --git a/Source/bindings/v8/custom/V8InspectorFrontendHostCustom.cpp b/Source/bindings/v8/custom/V8InspectorFrontendHostCustom.cpp
index 485976b..9289ff1 100644
--- a/Source/bindings/v8/custom/V8InspectorFrontendHostCustom.cpp
+++ b/Source/bindings/v8/custom/V8InspectorFrontendHostCustom.cpp
@@ -44,17 +44,17 @@
 
 void V8InspectorFrontendHost::platformMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
 {
-#if defined(OS_MACOSX)
+#if OS(DARWIN)
     v8SetReturnValue(args, v8::String::NewSymbol("mac"));
-#elif defined(OS_LINUX)
+#elif OS(LINUX)
     v8SetReturnValue(args, v8::String::NewSymbol("linux"));
-#elif defined(OS_FREEBSD)
+#elif OS(FREEBSD)
     v8SetReturnValue(args, v8::String::NewSymbol("freebsd"));
-#elif defined(OS_OPENBSD)
+#elif OS(OPENBSD)
     v8SetReturnValue(args, v8::String::NewSymbol("openbsd"));
-#elif defined(OS_SOLARIS)
+#elif OS(SOLARIS)
     v8SetReturnValue(args, v8::String::NewSymbol("solaris"));
-#elif defined(OS_WIN)
+#elif OS(WINDOWS)
     v8SetReturnValue(args, v8::String::NewSymbol("windows"));
 #else
     v8SetReturnValue(args, v8::String::NewSymbol("unknown"));
diff --git a/Source/bindings/v8/custom/V8MessageEventCustom.cpp b/Source/bindings/v8/custom/V8MessageEventCustom.cpp
index 24fb92b..906ee9b 100644
--- a/Source/bindings/v8/custom/V8MessageEventCustom.cpp
+++ b/Source/bindings/v8/custom/V8MessageEventCustom.cpp
@@ -36,8 +36,8 @@
 
 #include "V8ArrayBuffer.h"
 #include "V8Blob.h"
-#include "V8DOMWindow.h"
 #include "V8MessagePort.h"
+#include "V8Window.h"
 #include "bindings/v8/V8Binding.h"
 
 namespace WebCore {
@@ -100,9 +100,9 @@
     DOMWindow* sourceArg = 0;
     if (args[6]->IsObject()) {
         v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(args[6]);
-        v8::Handle<v8::Object> window = wrapper->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(args.GetIsolate(), worldTypeInMainThread(args.GetIsolate())));
+        v8::Handle<v8::Object> window = wrapper->FindInstanceInPrototypeChain(V8Window::GetTemplate(args.GetIsolate(), worldTypeInMainThread(args.GetIsolate())));
         if (!window.IsEmpty())
-            sourceArg = V8DOMWindow::toNative(window);
+            sourceArg = V8Window::toNative(window);
     }
     OwnPtr<MessagePortArray> portArray;
 
diff --git a/Source/bindings/v8/custom/V8SVGDocumentCustom.cpp b/Source/bindings/v8/custom/V8SVGDocumentCustom.cpp
index 081fd3e..953e5e8 100644
--- a/Source/bindings/v8/custom/V8SVGDocumentCustom.cpp
+++ b/Source/bindings/v8/custom/V8SVGDocumentCustom.cpp
@@ -33,7 +33,7 @@
 #include "V8SVGDocument.h"
 
 #include "bindings/v8/ScriptController.h"
-#include "bindings/v8/V8DOMWindowShell.h"
+#include "bindings/v8/V8WindowShell.h"
 #include "core/page/Frame.h"
 
 namespace WebCore {
diff --git a/Source/bindings/v8/custom/V8SVGPathSegCustom.cpp b/Source/bindings/v8/custom/V8SVGPathSegCustom.cpp
index eae32f7..6fe9fdf 100644
--- a/Source/bindings/v8/custom/V8SVGPathSegCustom.cpp
+++ b/Source/bindings/v8/custom/V8SVGPathSegCustom.cpp
@@ -32,7 +32,6 @@
 
 #include "V8SVGPathSeg.h"
 
-#include "V8DOMWindow.h"
 #include "V8SVGPathSegArcAbs.h"
 #include "V8SVGPathSegArcRel.h"
 #include "V8SVGPathSegClosePath.h"
@@ -52,6 +51,7 @@
 #include "V8SVGPathSegLinetoVerticalRel.h"
 #include "V8SVGPathSegMovetoAbs.h"
 #include "V8SVGPathSegMovetoRel.h"
+#include "V8Window.h"
 #include "bindings/v8/V8DOMWrapper.h"
 
 namespace WebCore {
diff --git a/Source/bindings/v8/custom/V8StorageCustom.cpp b/Source/bindings/v8/custom/V8StorageCustom.cpp
deleted file mode 100644
index 29a1e83..0000000
--- a/Source/bindings/v8/custom/V8StorageCustom.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
-* Copyright (C) 2009 Google Inc. All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are
-* met:
-*
-*     * Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-*     * Redistributions in binary form must reproduce the above
-* copyright notice, this list of conditions and the following disclaimer
-* in the documentation and/or other materials provided with the
-* distribution.
-*     * Neither the name of Google Inc. nor the names of its
-* contributors may be used to endorse or promote products derived from
-* this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#include "config.h"
-#include "V8Storage.h"
-
-#include "bindings/v8/V8Binding.h"
-#include "core/storage/Storage.h"
-
-namespace WebCore {
-
-template<class T>
-static v8::Handle<T> setDOMException(ExceptionCode ec, const v8::AccessorInfo& info)
-{
-    setDOMException(ec, info.GetIsolate());
-    return v8::Handle<T>();
-}
-
-v8::Handle<v8::Integer> V8Storage::namedPropertyQuery(v8::Local<v8::String> v8Name, const v8::AccessorInfo& info)
-{
-    Storage* storage = V8Storage::toNative(info.Holder());
-    String name = toWebCoreString(v8Name);
-
-    if (name == "length")
-        return v8::Handle<v8::Integer>();
-    ExceptionCode ec = 0;
-    bool found = storage->contains(name, ec);
-    if (ec)
-        return setDOMException<v8::Integer>(ec, info);
-    if (!found)
-        return v8::Handle<v8::Integer>();
-    return v8Integer(0, info.GetIsolate());
-}
-
-} // namespace WebCore
diff --git a/Source/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp b/Source/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp
index bf1689a..9bdc5e0 100644
--- a/Source/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp
+++ b/Source/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp
@@ -32,6 +32,7 @@
 
 #include "V8WebGLRenderingContext.h"
 
+#include "V8ANGLEInstancedArrays.h"
 #include "V8ArrayBufferView.h"
 #include "V8EXTFragDepth.h"
 #include "V8EXTTextureFilterAnisotropic.h"
@@ -178,6 +179,10 @@
     v8::Handle<v8::Value> extensionObject;
     const char* referenceName = 0;
     switch (extension->getName()) {
+    case WebGLExtension::ANGLEInstancedArraysName:
+        extensionObject = toV8(static_cast<ANGLEInstancedArrays*>(extension), contextObject, isolate);
+        referenceName = "angleInstancedArraysName";
+        break;
     case WebGLExtension::EXTFragDepthName:
         extensionObject = toV8(static_cast<EXTFragDepth*>(extension), contextObject, isolate);
         referenceName = "extFragDepthName";
@@ -351,8 +356,8 @@
         return;
     }
     V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, name, args[0]);
-    WebGLExtension* extension = imp->getExtension(name);
-    v8SetReturnValue(args, toV8Object(extension, args.Holder(), args.GetIsolate()));
+    RefPtr<WebGLExtension> extension(imp->getExtension(name));
+    v8SetReturnValue(args, toV8Object(extension.get(), args.Holder(), args.GetIsolate()));
 }
 
 void V8WebGLRenderingContext::getFramebufferAttachmentParameterMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
diff --git a/Source/bindings/v8/custom/V8DOMPointCustom.cpp b/Source/bindings/v8/custom/V8WebKitPointCustom.cpp
similarity index 95%
rename from Source/bindings/v8/custom/V8DOMPointCustom.cpp
rename to Source/bindings/v8/custom/V8WebKitPointCustom.cpp
index ce4aa53..98329cc 100644
--- a/Source/bindings/v8/custom/V8DOMPointCustom.cpp
+++ b/Source/bindings/v8/custom/V8WebKitPointCustom.cpp
@@ -29,7 +29,7 @@
  */
 
 #include "config.h"
-#include "V8DOMPoint.h"
+#include "V8WebKitPoint.h"
 
 #include "bindings/v8/V8Binding.h"
 #include "bindings/v8/V8DOMWrapper.h"
@@ -39,7 +39,7 @@
 
 namespace WebCore {
 
-void V8DOMPoint::constructorCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+void V8WebKitPoint::constructorCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
 {
     float x = 0;
     float y = 0;
diff --git a/Source/bindings/v8/custom/V8DOMWindowCustom.cpp b/Source/bindings/v8/custom/V8WindowCustom.cpp
similarity index 83%
rename from Source/bindings/v8/custom/V8DOMWindowCustom.cpp
rename to Source/bindings/v8/custom/V8WindowCustom.cpp
index 338b058..4343ec8 100644
--- a/Source/bindings/v8/custom/V8DOMWindowCustom.cpp
+++ b/Source/bindings/v8/custom/V8WindowCustom.cpp
@@ -29,7 +29,7 @@
  */
 
 #include "config.h"
-#include "V8DOMWindow.h"
+#include "V8Window.h"
 
 #include "V8HTMLCollection.h"
 #include "V8Node.h"
@@ -76,7 +76,7 @@
     if (argumentCount < 1)
         return;
 
-    DOMWindow* imp = V8DOMWindow::toNative(args.Holder());
+    DOMWindow* imp = V8Window::toNative(args.Holder());
     ScriptExecutionContext* scriptContext = static_cast<ScriptExecutionContext*>(imp->document());
 
     if (!scriptContext) {
@@ -87,9 +87,9 @@
     v8::Handle<v8::Value> function = args[0];
     WTF::String functionString;
     if (!function->IsFunction()) {
-        if (function->IsString())
+        if (function->IsString()) {
             functionString = toWebCoreString(function);
-        else {
+        } else {
             v8::Handle<v8::Value> v8String = function->ToString();
 
             // Bail out if string conversion failed.
@@ -101,7 +101,7 @@
 
         // Don't allow setting timeouts to run empty functions!
         // (Bug 1009597)
-        if (functionString.length() == 0)
+        if (!functionString.length())
             return;
     }
 
@@ -118,9 +118,10 @@
         v8::Local<v8::Value>* params = 0;
         if (paramCount > 0) {
             params = new v8::Local<v8::Value>[paramCount];
-            for (int i = 0; i < paramCount; i++)
+            for (int i = 0; i < paramCount; i++) {
                 // parameters must be globalized
                 params[i] = args[i+2];
+            }
         }
 
         // params is passed to action, and released in action's destructor
@@ -150,13 +151,13 @@
     v8SetReturnValue(args, id);
 }
 
-void V8DOMWindow::eventAttrGetterCustom(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
+void V8Window::eventAttrGetterCustom(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
 {
-    v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(info.GetIsolate(), worldTypeInMainThread(info.GetIsolate())));
+    v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8Window::GetTemplate(info.GetIsolate(), worldTypeInMainThread(info.GetIsolate())));
     if (holder.IsEmpty())
         return;
 
-    Frame* frame = V8DOMWindow::toNative(holder)->frame();
+    Frame* frame = V8Window::toNative(holder)->frame();
     if (!BindingSecurity::shouldAllowAccessToFrame(frame))
         return;
 
@@ -172,13 +173,13 @@
     v8SetReturnValue(info, jsEvent);
 }
 
-void V8DOMWindow::eventAttrSetterCustom(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info)
+void V8Window::eventAttrSetterCustom(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info)
 {
-    v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(info.GetIsolate(), worldTypeInMainThread(info.GetIsolate())));
+    v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8Window::GetTemplate(info.GetIsolate(), worldTypeInMainThread(info.GetIsolate())));
     if (holder.IsEmpty())
         return;
 
-    Frame* frame = V8DOMWindow::toNative(holder)->frame();
+    Frame* frame = V8Window::toNative(holder)->frame();
     if (!BindingSecurity::shouldAllowAccessToFrame(frame))
         return;
 
@@ -191,25 +192,25 @@
     context->Global()->SetHiddenValue(eventSymbol, value);
 }
 
-void V8DOMWindow::locationAttrSetterCustom(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info)
+void V8Window::locationAttrSetterCustom(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info)
 {
-    DOMWindow* imp = V8DOMWindow::toNative(info.Holder());
+    DOMWindow* imp = V8Window::toNative(info.Holder());
 
     DOMWindow* active = activeDOMWindow();
     if (!active)
-      return;
+        return;
 
     DOMWindow* first = firstDOMWindow();
     if (!first)
-      return;
+        return;
 
     if (Location* location = imp->location())
         location->setHref(active, first, toWebCoreString(value));
 }
 
-void V8DOMWindow::openerAttrSetterCustom(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info)
+void V8Window::openerAttrSetterCustom(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info)
 {
-    DOMWindow* imp = V8DOMWindow::toNative(info.Holder());
+    DOMWindow* imp = V8Window::toNative(info.Holder());
 
     if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame()))
         return;
@@ -231,12 +232,12 @@
     info.This()->Set(name, value);
 }
 
-void V8DOMWindow::addEventListenerMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+void V8Window::addEventListenerMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
 {
     String eventType = toWebCoreString(args[0]);
     bool useCapture = args[2]->BooleanValue();
 
-    DOMWindow* imp = V8DOMWindow::toNative(args.Holder());
+    DOMWindow* imp = V8Window::toNative(args.Holder());
 
     if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame()))
         return;
@@ -259,12 +260,12 @@
 }
 
 
-void V8DOMWindow::removeEventListenerMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+void V8Window::removeEventListenerMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
 {
     String eventType = toWebCoreString(args[0]);
     bool useCapture = args[2]->BooleanValue();
 
-    DOMWindow* imp = V8DOMWindow::toNative(args.Holder());
+    DOMWindow* imp = V8Window::toNative(args.Holder());
 
     if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame()))
         return;
@@ -293,11 +294,11 @@
 }
 
 
-void V8DOMWindow::postMessageMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+void V8Window::postMessageMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
 {
     // None of these need to be RefPtr because args and context are guaranteed
     // to hold on to them.
-    DOMWindow* window = V8DOMWindow::toNative(args.Holder());
+    DOMWindow* window = V8Window::toNative(args.Holder());
     DOMWindow* source = activeDOMWindow();
 
     // If called directly by WebCore we don't have a calling context.
@@ -328,11 +329,7 @@
 
     bool didThrow = false;
     RefPtr<SerializedScriptValue> message =
-        SerializedScriptValue::create(args[0],
-                                      &portArray,
-                                      &arrayBufferArray,
-                                      didThrow,
-                                      args.GetIsolate());
+        SerializedScriptValue::create(args[0], &portArray, &arrayBufferArray, didThrow, args.GetIsolate());
     if (didThrow)
         return;
 
@@ -345,9 +342,9 @@
 // fix this by calling toString function on the receiver.
 // However, V8 implements toString in JavaScript, which requires
 // switching context of receiver. I consider it is dangerous.
-void V8DOMWindow::toStringMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+void V8Window::toStringMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
 {
-    v8::Handle<v8::Object> domWrapper = args.This()->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(args.GetIsolate(), worldTypeInMainThread(args.GetIsolate())));
+    v8::Handle<v8::Object> domWrapper = args.This()->FindInstanceInPrototypeChain(V8Window::GetTemplate(args.GetIsolate(), worldTypeInMainThread(args.GetIsolate())));
     if (domWrapper.IsEmpty()) {
         v8SetReturnValue(args, args.This()->ObjectProtoToString());
         return;
@@ -397,9 +394,9 @@
     static_cast<DialogHandler*>(handler)->dialogCreated(dialog);
 }
 
-void V8DOMWindow::showModalDialogMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+void V8Window::showModalDialogMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
 {
-    DOMWindow* impl = V8DOMWindow::toNative(args.Holder());
+    DOMWindow* impl = V8Window::toNative(args.Holder());
     if (!BindingSecurity::shouldAllowAccessToFrame(impl->frame()))
         return;
 
@@ -413,9 +410,9 @@
     v8SetReturnValue(args, handler.returnValue());
 }
 
-void V8DOMWindow::openMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+void V8Window::openMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
 {
-    DOMWindow* impl = V8DOMWindow::toNative(args.Holder());
+    DOMWindow* impl = V8Window::toNative(args.Holder());
     if (!BindingSecurity::shouldAllowAccessToFrame(impl->frame()))
         return;
 
@@ -431,27 +428,29 @@
     v8SetReturnValue(args, toV8Fast(openedWindow.release(), args, impl));
 }
 
-v8::Handle<v8::Value> V8DOMWindow::namedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
+void V8Window::namedPropertyGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
 {
 
-    DOMWindow* window = V8DOMWindow::toNative(info.Holder());
+    DOMWindow* window = V8Window::toNative(info.Holder());
     if (!window)
-        return v8Undefined();
+        return;
 
     Frame* frame = window->frame();
     // window is detached from a frame.
     if (!frame)
-        return v8Undefined();
+        return;
 
     // Search sub-frames.
     AtomicString propName = toWebCoreAtomicString(name);
     Frame* child = frame->tree()->scopedChild(propName);
-    if (child)
-        return toV8Fast(child->document()->domWindow(), info, window);
+    if (child) {
+        v8SetReturnValue(info, toV8Fast(child->document()->domWindow(), info, window));
+        return;
+    }
 
     // Search IDL functions defined in the prototype
     if (!info.Holder()->GetRealNamedProperty(name).IsEmpty())
-        return v8Undefined();
+        return;
 
     // Search named items in the document.
     Document* doc = frame->document();
@@ -460,36 +459,37 @@
         if (toHTMLDocument(doc)->hasNamedItem(propName.impl()) || doc->hasElementWithId(propName.impl())) {
             RefPtr<HTMLCollection> items = doc->windowNamedItems(propName);
             if (!items->isEmpty()) {
-                if (items->hasExactlyOneItem())
-                    return toV8Fast(items->item(0), info, window);
-                return toV8Fast(items.release(), info, window);
+                if (items->hasExactlyOneItem()) {
+                    v8SetReturnValue(info, toV8Fast(items->item(0), info, window));
+                    return;
+                }
+                v8SetReturnValue(info, toV8Fast(items.release(), info, window));
+                return;
             }
         }
     }
-
-    return v8Undefined();
 }
 
 
-void V8DOMWindow::setTimeoutMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+void V8Window::setTimeoutMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
 {
     WindowSetTimeoutImpl(args, true);
 }
 
 
-void V8DOMWindow::setIntervalMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+void V8Window::setIntervalMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
 {
     WindowSetTimeoutImpl(args, false);
 }
 
-bool V8DOMWindow::namedSecurityCheckCustom(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8::AccessType type, v8::Local<v8::Value>)
+bool V8Window::namedSecurityCheckCustom(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8::AccessType type, v8::Local<v8::Value>)
 {
     v8::Isolate* isolate = v8::Isolate::GetCurrent();
-    v8::Handle<v8::Object> window = host->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(isolate, worldTypeInMainThread(isolate)));
+    v8::Handle<v8::Object> window = host->FindInstanceInPrototypeChain(V8Window::GetTemplate(isolate, worldTypeInMainThread(isolate)));
     if (window.IsEmpty())
-        return false;  // the frame is gone.
+        return false; // the frame is gone.
 
-    DOMWindow* targetWindow = V8DOMWindow::toNative(window);
+    DOMWindow* targetWindow = V8Window::toNative(window);
 
     ASSERT(targetWindow);
 
@@ -525,14 +525,14 @@
     return BindingSecurity::shouldAllowAccessToFrame(target, DoNotReportSecurityError);
 }
 
-bool V8DOMWindow::indexedSecurityCheckCustom(v8::Local<v8::Object> host, uint32_t index, v8::AccessType type, v8::Local<v8::Value>)
+bool V8Window::indexedSecurityCheckCustom(v8::Local<v8::Object> host, uint32_t index, v8::AccessType type, v8::Local<v8::Value>)
 {
     v8::Isolate* isolate = v8::Isolate::GetCurrent();
-    v8::Handle<v8::Object> window = host->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(isolate, worldTypeInMainThread(isolate)));
+    v8::Handle<v8::Object> window = host->FindInstanceInPrototypeChain(V8Window::GetTemplate(isolate, worldTypeInMainThread(isolate)));
     if (window.IsEmpty())
         return false;
 
-    DOMWindow* targetWindow = V8DOMWindow::toNative(window);
+    DOMWindow* targetWindow = V8Window::toNative(window);
 
     ASSERT(targetWindow);
 
@@ -574,9 +574,9 @@
     // necessarily the first global object associated with that DOMWindow.
     v8::Handle<v8::Context> currentContext = v8::Context::GetCurrent();
     v8::Handle<v8::Object> currentGlobal = currentContext->Global();
-    v8::Handle<v8::Object> windowWrapper = currentGlobal->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(isolate, worldTypeInMainThread(isolate)));
+    v8::Handle<v8::Object> windowWrapper = currentGlobal->FindInstanceInPrototypeChain(V8Window::GetTemplate(isolate, worldTypeInMainThread(isolate)));
     if (!windowWrapper.IsEmpty()) {
-        if (V8DOMWindow::toNative(windowWrapper) == window)
+        if (V8Window::toNative(windowWrapper) == window)
             return currentGlobal;
     }
 
diff --git a/Source/bindings/v8/custom/V8DOMStringMapCustom.cpp b/Source/bindings/v8/custom/V8WorkerCryptoCustom.cpp
similarity index 75%
copy from Source/bindings/v8/custom/V8DOMStringMapCustom.cpp
copy to Source/bindings/v8/custom/V8WorkerCryptoCustom.cpp
index 6b6ee5f..539b9ed 100644
--- a/Source/bindings/v8/custom/V8DOMStringMapCustom.cpp
+++ b/Source/bindings/v8/custom/V8WorkerCryptoCustom.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2013 Google Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -29,20 +29,15 @@
  */
 
 #include "config.h"
-#include "V8DOMStringMap.h"
+#include "V8WorkerCrypto.h"
 
-#include "V8Element.h"
-#include "bindings/v8/V8Binding.h"
-#include "bindings/v8/V8DOMWrapper.h"
-#include "core/dom/DOMStringMap.h"
+#include "V8Crypto.h"
 
 namespace WebCore {
 
-v8::Handle<v8::Integer> V8DOMStringMap::namedPropertyQuery(v8::Local<v8::String> name, const v8::AccessorInfo& info)
+void V8WorkerCrypto::getRandomValuesMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
 {
-    if (V8DOMStringMap::toNative(info.Holder())->contains(toWebCoreString(name)))
-        return v8Integer(0, info.GetIsolate());
-    return v8::Handle<v8::Integer>();
+    V8Crypto::getRandomValuesMethodCustom(args);
 }
 
 } // namespace WebCore
diff --git a/Source/bindings/v8/custom/V8XMLHttpRequestCustom.cpp b/Source/bindings/v8/custom/V8XMLHttpRequestCustom.cpp
index ba312ed..afbce7b 100644
--- a/Source/bindings/v8/custom/V8XMLHttpRequestCustom.cpp
+++ b/Source/bindings/v8/custom/V8XMLHttpRequestCustom.cpp
@@ -70,12 +70,16 @@
 {
     XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(info.Holder());
     ExceptionCode ec = 0;
-    const String& text = xmlHttpRequest->responseText(ec);
+    ScriptValue text = xmlHttpRequest->responseText(ec);
     if (ec) {
         setDOMException(ec, info.GetIsolate());
         return;
     }
-    v8SetReturnValue(info, v8String(text, info.GetIsolate()));
+    if (text.hasNoValue()) {
+        v8SetReturnValue(info, v8String(emptyString(), info.GetIsolate()));
+        return;
+    }
+    v8SetReturnValue(info, text.v8Value());
 }
 
 void V8XMLHttpRequest::responseAttrGetterCustom(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)