Merge from Chromium at DEPS revision 225410

This commit was generated by merge_to_master.py.

Change-Id: I639f21f936f7475217030840a808765c32e44635
diff --git a/Source/bindings/v8/CustomElementConstructorBuilder.cpp b/Source/bindings/v8/CustomElementConstructorBuilder.cpp
index b404034..7aba519 100644
--- a/Source/bindings/v8/CustomElementConstructorBuilder.cpp
+++ b/Source/bindings/v8/CustomElementConstructorBuilder.cpp
@@ -210,7 +210,7 @@
 
 bool CustomElementConstructorBuilder::prototypeIsValid(const AtomicString& type, ExceptionState& es) const
 {
-    if (m_prototype->InternalFieldCount() || !m_prototype->GetHiddenValue(V8HiddenPropertyName::customElementIsInterfacePrototypeObject()).IsEmpty()) {
+    if (m_prototype->InternalFieldCount() || !m_prototype->GetHiddenValue(V8HiddenPropertyName::customElementIsInterfacePrototypeObject(m_context->GetIsolate())).IsEmpty()) {
         CustomElementException::throwException(CustomElementException::PrototypeInUse, type, es);
         return false;
     }
@@ -265,10 +265,10 @@
         return;
     }
 
-    Document* document = V8Document::toNative(args.Callee()->GetHiddenValue(V8HiddenPropertyName::customElementDocument()).As<v8::Object>());
-    V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, namespaceURI, args.Callee()->GetHiddenValue(V8HiddenPropertyName::customElementNamespaceURI()));
-    V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, tagName, args.Callee()->GetHiddenValue(V8HiddenPropertyName::customElementTagName()));
-    v8::Handle<v8::Value> maybeType = args.Callee()->GetHiddenValue(V8HiddenPropertyName::customElementType());
+    Document* document = V8Document::toNative(args.Callee()->GetHiddenValue(V8HiddenPropertyName::customElementDocument(isolate)).As<v8::Object>());
+    V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, namespaceURI, args.Callee()->GetHiddenValue(V8HiddenPropertyName::customElementNamespaceURI(isolate)));
+    V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, tagName, args.Callee()->GetHiddenValue(V8HiddenPropertyName::customElementTagName(isolate)));
+    v8::Handle<v8::Value> maybeType = args.Callee()->GetHiddenValue(V8HiddenPropertyName::customElementType(isolate));
     V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, type, maybeType);
 
     ExceptionState es(args.GetIsolate());
diff --git a/Source/bindings/v8/DateExtension.cpp b/Source/bindings/v8/DateExtension.cpp
index d06983b..ebf203c 100644
--- a/Source/bindings/v8/DateExtension.cpp
+++ b/Source/bindings/v8/DateExtension.cpp
@@ -84,7 +84,7 @@
     if (dateObject.IsEmpty())
         return;
 
-    v8::Local<v8::Value> sleepFunctionHandle = dateObject->GetHiddenValue(V8HiddenPropertyName::sleepFunction());
+    v8::Local<v8::Value> sleepFunctionHandle = dateObject->GetHiddenValue(V8HiddenPropertyName::sleepFunction(isolate));
     if (sleepFunctionHandle.IsEmpty() || !sleepFunctionHandle->IsFunction())
         return;
 
@@ -111,7 +111,7 @@
     v8::Handle<v8::Object> dateObject = v8::Handle<v8::Object>::Cast(args[0]);
     v8::Handle<v8::Function> enableSleepDetectionFunction = v8::Handle<v8::Function>::Cast(args[1]);
 
-    dateObject->SetHiddenValue(V8HiddenPropertyName::sleepFunction(), enableSleepDetectionFunction);
+    dateObject->SetHiddenValue(V8HiddenPropertyName::sleepFunction(args.GetIsolate()), enableSleepDetectionFunction);
     return;
 }
 
diff --git a/Source/bindings/v8/DebuggerScript.js b/Source/bindings/v8/DebuggerScript.js
index c48664a..ccea7e0 100644
--- a/Source/bindings/v8/DebuggerScript.js
+++ b/Source/bindings/v8/DebuggerScript.js
@@ -217,9 +217,10 @@
     execState.prepareStep(Debug.StepAction.StepIn, 1);
 }
 
-DebuggerScript.stepOverStatement = function(execState)
+DebuggerScript.stepOverStatement = function(execState, callFrame)
 {
-    execState.prepareStep(Debug.StepAction.StepNext, 1);
+    var frameMirror = callFrame ? callFrame.frameMirror : undefined;
+    execState.prepareStep(Debug.StepAction.StepNext, 1, frameMirror);
 }
 
 DebuggerScript.stepOutOfFunction = function(execState)
@@ -387,7 +388,8 @@
         "caller": callerFrame,
         "restart": restart,
         "setVariableValue": setVariableValue,
-        "stepInPositions": stepInPositions
+        "stepInPositions": stepInPositions,
+        "frameMirror": frameMirror
     };
 }
 
diff --git a/Source/bindings/v8/Dictionary.h b/Source/bindings/v8/Dictionary.h
index ec22291..27fea21 100644
--- a/Source/bindings/v8/Dictionary.h
+++ b/Source/bindings/v8/Dictionary.h
@@ -27,7 +27,7 @@
 #define Dictionary_h
 
 #include "bindings/v8/ScriptValue.h"
-#include "core/dom/EventListener.h"
+#include "core/events/EventListener.h"
 #include "core/dom/MessagePort.h"
 #include <v8.h>
 #include "wtf/HashMap.h"
diff --git a/Source/bindings/v8/ExceptionMessages.cpp b/Source/bindings/v8/ExceptionMessages.cpp
index f8d6a55..905a2fc 100644
--- a/Source/bindings/v8/ExceptionMessages.cpp
+++ b/Source/bindings/v8/ExceptionMessages.cpp
@@ -53,6 +53,11 @@
     return "Failed to set the '" + property + "' property on '" + type + "': " + detail;
 }
 
+String ExceptionMessages::failedToDelete(const String& property, const String& type, const String& detail)
+{
+    return "Failed to delete the '" + property + "' property from '" + type + "': " + detail;
+}
+
 String ExceptionMessages::notEnoughArguments(unsigned expected, unsigned provided)
 {
     return String::number(expected) + " argument" + (expected > 1 ? "s" : "") + " required, but only " + String::number(provided) + " present.";
diff --git a/Source/bindings/v8/ExceptionMessages.h b/Source/bindings/v8/ExceptionMessages.h
index 424754d..204f67a 100644
--- a/Source/bindings/v8/ExceptionMessages.h
+++ b/Source/bindings/v8/ExceptionMessages.h
@@ -41,6 +41,7 @@
     static String failedToExecute(const String& method, const String& type, const String& detail = String());
     static String failedToGet(const String& property, const String& type, const String& detail);
     static String failedToSet(const String& property, const String& type, const String& detail);
+    static String failedToDelete(const String& property, const String& type, const String& detail);
 
     static String notEnoughArguments(unsigned expected, unsigned providedleastNumMandatoryParams);
 };
diff --git a/Source/bindings/v8/ExceptionState.h b/Source/bindings/v8/ExceptionState.h
index 0642a0a..26bae40 100644
--- a/Source/bindings/v8/ExceptionState.h
+++ b/Source/bindings/v8/ExceptionState.h
@@ -48,10 +48,13 @@
         : m_code(0)
         , m_isolate(isolate) { }
 
-    virtual void throwDOMException(const ExceptionCode&,  const String& message = String());
+    virtual void throwDOMException(const ExceptionCode&,  const String& message);
     virtual void throwTypeError(const String& message = String());
     virtual void throwSecurityError(const String& sanitizedMessage, const String& unsanitizedMessage = String());
 
+    // Please don't use this method. Use ::throwDOMException, and pass in a useful exception message.
+    virtual void throwUninformativeAndGenericDOMException(const ExceptionCode& ec) { throwDOMException(ec, String()); };
+
     bool hadException() const { return !m_exception.isEmpty() || m_code; }
     void clearException();
 
@@ -62,7 +65,7 @@
         if (m_exception.isEmpty()) {
             if (!m_code)
                 return false;
-            throwDOMException(m_code);
+            throwUninformativeAndGenericDOMException(m_code);
         }
 
         V8ThrowException::throwError(m_exception.newLocal(m_isolate), m_isolate);
@@ -82,7 +85,7 @@
 class TrackExceptionState : public ExceptionState {
 public:
     TrackExceptionState(): ExceptionState(0) { }
-    virtual void throwDOMException(const ExceptionCode&, const String& message = String()) OVERRIDE FINAL;
+    virtual void throwDOMException(const ExceptionCode&, const String& message) OVERRIDE FINAL;
     virtual void throwTypeError(const String& message = String()) OVERRIDE FINAL;
     virtual void throwSecurityError(const String& sanitizedMessage, const String& unsanitizedMessage = String()) OVERRIDE FINAL;
 };
diff --git a/Source/bindings/v8/ScriptController.cpp b/Source/bindings/v8/ScriptController.cpp
index 1b24a38..d400a91 100644
--- a/Source/bindings/v8/ScriptController.cpp
+++ b/Source/bindings/v8/ScriptController.cpp
@@ -50,9 +50,9 @@
 #include "bindings/v8/npruntime_impl.h"
 #include "bindings/v8/npruntime_priv.h"
 #include "core/dom/Document.h"
-#include "core/dom/Event.h"
-#include "core/dom/EventListener.h"
-#include "core/dom/EventNames.h"
+#include "core/events/Event.h"
+#include "core/events/EventListener.h"
+#include "core/events/EventNames.h"
 #include "core/dom/Node.h"
 #include "core/dom/ScriptableDocumentParser.h"
 #include "core/dom/UserGestureIndicator.h"
diff --git a/Source/bindings/v8/ScriptDebugServer.cpp b/Source/bindings/v8/ScriptDebugServer.cpp
index 7a408d7..2caa721 100644
--- a/Source/bindings/v8/ScriptDebugServer.cpp
+++ b/Source/bindings/v8/ScriptDebugServer.cpp
@@ -222,12 +222,24 @@
     continueProgram();
 }
 
-void ScriptDebugServer::stepOverStatement()
+void ScriptDebugServer::stepOverStatement(const ScriptValue& frame)
 {
     ASSERT(isPaused());
     v8::HandleScope handleScope(m_isolate);
-    v8::Handle<v8::Value> argv[] = { m_executionState.newLocal(m_isolate) };
-    callDebuggerMethod("stepOverStatement", 1, argv);
+    v8::Handle<v8::Value> callFrame;
+    if (frame.hasNoValue()) {
+        callFrame = v8::Undefined(m_isolate);
+    } else {
+        JavaScriptCallFrame* impl = V8JavaScriptCallFrame::toNative(v8::Handle<v8::Object>::Cast(frame.v8Value()));
+        callFrame = impl->innerCallFrame();
+    }
+
+    v8::Handle<v8::Value> argv[] = {
+        m_executionState.newLocal(m_isolate),
+        callFrame
+    };
+
+    callDebuggerMethod("stepOverStatement", 2, argv);
     continueProgram();
 }
 
diff --git a/Source/bindings/v8/ScriptDebugServer.h b/Source/bindings/v8/ScriptDebugServer.h
index 18dc579..ab40574 100644
--- a/Source/bindings/v8/ScriptDebugServer.h
+++ b/Source/bindings/v8/ScriptDebugServer.h
@@ -75,7 +75,7 @@
     void breakProgram();
     void continueProgram();
     void stepIntoStatement();
-    void stepOverStatement();
+    void stepOverStatement(const ScriptValue& frame);
     void stepOutOfFunction();
 
     bool setScriptSource(const String& sourceID, const String& newContent, bool preview, String* error, RefPtr<TypeBuilder::Debugger::SetScriptSourceError>&, ScriptValue* newCallFrames, ScriptObject* result);
diff --git a/Source/bindings/v8/ScriptEventListener.cpp b/Source/bindings/v8/ScriptEventListener.cpp
index c10cea9..abd3d4d 100644
--- a/Source/bindings/v8/ScriptEventListener.cpp
+++ b/Source/bindings/v8/ScriptEventListener.cpp
@@ -38,7 +38,7 @@
 #include "bindings/v8/V8WindowShell.h"
 #include "core/dom/Document.h"
 #include "core/dom/DocumentParser.h"
-#include "core/dom/EventListener.h"
+#include "core/events/EventListener.h"
 #include "core/page/Frame.h"
 
 namespace WebCore {
@@ -60,15 +60,19 @@
     TextPosition position(OrdinalNumber::fromZeroBasedInt(1), OrdinalNumber::first());
     String sourceURL;
 
+    v8::Isolate* isolate;
     if (Frame* frame = node->document().frame()) {
+        isolate = toIsolate(frame);
         ScriptController* scriptController = frame->script();
         if (!scriptController->canExecuteScripts(AboutToExecuteScript))
             return 0;
         position = scriptController->eventHandlerPosition();
         sourceURL = node->document().url().string();
+    } else {
+        isolate = v8::Isolate::GetCurrent();
     }
 
-    return V8LazyEventListener::create(name.localName().string(), eventParameterName(node->isSVGElement()), value, sourceURL, position, node);
+    return V8LazyEventListener::create(name.localName().string(), eventParameterName(node->isSVGElement()), value, sourceURL, position, node, isolate);
 }
 
 PassRefPtr<V8LazyEventListener> createAttributeEventListener(Frame* frame, const QualifiedName& name, const AtomicString& value)
@@ -86,7 +90,7 @@
     TextPosition position = scriptController->eventHandlerPosition();
     String sourceURL = frame->document()->url().string();
 
-    return V8LazyEventListener::create(name.localName().string(), eventParameterName(frame->document()->isSVGDocument()), value, sourceURL, position, 0);
+    return V8LazyEventListener::create(name.localName().string(), eventParameterName(frame->document()->isSVGDocument()), value, sourceURL, position, 0, toIsolate(frame));
 }
 
 String eventListenerHandlerBody(Document* document, EventListener* listener)
diff --git a/Source/bindings/v8/ScriptGCEvent.cpp b/Source/bindings/v8/ScriptGCEvent.cpp
index 50b2d8f..361d8e3 100644
--- a/Source/bindings/v8/ScriptGCEvent.cpp
+++ b/Source/bindings/v8/ScriptGCEvent.cpp
@@ -62,7 +62,7 @@
     GCEventData::GCEventListeners& listeners = isolateGCEventData()->listeners();
     ASSERT(!listeners.isEmpty());
     size_t i = listeners.find(eventListener);
-    ASSERT(i != notFound);
+    ASSERT(i != kNotFound);
     listeners.remove(i);
     if (listeners.isEmpty()) {
         v8::V8::RemoveGCPrologueCallback(ScriptGCEvent::gcPrologueCallback);
diff --git a/Source/bindings/v8/ScriptProfiler.cpp b/Source/bindings/v8/ScriptProfiler.cpp
index f9f5604..7027da6 100644
--- a/Source/bindings/v8/ScriptProfiler.cpp
+++ b/Source/bindings/v8/ScriptProfiler.cpp
@@ -50,6 +50,14 @@
 
 typedef HashMap<String, double> ProfileNameIdleTimeMap;
 
+void ScriptProfiler::setSamplingInterval(int intervalUs)
+{
+    v8::Isolate* isolate = v8::Isolate::GetCurrent();
+    v8::CpuProfiler* profiler = isolate->GetCpuProfiler();
+    if (profiler)
+        profiler->SetSamplingInterval(intervalUs);
+}
+
 void ScriptProfiler::start(const String& title)
 {
     ProfileNameIdleTimeMap* profileNameIdleTimeMap = ScriptProfiler::currentProfileNameIdleTimeMap();
diff --git a/Source/bindings/v8/ScriptProfiler.h b/Source/bindings/v8/ScriptProfiler.h
index 93f25bc..f406c52 100644
--- a/Source/bindings/v8/ScriptProfiler.h
+++ b/Source/bindings/v8/ScriptProfiler.h
@@ -70,6 +70,7 @@
     static void collectGarbage();
     static ScriptObject objectByHeapObjectId(unsigned id);
     static unsigned getHeapObjectId(const ScriptValue&);
+    static void setSamplingInterval(int intervalUs);
     static void start(const String& title);
     static PassRefPtr<ScriptProfile> stop(const String& title);
     static PassRefPtr<ScriptHeapSnapshot> takeHeapSnapshot(const String& title, HeapSnapshotProgress*);
diff --git a/Source/bindings/v8/ScriptPromiseResolver.cpp b/Source/bindings/v8/ScriptPromiseResolver.cpp
index 7440a41..8e2e5b3 100644
--- a/Source/bindings/v8/ScriptPromiseResolver.cpp
+++ b/Source/bindings/v8/ScriptPromiseResolver.cpp
@@ -44,12 +44,12 @@
 
 ScriptPromiseResolver::ScriptPromiseResolver(v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
     : m_isolate(isolate)
+    , m_promiseForExposeDetached(false)
+    , m_promiseForResolveDetached(false)
 {
     ASSERT(RuntimeEnabledFeatures::promiseEnabled());
-    v8::Local<v8::Object> promise, resolver;
-    V8PromiseCustom::createPromise(creationContext, &promise, &resolver, isolate);
+    v8::Local<v8::Object> promise = V8PromiseCustom::createPromise(creationContext, isolate);
     m_promise = ScriptPromise(promise, isolate);
-    m_resolver.set(isolate, resolver);
 }
 
 ScriptPromiseResolver::~ScriptPromiseResolver()
@@ -57,16 +57,34 @@
     // We don't call "detach" here because it requires a caller
     // to be in a v8 context.
 
-    detachPromise();
-    m_resolver.clear();
+    detachPromiseForExpose();
+    detachPromiseForResolve();
+}
+
+void ScriptPromiseResolver::detachPromise()
+{
+    detachPromiseForExpose();
+}
+
+void ScriptPromiseResolver::detachPromiseForExpose()
+{
+    m_promiseForExposeDetached = true;
+    if (m_promiseForResolveDetached)
+        m_promise.clear();
+}
+
+void ScriptPromiseResolver::detachPromiseForResolve()
+{
+    m_promiseForResolveDetached = true;
+    if (m_promiseForExposeDetached)
+        m_promise.clear();
 }
 
 PassRefPtr<ScriptPromiseResolver> ScriptPromiseResolver::create(ScriptExecutionContext* context)
 {
     ASSERT(v8::Context::InContext());
     ASSERT(context);
-    v8::Isolate* isolate = v8::Isolate::GetCurrent();
-    return adoptRef(new ScriptPromiseResolver(toV8Context(context, DOMWrapperWorld::current())->Global(), isolate));
+    return adoptRef(new ScriptPromiseResolver(toV8Context(context, DOMWrapperWorld::current())->Global(), toIsolate(context)));
 }
 
 PassRefPtr<ScriptPromiseResolver> ScriptPromiseResolver::create()
@@ -79,48 +97,49 @@
 bool ScriptPromiseResolver::isPending() const
 {
     ASSERT(v8::Context::InContext());
-    return isPendingInternal();
+    if (m_promiseForResolveDetached)
+        return false;
+    ASSERT(!m_promise.hasNoValue());
+    v8::Local<v8::Object> promise = m_promise.v8Value().As<v8::Object>();
+    v8::Local<v8::Object> internal = V8PromiseCustom::getInternal(promise);
+    V8PromiseCustom::PromiseState state = V8PromiseCustom::getState(internal);
+    return state == V8PromiseCustom::Pending;
 }
 
 void ScriptPromiseResolver::detach()
 {
     ASSERT(v8::Context::InContext());
-    detachPromise();
+    detachPromiseForExpose();
     reject(v8::Undefined(m_isolate));
-    m_resolver.clear();
+    detachPromiseForResolve();
 }
 
 void ScriptPromiseResolver::fulfill(v8::Handle<v8::Value> value)
 {
-    ASSERT(v8::Context::InContext());
-    if (!isPendingInternal())
-        return;
-    V8PromiseCustom::fulfillResolver(m_resolver.newLocal(m_isolate), value, V8PromiseCustom::Asynchronous, m_isolate);
-    m_resolver.clear();
+    resolve(value);
 }
 
 void ScriptPromiseResolver::resolve(v8::Handle<v8::Value> value)
 {
     ASSERT(v8::Context::InContext());
-    if (!isPendingInternal())
+    if (!isPending())
         return;
-    V8PromiseCustom::resolveResolver(m_resolver.newLocal(m_isolate), value, V8PromiseCustom::Asynchronous, m_isolate);
-    m_resolver.clear();
+    V8PromiseCustom::resolve(m_promise.v8Value().As<v8::Object>(), value, V8PromiseCustom::Asynchronous, m_isolate);
+    detachPromiseForResolve();
 }
 
 void ScriptPromiseResolver::reject(v8::Handle<v8::Value> value)
 {
     ASSERT(v8::Context::InContext());
-    if (!isPendingInternal())
+    if (!isPending())
         return;
-    V8PromiseCustom::rejectResolver(m_resolver.newLocal(m_isolate), value, V8PromiseCustom::Asynchronous, m_isolate);
-    m_resolver.clear();
+    V8PromiseCustom::reject(m_promise.v8Value().As<v8::Object>(), value, V8PromiseCustom::Asynchronous, m_isolate);
+    detachPromiseForResolve();
 }
 
 void ScriptPromiseResolver::fulfill(ScriptValue value)
 {
-    ASSERT(v8::Context::InContext());
-    fulfill(value.v8Value());
+    resolve(value);
 }
 
 void ScriptPromiseResolver::resolve(ScriptValue value)
@@ -135,17 +154,4 @@
     reject(value.v8Value());
 }
 
-bool ScriptPromiseResolver::isPendingInternal() const
-{
-    ASSERT(v8::Context::InContext());
-    if (m_resolver.isEmpty())
-        return false;
-    v8::Local<v8::Object> resolver = m_resolver.newLocal(m_isolate);
-    if (V8PromiseCustom::isInternalDetached(resolver))
-        return false;
-    v8::Local<v8::Object> internal = V8PromiseCustom::getInternal(resolver);
-    V8PromiseCustom::PromiseState state = V8PromiseCustom::getState(internal);
-    return state == V8PromiseCustom::Pending;
-}
-
 } // namespace WebCore
diff --git a/Source/bindings/v8/ScriptPromiseResolver.h b/Source/bindings/v8/ScriptPromiseResolver.h
index 7140b39..7c93e06 100644
--- a/Source/bindings/v8/ScriptPromiseResolver.h
+++ b/Source/bindings/v8/ScriptPromiseResolver.h
@@ -44,8 +44,8 @@
 
 class ScriptExecutionContext;
 
-// ScriptPromiseResolver is a class for accessing PromiseResolver methods
-// (fulfill / resolve / reject) from C++ world.
+// ScriptPromiseResolver is a class for performing operations on Promise
+// (resolve / reject) from C++ world.
 // ScriptPromiseResolver holds a Promise and a PromiseResolver.
 // All methods of this class must be called from the main thread.
 // Here is a typical usage:
@@ -53,7 +53,7 @@
 //  2. Pass the promise object of the holder to a JavaScript program
 //     (such as XMLHttpRequest return value).
 //  3. Detach the promise object if you no longer need it.
-//  4. Call fulfill or reject when the operation completes or
+//  4. Call resolve or reject when the operation completes or
 //     the operation fails respectively.
 //
 // Most methods including constructors must be called within a v8 context.
@@ -61,12 +61,19 @@
 // enter a v8 context, for example by using ScriptScope and ScriptState.
 //
 // If you hold ScriptPromiseResolver as a member variable in a DOM object,
-// it causes memory leaks unless you detach the promise and resolver object
-// manually.
+// it causes memory leaks unless you detach the promise object manually.
+// Logically ScriptPromiseResolver has 2 references to the promise object.
+// One is for exposing the promise object, another is for resolving it.
+// To prevent memory leaks, you should release these 2 references manually.
+// Following operations release references to the promise object.
+//  1. detachPromise releases the reference for exposing.
+//  2. resolve / reject operations release the reference for resolving.
+//  3. detach releases both references.
+//  4. Destroying ScriptPromiseResolver releases both references.
+//
 // So if you no longer need the promise object, you should call detachPromise.
-// And if the operation completes or fails, you should call fulfill / resolve /
-// reject. Destroying ScriptPromiseResolver will also detach the promise and
-// resolver object.
+// And if the operation completes or fails, you should call resolve / reject.
+// Destroying ScriptPromiseResolver will also detach the promise object.
 //
 class ScriptPromiseResolver : public RefCounted<ScriptPromiseResolver> {
     WTF_MAKE_NONCOPYABLE(ScriptPromiseResolver);
@@ -74,22 +81,19 @@
     static PassRefPtr<ScriptPromiseResolver> create(ScriptExecutionContext*);
     static PassRefPtr<ScriptPromiseResolver> create();
 
-    // A ScriptPromiseResolver should be fulfilled / resolved / rejected before
+    // A ScriptPromiseResolver should be resolved / rejected before
     // its destruction.
     // A ScriptPromiseResolver can be destructed safely without
     // entering a v8 context.
     ~ScriptPromiseResolver();
 
-    // Detach the promise object and reject the resolver object with undefined.
+    // Reject the promise with undefined and detach it.
     void detach();
 
     // Detach the promise object.
-    void detachPromise() { m_promise.clear(); }
+    void detachPromise();
 
-    // Return true if the following conditions are met:
-    //  - The resolver object is not detached.
-    //  - The resolver's promise object is in pending state.
-    //  - The resolver's resolved flag is not set.
+    // Return true if the promise object is in pending state.
     bool isPending() const;
 
     ScriptPromise promise()
@@ -99,6 +103,7 @@
     }
 
     // Fulfill with a C++ object which can be converted to a v8 object by toV8.
+    // This method "fulfill" is the deprecated alias to resolve.
     template<typename T>
     inline void fulfill(PassRefPtr<T>);
     // Resolve with a C++ object which can be converted to a v8 object by toV8.
@@ -108,6 +113,7 @@
     template<typename T>
     inline void reject(PassRefPtr<T>);
 
+    // This method "fulfill" is the deprecated alias to resolve.
     void fulfill(ScriptValue);
     void resolve(ScriptValue);
     void reject(ScriptValue);
@@ -120,8 +126,11 @@
 
     v8::Isolate* m_isolate;
     ScriptPromise m_promise;
-    ScopedPersistent<v8::Object> m_resolver;
-    bool isPendingInternal() const;
+    bool m_promiseForExposeDetached : 1;
+    bool m_promiseForResolveDetached : 1;
+
+    void detachPromiseForExpose();
+    void detachPromiseForResolve();
 };
 
 template<typename T>
diff --git a/Source/bindings/v8/ScriptState.cpp b/Source/bindings/v8/ScriptState.cpp
index d59ccf0..0304680 100644
--- a/Source/bindings/v8/ScriptState.cpp
+++ b/Source/bindings/v8/ScriptState.cpp
@@ -72,12 +72,12 @@
 
     v8::Local<v8::Object> innerGlobal = v8::Local<v8::Object>::Cast(context->Global()->GetPrototype());
 
-    v8::Local<v8::Value> scriptStateWrapper = innerGlobal->GetHiddenValue(V8HiddenPropertyName::scriptState());
+    v8::Local<v8::Value> scriptStateWrapper = innerGlobal->GetHiddenValue(V8HiddenPropertyName::scriptState(context->GetIsolate()));
     if (!scriptStateWrapper.IsEmpty() && scriptStateWrapper->IsExternal())
         return static_cast<ScriptState*>(v8::External::Cast(*scriptStateWrapper)->Value());
 
     ScriptState* scriptState = new ScriptState(context);
-    innerGlobal->SetHiddenValue(V8HiddenPropertyName::scriptState(), v8::External::New(scriptState));
+    innerGlobal->SetHiddenValue(V8HiddenPropertyName::scriptState(context->GetIsolate()), v8::External::New(scriptState));
     return scriptState;
 }
 
diff --git a/Source/bindings/v8/SerializedScriptValue.cpp b/Source/bindings/v8/SerializedScriptValue.cpp
index 46a815b..8f9d608 100644
--- a/Source/bindings/v8/SerializedScriptValue.cpp
+++ b/Source/bindings/v8/SerializedScriptValue.cpp
@@ -1746,7 +1746,6 @@
         const void* bufferStart = m_buffer + m_position;
         RefPtr<ArrayBuffer> arrayBuffer = ArrayBuffer::create(bufferStart, byteLength);
         arrayBuffer->setDeallocationObserver(V8ArrayBufferDeallocationObserver::instance());
-        v8::V8::AdjustAmountOfExternalAllocatedMemory(arrayBuffer->byteLength());
         m_position += byteLength;
         return arrayBuffer.release();
     }
diff --git a/Source/bindings/v8/V8AbstractEventListener.cpp b/Source/bindings/v8/V8AbstractEventListener.cpp
index 678ed9f..7fe68ab 100644
--- a/Source/bindings/v8/V8AbstractEventListener.cpp
+++ b/Source/bindings/v8/V8AbstractEventListener.cpp
@@ -37,9 +37,9 @@
 #include "bindings/v8/V8Binding.h"
 #include "bindings/v8/V8EventListenerList.h"
 #include "bindings/v8/V8HiddenPropertyName.h"
-#include "core/dom/BeforeUnloadEvent.h"
-#include "core/dom/Event.h"
-#include "core/dom/EventNames.h"
+#include "core/events/BeforeUnloadEvent.h"
+#include "core/events/Event.h"
+#include "core/events/EventNames.h"
 #include "core/inspector/InspectorCounters.h"
 #include "core/workers/WorkerGlobalScope.h"
 
@@ -58,7 +58,7 @@
 {
     if (!m_listener.isEmpty()) {
         v8::HandleScope scope(m_isolate);
-        V8EventListenerList::clearWrapper(m_listener.newLocal(m_isolate), m_isAttribute);
+        V8EventListenerList::clearWrapper(m_listener.newLocal(m_isolate), m_isAttribute, m_isolate);
     }
     ThreadLocalInspectorCounters::current().decrementCounter(ThreadLocalInspectorCounters::JSEventListenerCounter);
 }
@@ -109,7 +109,7 @@
         return;
 
     // We push the event being processed into the global object, so that it can be exposed by DOMWindow's bindings.
-    v8::Handle<v8::String> eventSymbol = V8HiddenPropertyName::event();
+    v8::Handle<v8::String> eventSymbol = V8HiddenPropertyName::event(v8Context->GetIsolate());
     v8::Local<v8::Value> returnValue;
 
     // In beforeunload/unload handlers, we want to avoid sleeps which do tight loops of calling Date.getTime().
diff --git a/Source/bindings/v8/V8AbstractEventListener.h b/Source/bindings/v8/V8AbstractEventListener.h
index 9fcb915..1fdca6b 100644
--- a/Source/bindings/v8/V8AbstractEventListener.h
+++ b/Source/bindings/v8/V8AbstractEventListener.h
@@ -34,7 +34,7 @@
 #include "bindings/v8/DOMWrapperWorld.h"
 #include "bindings/v8/ScopedPersistent.h"
 #include "bindings/v8/V8Utilities.h"
-#include "core/dom/EventListener.h"
+#include "core/events/EventListener.h"
 #include <v8.h>
 #include "wtf/PassRefPtr.h"
 #include "wtf/RefCounted.h"
diff --git a/Source/bindings/v8/V8Binding.cpp b/Source/bindings/v8/V8Binding.cpp
index 9ae2300..1901643 100644
--- a/Source/bindings/v8/V8Binding.cpp
+++ b/Source/bindings/v8/V8Binding.cpp
@@ -117,11 +117,6 @@
         return data;
     }
 
-    virtual void Free(void*)
-    {
-        IMMEDIATE_CRASH();
-    }
-
     virtual void Free(void* data, size_t size) OVERRIDE
     {
         WTF::ArrayBufferContents::freeMemory(data, size);
@@ -591,14 +586,26 @@
     return wrapper.IsEmpty() ? v8::Local<v8::Value>() : wrapper->GetHiddenValue(key);
 }
 
+static v8::Isolate* mainIsolate = 0;
+
+v8::Isolate* mainThreadIsolate()
+{
+    ASSERT(mainIsolate);
+    ASSERT(isMainThread());
+    return mainIsolate;
+}
+
+void setMainThreadIsolate(v8::Isolate* isolate)
+{
+    ASSERT(!mainIsolate);
+    ASSERT(isMainThread());
+    mainIsolate = isolate;
+}
+
 v8::Isolate* toIsolate(ScriptExecutionContext* context)
 {
-    if (context && context->isDocument()) {
-        static v8::Isolate* mainWorldIsolate = 0;
-        if (!mainWorldIsolate)
-            mainWorldIsolate = v8::Isolate::GetCurrent();
-        return mainWorldIsolate;
-    }
+    if (context && context->isDocument())
+        return mainThreadIsolate();
     return v8::Isolate::GetCurrent();
 }
 
diff --git a/Source/bindings/v8/V8Binding.h b/Source/bindings/v8/V8Binding.h
index 0fe7ff2..9da35ec 100644
--- a/Source/bindings/v8/V8Binding.h
+++ b/Source/bindings/v8/V8Binding.h
@@ -647,16 +647,19 @@
     }
 
     // Attaches |environment| to |function| and returns it.
-    inline v8::Local<v8::Function> createClosure(v8::FunctionCallback function, v8::Handle<v8::Value> environment)
+    inline v8::Local<v8::Function> createClosure(v8::FunctionCallback function, v8::Handle<v8::Value> environment, v8::Isolate* isolate)
     {
-        return v8::FunctionTemplate::New(function, environment)->GetFunction();
+        return v8::Function::New(isolate, function, environment);
     }
 
     v8::Local<v8::Value> getHiddenValueFromMainWorldWrapper(v8::Isolate*, ScriptWrappable*, v8::Handle<v8::String> key);
 
+    v8::Isolate* mainThreadIsolate();
     v8::Isolate* toIsolate(ScriptExecutionContext*);
     v8::Isolate* toIsolate(Frame*);
 
+    // Can only be called by WebKit::initialize
+    void setMainThreadIsolate(v8::Isolate*);
 } // namespace WebCore
 
 #endif // V8Binding_h
diff --git a/Source/bindings/v8/V8CustomElementLifecycleCallbacks.cpp b/Source/bindings/v8/V8CustomElementLifecycleCallbacks.cpp
index 93b0518..1c3e3c8 100644
--- a/Source/bindings/v8/V8CustomElementLifecycleCallbacks.cpp
+++ b/Source/bindings/v8/V8CustomElementLifecycleCallbacks.cpp
@@ -51,12 +51,13 @@
 
 PassRefPtr<V8CustomElementLifecycleCallbacks> V8CustomElementLifecycleCallbacks::create(ScriptExecutionContext* scriptExecutionContext, v8::Handle<v8::Object> prototype, v8::Handle<v8::Function> created, v8::Handle<v8::Function> enteredView, v8::Handle<v8::Function> leftView, v8::Handle<v8::Function> attributeChanged)
 {
+    v8::Isolate* isolate = toIsolate(scriptExecutionContext);
     // A given object can only be used as a Custom Element prototype
     // once; see customElementIsInterfacePrototypeObject
 #define SET_HIDDEN_PROPERTY(Value, Name) \
-    ASSERT(prototype->GetHiddenValue(V8HiddenPropertyName::customElement##Name()).IsEmpty()); \
+    ASSERT(prototype->GetHiddenValue(V8HiddenPropertyName::customElement##Name(isolate)).IsEmpty()); \
     if (!Value.IsEmpty()) \
-        prototype->SetHiddenValue(V8HiddenPropertyName::customElement##Name(), Value);
+        prototype->SetHiddenValue(V8HiddenPropertyName::customElement##Name(isolate), Value);
 
     CALLBACK_LIST(SET_HIDDEN_PROPERTY)
 #undef SET_HIDDEN_PROPERTY
diff --git a/Source/bindings/v8/V8ErrorHandler.cpp b/Source/bindings/v8/V8ErrorHandler.cpp
index 1037f59..328378c 100644
--- a/Source/bindings/v8/V8ErrorHandler.cpp
+++ b/Source/bindings/v8/V8ErrorHandler.cpp
@@ -37,15 +37,15 @@
 #include "bindings/v8/V8HiddenPropertyName.h"
 #include "bindings/v8/V8ScriptRunner.h"
 #include "core/dom/Document.h"
-#include "core/dom/ErrorEvent.h"
-#include "core/dom/EventNames.h"
+#include "core/events/ErrorEvent.h"
+#include "core/events/EventNames.h"
 #include "core/dom/ScriptExecutionContext.h"
 #include "core/page/Frame.h"
 
 namespace WebCore {
 
-V8ErrorHandler::V8ErrorHandler(v8::Local<v8::Object> listener, bool isInline)
-    : V8EventListener(listener, isInline)
+V8ErrorHandler::V8ErrorHandler(v8::Local<v8::Object> listener, bool isInline, v8::Isolate* isolate)
+    : V8EventListener(listener, isInline, isolate)
 {
 }
 
@@ -66,7 +66,7 @@
         v8::Local<v8::Function> callFunction = v8::Local<v8::Function>::Cast(listener);
         v8::Local<v8::Object> thisValue = v8::Context::GetCurrent()->Global();
 
-        v8::Local<v8::Value> error = jsEvent->ToObject()->GetHiddenValue(V8HiddenPropertyName::error());
+        v8::Local<v8::Value> error = jsEvent->ToObject()->GetHiddenValue(V8HiddenPropertyName::error(isolate));
         if (error.IsEmpty())
             error = v8::Null(isolate);
 
@@ -87,7 +87,7 @@
     v8::Local<v8::Value> wrappedEvent = toV8(event, v8::Handle<v8::Object>(), isolate);
     if (!wrappedEvent.IsEmpty()) {
         ASSERT(wrappedEvent->IsObject());
-        v8::Local<v8::Object>::Cast(wrappedEvent)->SetHiddenValue(V8HiddenPropertyName::error(), data);
+        v8::Local<v8::Object>::Cast(wrappedEvent)->SetHiddenValue(V8HiddenPropertyName::error(isolate), data);
     }
 }
 
diff --git a/Source/bindings/v8/V8ErrorHandler.h b/Source/bindings/v8/V8ErrorHandler.h
index 92246d3..faaf430 100644
--- a/Source/bindings/v8/V8ErrorHandler.h
+++ b/Source/bindings/v8/V8ErrorHandler.h
@@ -42,15 +42,15 @@
 
 class V8ErrorHandler : public V8EventListener {
 public:
-    static PassRefPtr<V8ErrorHandler> create(v8::Local<v8::Object> listener, bool isInline)
+    static PassRefPtr<V8ErrorHandler> create(v8::Local<v8::Object> listener, bool isInline, v8::Isolate* isolate)
     {
-        return adoptRef(new V8ErrorHandler(listener, isInline));
+        return adoptRef(new V8ErrorHandler(listener, isInline, isolate));
     }
 
     static void storeExceptionOnErrorEventWrapper(ErrorEvent*, v8::Handle<v8::Value>, v8::Isolate*);
 
 private:
-    V8ErrorHandler(v8::Local<v8::Object> listener, bool isInline);
+    V8ErrorHandler(v8::Local<v8::Object> listener, bool isInline, v8::Isolate*);
 
     virtual v8::Local<v8::Value> callListenerFunction(ScriptExecutionContext*, v8::Handle<v8::Value> jsEvent, Event*);
     virtual bool shouldPreventDefault(v8::Local<v8::Value> returnValue);
diff --git a/Source/bindings/v8/V8EventListener.cpp b/Source/bindings/v8/V8EventListener.cpp
index 343654c..687e33e 100644
--- a/Source/bindings/v8/V8EventListener.cpp
+++ b/Source/bindings/v8/V8EventListener.cpp
@@ -37,8 +37,8 @@
 
 namespace WebCore {
 
-V8EventListener::V8EventListener(v8::Local<v8::Object> listener, bool isAttribute)
-    : V8AbstractEventListener(isAttribute, DOMWrapperWorld::current(), v8::Isolate::GetCurrent()) // FIXME: Remove GetCurrent().
+V8EventListener::V8EventListener(v8::Local<v8::Object> listener, bool isAttribute, v8::Isolate* isolate)
+    : V8AbstractEventListener(isAttribute, DOMWrapperWorld::current(), isolate)
 {
     setListenerObject(listener);
 }
diff --git a/Source/bindings/v8/V8EventListener.h b/Source/bindings/v8/V8EventListener.h
index 1a661f2..38ca53e 100644
--- a/Source/bindings/v8/V8EventListener.h
+++ b/Source/bindings/v8/V8EventListener.h
@@ -45,13 +45,13 @@
     // that can handle the event.
     class V8EventListener : public V8AbstractEventListener {
     public:
-        static PassRefPtr<V8EventListener> create(v8::Local<v8::Object> listener, bool isAttribute)
+        static PassRefPtr<V8EventListener> create(v8::Local<v8::Object> listener, bool isAttribute, v8::Isolate* isolate)
         {
-            return adoptRef(new V8EventListener(listener, isAttribute));
+            return adoptRef(new V8EventListener(listener, isAttribute, isolate));
         }
 
     protected:
-        V8EventListener(v8::Local<v8::Object> listener, bool isAttribute);
+        V8EventListener(v8::Local<v8::Object> listener, bool isAttribute, v8::Isolate*);
 
         v8::Local<v8::Function> getListenerFunction(ScriptExecutionContext*);
 
diff --git a/Source/bindings/v8/V8EventListenerList.cpp b/Source/bindings/v8/V8EventListenerList.cpp
index 23565ca..24eccb8 100644
--- a/Source/bindings/v8/V8EventListenerList.cpp
+++ b/Source/bindings/v8/V8EventListenerList.cpp
@@ -43,10 +43,10 @@
     if (context.IsEmpty())
         return 0;
     if (lookup == ListenerFindOnly)
-        return V8EventListenerList::findWrapper(value, isAttribute);
+        return V8EventListenerList::findWrapper(value, isAttribute, context->GetIsolate());
     if (V8DOMWrapper::isWrapperOfType(toInnerGlobalObject(context), &V8Window::info))
-        return V8EventListenerList::findOrCreateWrapper<V8EventListener>(value, isAttribute);
-    return V8EventListenerList::findOrCreateWrapper<V8WorkerGlobalScopeEventListener>(value, isAttribute);
+        return V8EventListenerList::findOrCreateWrapper<V8EventListener>(value, isAttribute, context->GetIsolate());
+    return V8EventListenerList::findOrCreateWrapper<V8WorkerGlobalScopeEventListener>(value, isAttribute, context->GetIsolate());
 }
 
 } // namespace WebCore
diff --git a/Source/bindings/v8/V8EventListenerList.h b/Source/bindings/v8/V8EventListenerList.h
index e670b2c..def9801 100644
--- a/Source/bindings/v8/V8EventListenerList.h
+++ b/Source/bindings/v8/V8EventListenerList.h
@@ -49,59 +49,59 @@
 // This is a container for V8EventListener objects that uses hidden properties of v8::Object to speed up lookups.
 class V8EventListenerList {
 public:
-    static PassRefPtr<V8EventListener> findWrapper(v8::Local<v8::Value> value, bool isAttribute)
+    static PassRefPtr<V8EventListener> findWrapper(v8::Local<v8::Value> value, bool isAttribute, v8::Isolate* isolate)
     {
         ASSERT(v8::Context::InContext());
         if (!value->IsObject())
             return 0;
 
-        v8::Handle<v8::String> wrapperProperty = getHiddenProperty(isAttribute);
-        return doFindWrapper(v8::Local<v8::Object>::Cast(value), wrapperProperty);
+        v8::Handle<v8::String> wrapperProperty = getHiddenProperty(isAttribute, isolate);
+        return doFindWrapper(v8::Local<v8::Object>::Cast(value), wrapperProperty, isolate);
     }
 
     template<typename WrapperType>
-    static PassRefPtr<V8EventListener> findOrCreateWrapper(v8::Local<v8::Value>, bool isAttribute);
+    static PassRefPtr<V8EventListener> findOrCreateWrapper(v8::Local<v8::Value>, bool isAttribute, v8::Isolate*);
 
-    static void clearWrapper(v8::Handle<v8::Object> listenerObject, bool isAttribute)
+    static void clearWrapper(v8::Handle<v8::Object> listenerObject, bool isAttribute, v8::Isolate* isolate)
     {
-        v8::Handle<v8::String> wrapperProperty = getHiddenProperty(isAttribute);
+        v8::Handle<v8::String> wrapperProperty = getHiddenProperty(isAttribute, isolate);
         listenerObject->DeleteHiddenValue(wrapperProperty);
     }
 
     static PassRefPtr<EventListener> getEventListener(v8::Local<v8::Value>, bool isAttribute, ListenerLookupType);
 
 private:
-    static V8EventListener* doFindWrapper(v8::Local<v8::Object> object, v8::Handle<v8::String> wrapperProperty)
+    static V8EventListener* doFindWrapper(v8::Local<v8::Object> object, v8::Handle<v8::String> wrapperProperty, v8::Isolate* isolate)
     {
         ASSERT(v8::Context::InContext());
-        v8::HandleScope scope(v8::Isolate::GetCurrent());
+        v8::HandleScope scope(isolate);
         v8::Local<v8::Value> listener = object->GetHiddenValue(wrapperProperty);
         if (listener.IsEmpty())
             return 0;
         return static_cast<V8EventListener*>(v8::External::Cast(*listener)->Value());
     }
 
-    static inline v8::Handle<v8::String> getHiddenProperty(bool isAttribute)
+    static inline v8::Handle<v8::String> getHiddenProperty(bool isAttribute, v8::Isolate* isolate)
     {
-        return isAttribute ? V8HiddenPropertyName::attributeListener() : V8HiddenPropertyName::listener();
+        return isAttribute ? V8HiddenPropertyName::attributeListener(isolate) : V8HiddenPropertyName::listener(isolate);
     }
 };
 
 template<typename WrapperType>
-PassRefPtr<V8EventListener> V8EventListenerList::findOrCreateWrapper(v8::Local<v8::Value> value, bool isAttribute)
+PassRefPtr<V8EventListener> V8EventListenerList::findOrCreateWrapper(v8::Local<v8::Value> value, bool isAttribute, v8::Isolate* isolate)
 {
     ASSERT(v8::Context::InContext());
     if (!value->IsObject())
         return 0;
 
     v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(value);
-    v8::Handle<v8::String> wrapperProperty = getHiddenProperty(isAttribute);
+    v8::Handle<v8::String> wrapperProperty = getHiddenProperty(isAttribute, isolate);
 
-    V8EventListener* wrapper = doFindWrapper(object, wrapperProperty);
+    V8EventListener* wrapper = doFindWrapper(object, wrapperProperty, isolate);
     if (wrapper)
         return wrapper;
 
-    RefPtr<V8EventListener> wrapperPtr = WrapperType::create(object, isAttribute);
+    RefPtr<V8EventListener> wrapperPtr = WrapperType::create(object, isAttribute, isolate);
     if (wrapperPtr)
         object->SetHiddenValue(wrapperProperty, v8::External::New(wrapperPtr.get()));
 
diff --git a/Source/bindings/v8/V8HiddenPropertyName.cpp b/Source/bindings/v8/V8HiddenPropertyName.cpp
index 2da72d3..07a9652 100644
--- a/Source/bindings/v8/V8HiddenPropertyName.cpp
+++ b/Source/bindings/v8/V8HiddenPropertyName.cpp
@@ -44,12 +44,11 @@
 #define V8_HIDDEN_PROPERTY_PREFIX "WebCore::HiddenProperty::"
 
 #define V8_DEFINE_HIDDEN_PROPERTY(name) \
-v8::Handle<v8::String> V8HiddenPropertyName::name() \
+v8::Handle<v8::String> V8HiddenPropertyName::name(v8::Isolate* isolate) \
 { \
-    v8::Isolate* isolate = v8::Isolate::GetCurrent(); \
     V8HiddenPropertyName* hiddenPropertyName = V8PerIsolateData::from(isolate)->hiddenPropertyName(); \
     if (hiddenPropertyName->m_##name.IsEmpty()) { \
-        createString(V8_HIDDEN_PROPERTY_PREFIX V8_AS_STRING(name), &(hiddenPropertyName->m_##name)); \
+        createString(V8_HIDDEN_PROPERTY_PREFIX V8_AS_STRING(name), &(hiddenPropertyName->m_##name), isolate); \
     } \
     return v8::Local<v8::String>::New(isolate, hiddenPropertyName->m_##name); \
 }
@@ -71,9 +70,8 @@
     parent->SetHiddenValue(hiddenReferenceName(name, strlen(name)), child);
 }
 
-void V8HiddenPropertyName::createString(const char* key, v8::Persistent<v8::String>* handle)
+void V8HiddenPropertyName::createString(const char* key, v8::Persistent<v8::String>* handle, v8::Isolate* isolate)
 {
-    v8::Isolate* isolate = v8::Isolate::GetCurrent();
     v8::HandleScope scope(isolate);
     handle->Reset(isolate, v8::String::NewSymbol(key));
 }
diff --git a/Source/bindings/v8/V8HiddenPropertyName.h b/Source/bindings/v8/V8HiddenPropertyName.h
index 63b7c48..066536d 100644
--- a/Source/bindings/v8/V8HiddenPropertyName.h
+++ b/Source/bindings/v8/V8HiddenPropertyName.h
@@ -64,14 +64,14 @@
 class V8HiddenPropertyName {
 public:
     V8HiddenPropertyName() { }
-#define V8_DECLARE_PROPERTY(name) static v8::Handle<v8::String> name();
+#define V8_DECLARE_PROPERTY(name) static v8::Handle<v8::String> name(v8::Isolate*);
     V8_HIDDEN_PROPERTIES(V8_DECLARE_PROPERTY);
 #undef V8_DECLARE_PROPERTY
 
     static void setNamedHiddenReference(v8::Handle<v8::Object> parent, const char* name, v8::Handle<v8::Value> child);
 
 private:
-    static void createString(const char* key, v8::Persistent<v8::String>* handle);
+    static void createString(const char* key, v8::Persistent<v8::String>* handle, v8::Isolate*);
 #define V8_DECLARE_FIELD(name) v8::Persistent<v8::String> m_##name;
     V8_HIDDEN_PROPERTIES(V8_DECLARE_FIELD);
 #undef V8_DECLARE_FIELD
diff --git a/Source/bindings/v8/V8LazyEventListener.cpp b/Source/bindings/v8/V8LazyEventListener.cpp
index f899de4..50a6e65 100644
--- a/Source/bindings/v8/V8LazyEventListener.cpp
+++ b/Source/bindings/v8/V8LazyEventListener.cpp
@@ -52,8 +52,8 @@
 
 namespace WebCore {
 
-V8LazyEventListener::V8LazyEventListener(const AtomicString& functionName, const AtomicString& eventParameterName, const String& code, const String sourceURL, const TextPosition& position, Node* node)
-    : V8AbstractEventListener(true, mainThreadNormalWorld(), v8::Isolate::GetCurrent()) // FIXME Remove GetCurrent()
+V8LazyEventListener::V8LazyEventListener(const AtomicString& functionName, const AtomicString& eventParameterName, const String& code, const String sourceURL, const TextPosition& position, Node* node, v8::Isolate* isolate)
+    : V8AbstractEventListener(true, mainThreadNormalWorld(), isolate)
     , m_functionName(functionName)
     , m_eventParameterName(eventParameterName)
     , m_code(code)
@@ -105,7 +105,7 @@
 
 static void V8LazyEventListenerToString(const v8::FunctionCallbackInfo<v8::Value>& args)
 {
-    v8SetReturnValue(args, args.Holder()->GetHiddenValue(V8HiddenPropertyName::toStringString()));
+    v8SetReturnValue(args, args.Holder()->GetHiddenValue(V8HiddenPropertyName::toStringString(args.GetIsolate())));
 }
 
 void V8LazyEventListener::prepareListenerObject(ScriptExecutionContext* context)
@@ -211,7 +211,7 @@
         toStringFunction = toStringTemplate->GetFunction();
     if (!toStringFunction.IsEmpty()) {
         String toStringString = "function " + m_functionName + "(" + m_eventParameterName + ") {\n  " + m_code + "\n}";
-        wrappedFunction->SetHiddenValue(V8HiddenPropertyName::toStringString(), v8String(toStringString, isolate));
+        wrappedFunction->SetHiddenValue(V8HiddenPropertyName::toStringString(isolate), v8String(toStringString, isolate));
         wrappedFunction->Set(v8::String::NewSymbol("toString"), toStringFunction);
     }
 
diff --git a/Source/bindings/v8/V8LazyEventListener.h b/Source/bindings/v8/V8LazyEventListener.h
index 09d3006..415d9fe 100644
--- a/Source/bindings/v8/V8LazyEventListener.h
+++ b/Source/bindings/v8/V8LazyEventListener.h
@@ -48,9 +48,9 @@
     // A V8LazyEventListener is either a HTML or SVG event handler.
     class V8LazyEventListener : public V8AbstractEventListener {
     public:
-        static PassRefPtr<V8LazyEventListener> create(const AtomicString& functionName, const AtomicString& eventParameterName, const String& code, const String& sourceURL, const TextPosition& position, Node* node)
+        static PassRefPtr<V8LazyEventListener> create(const AtomicString& functionName, const AtomicString& eventParameterName, const String& code, const String& sourceURL, const TextPosition& position, Node* node, v8::Isolate* isolate)
         {
-            return adoptRef(new V8LazyEventListener(functionName, eventParameterName, code, sourceURL, position, node));
+            return adoptRef(new V8LazyEventListener(functionName, eventParameterName, code, sourceURL, position, node, isolate));
         }
 
         virtual bool isLazy() const { return true; }
@@ -59,7 +59,7 @@
         virtual void prepareListenerObject(ScriptExecutionContext*);
 
     private:
-        V8LazyEventListener(const AtomicString& functionName, const AtomicString& eventParameterName, const String& code, const String sourceURL, const TextPosition&, Node*);
+        V8LazyEventListener(const AtomicString& functionName, const AtomicString& eventParameterName, const String& code, const String sourceURL, const TextPosition&, Node*, v8::Isolate*);
 
         virtual v8::Local<v8::Value> callListenerFunction(ScriptExecutionContext*, v8::Handle<v8::Value> jsEvent, Event*);
 
diff --git a/Source/bindings/v8/V8MutationCallback.cpp b/Source/bindings/v8/V8MutationCallback.cpp
index 950a959..bd8733d 100644
--- a/Source/bindings/v8/V8MutationCallback.cpp
+++ b/Source/bindings/v8/V8MutationCallback.cpp
@@ -42,7 +42,7 @@
     , m_world(DOMWrapperWorld::current())
     , m_isolate(isolate)
 {
-    owner->SetHiddenValue(V8HiddenPropertyName::callback(), callback);
+    owner->SetHiddenValue(V8HiddenPropertyName::callback(m_isolate), callback);
     m_callback.makeWeak(this, &makeWeakCallback);
 }
 
diff --git a/Source/bindings/v8/V8NodeFilterCondition.cpp b/Source/bindings/v8/V8NodeFilterCondition.cpp
index 94fe3ab..58e8b9b 100644
--- a/Source/bindings/v8/V8NodeFilterCondition.cpp
+++ b/Source/bindings/v8/V8NodeFilterCondition.cpp
@@ -44,7 +44,7 @@
 V8NodeFilterCondition::V8NodeFilterCondition(v8::Handle<v8::Value> filter, v8::Handle<v8::Object> owner, v8::Isolate* isolate)
     : m_filter(isolate, filter)
 {
-    owner->SetHiddenValue(V8HiddenPropertyName::condition(), filter);
+    owner->SetHiddenValue(V8HiddenPropertyName::condition(isolate), filter);
     m_filter.makeWeak(this, &makeWeakCallback);
 }
 
diff --git a/Source/bindings/v8/V8PerIsolateData.h b/Source/bindings/v8/V8PerIsolateData.h
index 82abf36..00c43d6 100644
--- a/Source/bindings/v8/V8PerIsolateData.h
+++ b/Source/bindings/v8/V8PerIsolateData.h
@@ -95,13 +95,13 @@
 
     void registerDOMDataStore(DOMDataStore* domDataStore)
     {
-        ASSERT(m_domDataList.find(domDataStore) == notFound);
+        ASSERT(m_domDataList.find(domDataStore) == kNotFound);
         m_domDataList.append(domDataStore);
     }
 
     void unregisterDOMDataStore(DOMDataStore* domDataStore)
     {
-        ASSERT(m_domDataList.find(domDataStore) != notFound);
+        ASSERT(m_domDataList.find(domDataStore) != kNotFound);
         m_domDataList.remove(m_domDataList.find(domDataStore));
     }
 
diff --git a/Source/bindings/v8/V8WindowShell.cpp b/Source/bindings/v8/V8WindowShell.cpp
index 05221c1..f68494d 100644
--- a/Source/bindings/v8/V8WindowShell.cpp
+++ b/Source/bindings/v8/V8WindowShell.cpp
@@ -362,7 +362,7 @@
     // We also stash a reference to the document on the inner global object so that
     // DOMWindow objects we obtain from JavaScript references are guaranteed to have
     // live Document objects.
-    toInnerGlobalObject(context)->SetHiddenValue(V8HiddenPropertyName::document(), documentWrapper);
+    toInnerGlobalObject(context)->SetHiddenValue(V8HiddenPropertyName::document(m_isolate), documentWrapper);
 }
 
 void V8WindowShell::clearDocumentProperty()
diff --git a/Source/bindings/v8/V8WorkerGlobalScopeEventListener.cpp b/Source/bindings/v8/V8WorkerGlobalScopeEventListener.cpp
index 74d5260..1ba0ff9 100644
--- a/Source/bindings/v8/V8WorkerGlobalScopeEventListener.cpp
+++ b/Source/bindings/v8/V8WorkerGlobalScopeEventListener.cpp
@@ -44,8 +44,8 @@
 
 namespace WebCore {
 
-V8WorkerGlobalScopeEventListener::V8WorkerGlobalScopeEventListener(v8::Local<v8::Object> listener, bool isInline)
-    : V8EventListener(listener, isInline)
+V8WorkerGlobalScopeEventListener::V8WorkerGlobalScopeEventListener(v8::Local<v8::Object> listener, bool isInline, v8::Isolate* isolate)
+    : V8EventListener(listener, isInline, isolate)
 {
 }
 
diff --git a/Source/bindings/v8/V8WorkerGlobalScopeEventListener.h b/Source/bindings/v8/V8WorkerGlobalScopeEventListener.h
index 1d88e26..571b70d 100644
--- a/Source/bindings/v8/V8WorkerGlobalScopeEventListener.h
+++ b/Source/bindings/v8/V8WorkerGlobalScopeEventListener.h
@@ -41,15 +41,15 @@
 
     class V8WorkerGlobalScopeEventListener : public V8EventListener {
     public:
-        static PassRefPtr<V8WorkerGlobalScopeEventListener> create(v8::Local<v8::Object> listener, bool isInline)
+        static PassRefPtr<V8WorkerGlobalScopeEventListener> create(v8::Local<v8::Object> listener, bool isInline, v8::Isolate* isolate)
         {
-            return adoptRef(new V8WorkerGlobalScopeEventListener(listener, isInline));
+            return adoptRef(new V8WorkerGlobalScopeEventListener(listener, isInline, isolate));
         }
 
         virtual void handleEvent(ScriptExecutionContext*, Event*);
 
     protected:
-        V8WorkerGlobalScopeEventListener(v8::Local<v8::Object> listener, bool isInline);
+        V8WorkerGlobalScopeEventListener(v8::Local<v8::Object> listener, bool isInline, v8::Isolate*);
 
     private:
         virtual v8::Local<v8::Value> callListenerFunction(ScriptExecutionContext*, v8::Handle<v8::Value> jsEvent, Event*);
diff --git a/Source/bindings/v8/WorkerScriptController.h b/Source/bindings/v8/WorkerScriptController.h
index 407a111..ce2e9e7 100644
--- a/Source/bindings/v8/WorkerScriptController.h
+++ b/Source/bindings/v8/WorkerScriptController.h
@@ -33,7 +33,7 @@
 
 #include "bindings/v8/ScriptValue.h"
 #include "bindings/v8/V8Binding.h"
-#include "core/dom/ErrorEvent.h"
+#include "core/events/ErrorEvent.h"
 #include "wtf/OwnPtr.h"
 #include "wtf/ThreadingPrimitives.h"
 #include "wtf/text/TextPosition.h"
diff --git a/Source/bindings/v8/WrapperTypeInfo.h b/Source/bindings/v8/WrapperTypeInfo.h
index d77850a..3839e5b 100644
--- a/Source/bindings/v8/WrapperTypeInfo.h
+++ b/Source/bindings/v8/WrapperTypeInfo.h
@@ -144,14 +144,14 @@
     {
         // This would be unsafe, but InternalFieldCount and GetAlignedPointerFromInternalField are guaranteed not to allocate
         const v8::Handle<v8::Object>& object = reinterpret_cast<const v8::Handle<v8::Object>&>(persistent);
-        ASSERT(object->InternalFieldCount() >= offset);
+        ASSERT(offset < object->InternalFieldCount());
         return static_cast<T*>(object->GetAlignedPointerFromInternalField(offset));
     }
 
     template<typename T, int offset>
     inline T* getInternalField(v8::Handle<v8::Object> object)
     {
-        ASSERT(object->InternalFieldCount() >= offset);
+        ASSERT(offset < object->InternalFieldCount());
         return static_cast<T*>(object->GetAlignedPointerFromInternalField(offset));
     }
 
diff --git a/Source/bindings/v8/custom/V8ArrayBufferCustom.cpp b/Source/bindings/v8/custom/V8ArrayBufferCustom.cpp
index 5074319..6e43d56 100644
--- a/Source/bindings/v8/custom/V8ArrayBufferCustom.cpp
+++ b/Source/bindings/v8/custom/V8ArrayBufferCustom.cpp
@@ -71,7 +71,6 @@
     ASSERT(!DOMDataStore::containsWrapper<V8ArrayBuffer>(impl.get(), isolate));
 
     v8::Handle<v8::Object> wrapper = v8::ArrayBuffer::New(impl->data(), impl->byteLength());
-    v8::V8::AdjustAmountOfExternalAllocatedMemory(impl->byteLength());
     impl->setDeallocationObserver(V8ArrayBufferDeallocationObserver::instance());
 
     V8DOMWrapper::associateObjectWithWrapper<V8ArrayBuffer>(impl, &info, wrapper, isolate, WrapperConfiguration::Independent);
@@ -89,10 +88,9 @@
     ASSERT(!v8buffer->IsExternal());
 
     v8::ArrayBuffer::Contents v8Contents = v8buffer->Externalize();
-    ArrayBufferContents contents(v8Contents.Data(), v8Contents.ByteLength());
+    ArrayBufferContents contents(v8Contents.Data(), v8Contents.ByteLength(),
+        V8ArrayBufferDeallocationObserver::instance());
     RefPtr<ArrayBuffer> buffer = ArrayBuffer::create(contents);
-    // V8 accounts for external memory even after externalizing the buffer.
-    buffer->setDeallocationObserver(V8ArrayBufferDeallocationObserver::instance());
     V8DOMWrapper::associateObjectWithWrapper<V8ArrayBuffer>(buffer.release(), &info, object, v8::Isolate::GetCurrent(), WrapperConfiguration::Dependent);
 
     arraybufferPtr = object->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex);
diff --git a/Source/bindings/v8/custom/V8ArrayBufferCustom.h b/Source/bindings/v8/custom/V8ArrayBufferCustom.h
index a4ee565..484b390 100644
--- a/Source/bindings/v8/custom/V8ArrayBufferCustom.h
+++ b/Source/bindings/v8/custom/V8ArrayBufferCustom.h
@@ -36,11 +36,17 @@
 
 class V8ArrayBufferDeallocationObserver: public WTF::ArrayBufferDeallocationObserver {
 public:
-    virtual void ArrayBufferDeallocated(unsigned sizeInBytes)
+    virtual void arrayBufferDeallocated(unsigned sizeInBytes)
     {
         v8::V8::AdjustAmountOfExternalAllocatedMemory(-static_cast<int>(sizeInBytes));
     }
     static V8ArrayBufferDeallocationObserver* instance();
+
+protected:
+    virtual void blinkAllocatedMemory(unsigned sizeInBytes) OVERRIDE
+    {
+        v8::V8::AdjustAmountOfExternalAllocatedMemory(static_cast<int>(sizeInBytes));
+    }
 };
 
 class V8ArrayBuffer {
diff --git a/Source/bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp b/Source/bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp
index f81cd92..143acdf 100644
--- a/Source/bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp
+++ b/Source/bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp
@@ -38,7 +38,7 @@
 #include "core/css/CSSPrimitiveValue.h"
 #include "core/css/CSSStyleDeclaration.h"
 #include "core/css/CSSValue.h"
-#include "core/dom/EventTarget.h"
+#include "core/events/EventTarget.h"
 #include "core/page/RuntimeCSSEnabled.h"
 #include "wtf/ASCIICType.h"
 #include "wtf/PassRefPtr.h"
diff --git a/Source/bindings/v8/custom/V8CustomEventCustom.cpp b/Source/bindings/v8/custom/V8CustomEventCustom.cpp
index 5b5d0ff..e5c8f60 100644
--- a/Source/bindings/v8/custom/V8CustomEventCustom.cpp
+++ b/Source/bindings/v8/custom/V8CustomEventCustom.cpp
@@ -43,9 +43,9 @@
 
 namespace WebCore {
 
-static v8::Handle<v8::Value> cacheState(v8::Handle<v8::Object> customEvent, v8::Handle<v8::Value> detail)
+static v8::Handle<v8::Value> cacheState(v8::Handle<v8::Object> customEvent, v8::Handle<v8::Value> detail, v8::Isolate* isolate)
 {
-    customEvent->SetHiddenValue(V8HiddenPropertyName::detail(), detail);
+    customEvent->SetHiddenValue(V8HiddenPropertyName::detail(isolate), detail);
     return detail;
 }
 
@@ -54,7 +54,7 @@
 {
     CustomEvent* event = V8CustomEvent::toNative(info.Holder());
 
-    v8::Handle<v8::Value> result = info.Holder()->GetHiddenValue(V8HiddenPropertyName::detail());
+    v8::Handle<v8::Value> result = info.Holder()->GetHiddenValue(V8HiddenPropertyName::detail(info.GetIsolate()));
 
     if (!result.IsEmpty()) {
         v8SetReturnValue(info, result);
@@ -64,18 +64,18 @@
     if (!event->serializedDetail()) {
         // If we're in an isolated world and the event was created in the main world,
         // we need to find the 'detail' property on the main world wrapper and clone it.
-        v8::Local<v8::Value> mainWorldDetail = getHiddenValueFromMainWorldWrapper(info.GetIsolate(), event, V8HiddenPropertyName::detail());
+        v8::Local<v8::Value> mainWorldDetail = getHiddenValueFromMainWorldWrapper(info.GetIsolate(), event, V8HiddenPropertyName::detail(info.GetIsolate()));
         if (!mainWorldDetail.IsEmpty())
             event->setSerializedDetail(SerializedScriptValue::createAndSwallowExceptions(mainWorldDetail, info.GetIsolate()));
     }
 
     if (event->serializedDetail()) {
         result = event->serializedDetail()->deserialize();
-        v8SetReturnValue(info, cacheState(info.Holder(), result));
+        v8SetReturnValue(info, cacheState(info.Holder(), result, info.GetIsolate()));
         return;
     }
 
-    v8SetReturnValue(info, cacheState(info.Holder(), v8::Null(info.GetIsolate())));
+    v8SetReturnValue(info, cacheState(info.Holder(), v8::Null(info.GetIsolate()), info.GetIsolate()));
 }
 
 void V8CustomEvent::initCustomEventMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
@@ -91,7 +91,7 @@
     event->initEvent(typeArg, canBubbleArg, cancelableArg);
 
     if (!detailsArg.IsEmpty()) {
-        args.Holder()->SetHiddenValue(V8HiddenPropertyName::detail(), detailsArg);
+        args.Holder()->SetHiddenValue(V8HiddenPropertyName::detail(args.GetIsolate()), detailsArg);
         if (isolatedWorldForIsolate(args.GetIsolate()))
             event->setSerializedDetail(SerializedScriptValue::createAndSwallowExceptions(detailsArg, args.GetIsolate()));
     }
diff --git a/Source/bindings/v8/custom/V8ErrorEventCustom.cpp b/Source/bindings/v8/custom/V8ErrorEventCustom.cpp
index 98374aa..b574a22 100644
--- a/Source/bindings/v8/custom/V8ErrorEventCustom.cpp
+++ b/Source/bindings/v8/custom/V8ErrorEventCustom.cpp
@@ -46,7 +46,7 @@
 
 void V8ErrorEvent::errorAttributeGetterCustom(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
 {
-    v8::Handle<v8::Value> error = info.Holder()->GetHiddenValue(V8HiddenPropertyName::error());
+    v8::Handle<v8::Value> error = info.Holder()->GetHiddenValue(V8HiddenPropertyName::error(info.GetIsolate()));
 
     if (!error.IsEmpty()) {
         v8SetReturnValue(info, error);
diff --git a/Source/bindings/v8/custom/V8EventCustom.cpp b/Source/bindings/v8/custom/V8EventCustom.cpp
index 954af4a..f2132b0 100644
--- a/Source/bindings/v8/custom/V8EventCustom.cpp
+++ b/Source/bindings/v8/custom/V8EventCustom.cpp
@@ -36,9 +36,9 @@
 #include "V8Clipboard.h"
 #include "bindings/v8/V8Binding.h"
 #include "core/dom/Clipboard.h"
-#include "core/dom/ClipboardEvent.h"
-#include "core/dom/Event.h"
-#include "core/dom/EventNames.h"
+#include "core/events/ClipboardEvent.h"
+#include "core/events/Event.h"
+#include "core/events/EventNames.h"
 
 namespace WebCore {
 
diff --git a/Source/bindings/v8/custom/V8HTMLAllCollectionCustom.cpp b/Source/bindings/v8/custom/V8HTMLAllCollectionCustom.cpp
index 4e12f78..35458ff 100644
--- a/Source/bindings/v8/custom/V8HTMLAllCollectionCustom.cpp
+++ b/Source/bindings/v8/custom/V8HTMLAllCollectionCustom.cpp
@@ -36,6 +36,7 @@
 #include "bindings/v8/V8Binding.h"
 #include "core/dom/NamedNodesCollection.h"
 #include "core/html/HTMLAllCollection.h"
+#include "core/page/UseCounter.h"
 
 namespace WebCore {
 
@@ -101,6 +102,10 @@
         return;
 
     HTMLAllCollection* imp = V8HTMLAllCollection::toNative(args.Holder());
+    Node* ownerNode = imp->ownerNode();
+    ASSERT(ownerNode);
+
+    UseCounter::count(&ownerNode->document(), UseCounter::DocumentAllLegacyCall);
 
     if (args.Length() == 1) {
         v8SetReturnValue(args, getItem(imp, args[0], args));
diff --git a/Source/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp b/Source/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp
index 22658c3..3e488fc 100644
--- a/Source/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp
+++ b/Source/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp
@@ -86,7 +86,7 @@
         bool ok;
         V8TRYCATCH_VOID(int, index, toInt32(args[1], ok));
         if (!ok)
-            es.throwDOMException(TypeMismatchError);
+            es.throwUninformativeAndGenericDOMException(TypeMismatchError);
         else
             imp->add(option, index, es);
     }
@@ -102,7 +102,7 @@
     ExceptionState es(info.GetIsolate());
     if (!std::isnan(v) && !std::isinf(v)) {
         if (v < 0.0)
-            es.throwDOMException(IndexSizeError);
+            es.throwUninformativeAndGenericDOMException(IndexSizeError);
         else if (v > static_cast<double>(UINT_MAX))
             newLength = UINT_MAX;
         else
diff --git a/Source/bindings/v8/custom/V8HTMLPlugInElementCustom.cpp b/Source/bindings/v8/custom/V8HTMLPlugInElementCustom.cpp
index 4dd9b8c..34e00cf 100644
--- a/Source/bindings/v8/custom/V8HTMLPlugInElementCustom.cpp
+++ b/Source/bindings/v8/custom/V8HTMLPlugInElementCustom.cpp
@@ -36,6 +36,7 @@
 #include "bindings/v8/ScriptInstance.h"
 #include "bindings/v8/V8Binding.h"
 #include "bindings/v8/V8NPObject.h"
+#include "core/page/UseCounter.h"
 
 namespace WebCore {
 
@@ -104,16 +105,22 @@
 
 void V8HTMLAppletElement::legacyCallCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
 {
+    HTMLPlugInElement* imp = V8HTMLAppletElement::toNative(args.Holder());
+    UseCounter::count(&imp->document(), UseCounter::HTMLAppletElementLegacyCall);
     npObjectInvokeDefaultHandler(args);
 }
 
 void V8HTMLEmbedElement::legacyCallCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
 {
+    HTMLPlugInElement* imp = V8HTMLEmbedElement::toNative(args.Holder());
+    UseCounter::count(&imp->document(), UseCounter::HTMLEmbedElementLegacyCall);
     npObjectInvokeDefaultHandler(args);
 }
 
 void V8HTMLObjectElement::legacyCallCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
 {
+    HTMLPlugInElement* imp = V8HTMLObjectElement::toNative(args.Holder());
+    UseCounter::count(&imp->document(), UseCounter::HTMLObjectElementLegacyCall);
     npObjectInvokeDefaultHandler(args);
 }
 
diff --git a/Source/bindings/v8/custom/V8HistoryCustom.cpp b/Source/bindings/v8/custom/V8HistoryCustom.cpp
index 4fa07e0..0300b0c 100644
--- a/Source/bindings/v8/custom/V8HistoryCustom.cpp
+++ b/Source/bindings/v8/custom/V8HistoryCustom.cpp
@@ -45,7 +45,7 @@
 {
     History* history = V8History::toNative(info.Holder());
 
-    v8::Handle<v8::Value> value = info.Holder()->GetHiddenValue(V8HiddenPropertyName::state());
+    v8::Handle<v8::Value> value = info.Holder()->GetHiddenValue(V8HiddenPropertyName::state(info.GetIsolate()));
 
     if (!value.IsEmpty() && !history->stateChanged()) {
         v8SetReturnValue(info, value);
@@ -54,7 +54,7 @@
 
     RefPtr<SerializedScriptValue> serialized = history->state();
     value = serialized ? serialized->deserialize(info.GetIsolate()) : v8::Handle<v8::Value>(v8::Null(info.GetIsolate()));
-    info.Holder()->SetHiddenValue(V8HiddenPropertyName::state(), value);
+    info.Holder()->SetHiddenValue(V8HiddenPropertyName::state(info.GetIsolate()), value);
 
     v8SetReturnValue(info, value);
 }
@@ -72,7 +72,7 @@
     ExceptionState es(args.GetIsolate());
     History* history = V8History::toNative(args.Holder());
     history->stateObjectAdded(historyState.release(), title, url, SameDocumentNavigationPushState, es);
-    args.Holder()->DeleteHiddenValue(V8HiddenPropertyName::state());
+    args.Holder()->DeleteHiddenValue(V8HiddenPropertyName::state(args.GetIsolate()));
     es.throwIfNeeded();
 }
 
@@ -89,7 +89,7 @@
     ExceptionState es(args.GetIsolate());
     History* history = V8History::toNative(args.Holder());
     history->stateObjectAdded(historyState.release(), title, url, SameDocumentNavigationReplaceState, es);
-    args.Holder()->DeleteHiddenValue(V8HiddenPropertyName::state());
+    args.Holder()->DeleteHiddenValue(V8HiddenPropertyName::state(args.GetIsolate()));
     es.throwIfNeeded();
 }
 
diff --git a/Source/bindings/v8/custom/V8InspectorFrontendHostCustom.cpp b/Source/bindings/v8/custom/V8InspectorFrontendHostCustom.cpp
index 04b46fb..d0870df 100644
--- a/Source/bindings/v8/custom/V8InspectorFrontendHostCustom.cpp
+++ b/Source/bindings/v8/custom/V8InspectorFrontendHostCustom.cpp
@@ -45,16 +45,10 @@
 {
 #if OS(MACOSX)
     v8SetReturnValue(args, v8::String::NewSymbol("mac"));
-#elif OS(LINUX)
-    v8SetReturnValue(args, v8::String::NewSymbol("linux"));
-#elif OS(FREEBSD)
-    v8SetReturnValue(args, v8::String::NewSymbol("freebsd"));
-#elif OS(OPENBSD)
-    v8SetReturnValue(args, v8::String::NewSymbol("openbsd"));
 #elif OS(WIN)
     v8SetReturnValue(args, v8::String::NewSymbol("windows"));
-#else
-    v8SetReturnValue(args, v8::String::NewSymbol("unknown"));
+#else // Unix-like systems
+    v8SetReturnValue(args, v8::String::NewSymbol("linux"));
 #endif
 }
 
diff --git a/Source/bindings/v8/custom/V8MessageEventCustom.cpp b/Source/bindings/v8/custom/V8MessageEventCustom.cpp
index 24e91cc..21c4f0e 100644
--- a/Source/bindings/v8/custom/V8MessageEventCustom.cpp
+++ b/Source/bindings/v8/custom/V8MessageEventCustom.cpp
@@ -38,7 +38,7 @@
 #include "bindings/v8/V8Binding.h"
 #include "bindings/v8/V8HiddenPropertyName.h"
 #include "bindings/v8/custom/V8ArrayBufferCustom.h"
-#include "core/dom/MessageEvent.h"
+#include "core/events/MessageEvent.h"
 
 namespace WebCore {
 
@@ -49,12 +49,12 @@
     v8::Handle<v8::Value> result;
     switch (event->dataType()) {
     case MessageEvent::DataTypeScriptValue: {
-        result = info.Holder()->GetHiddenValue(V8HiddenPropertyName::data());
+        result = info.Holder()->GetHiddenValue(V8HiddenPropertyName::data(info.GetIsolate()));
         if (result.IsEmpty()) {
             if (!event->dataAsSerializedScriptValue()) {
                 // If we're in an isolated world and the event was created in the main world,
                 // we need to find the 'data' property on the main world wrapper and clone it.
-                v8::Local<v8::Value> mainWorldData = getHiddenValueFromMainWorldWrapper(info.GetIsolate(), event, V8HiddenPropertyName::data());
+                v8::Local<v8::Value> mainWorldData = getHiddenValueFromMainWorldWrapper(info.GetIsolate(), event, V8HiddenPropertyName::data(info.GetIsolate()));
                 if (!mainWorldData.IsEmpty())
                     event->setSerializedData(SerializedScriptValue::createAndSwallowExceptions(mainWorldData, info.GetIsolate()));
             }
@@ -124,7 +124,7 @@
     event->initMessageEvent(typeArg, canBubbleArg, cancelableArg, originArg, lastEventIdArg, sourceArg, portArray.release());
 
     if (!dataArg.IsEmpty()) {
-        args.Holder()->SetHiddenValue(V8HiddenPropertyName::data(), dataArg);
+        args.Holder()->SetHiddenValue(V8HiddenPropertyName::data(args.GetIsolate()), dataArg);
         if (isolatedWorldForIsolate(args.GetIsolate()))
             event->setSerializedData(SerializedScriptValue::createAndSwallowExceptions(dataArg, args.GetIsolate()));
     }
diff --git a/Source/bindings/v8/custom/V8NodeCustom.cpp b/Source/bindings/v8/custom/V8NodeCustom.cpp
index 23a5996..ff02372 100644
--- a/Source/bindings/v8/custom/V8NodeCustom.cpp
+++ b/Source/bindings/v8/custom/V8NodeCustom.cpp
@@ -51,7 +51,7 @@
 #include "bindings/v8/V8EventListener.h"
 #include "core/dom/CustomElementCallbackDispatcher.h"
 #include "core/dom/Document.h"
-#include "core/dom/EventListener.h"
+#include "core/events/EventListener.h"
 #include "core/dom/shadow/ShadowRoot.h"
 #include "wtf/RefPtr.h"
 
diff --git a/Source/bindings/v8/custom/V8PopStateEventCustom.cpp b/Source/bindings/v8/custom/V8PopStateEventCustom.cpp
index 6eee6c1..0c6c1c6 100644
--- a/Source/bindings/v8/custom/V8PopStateEventCustom.cpp
+++ b/Source/bindings/v8/custom/V8PopStateEventCustom.cpp
@@ -34,21 +34,21 @@
 #include "V8History.h"
 #include "bindings/v8/SerializedScriptValue.h"
 #include "bindings/v8/V8HiddenPropertyName.h"
-#include "core/dom/PopStateEvent.h"
+#include "core/events/PopStateEvent.h"
 #include "core/page/History.h"
 
 namespace WebCore {
 
 // Save the state value to a hidden attribute in the V8PopStateEvent, and return it, for convenience.
-static v8::Handle<v8::Value> cacheState(v8::Handle<v8::Object> popStateEvent, v8::Handle<v8::Value> state)
+static v8::Handle<v8::Value> cacheState(v8::Handle<v8::Object> popStateEvent, v8::Handle<v8::Value> state, v8::Isolate* isolate)
 {
-    popStateEvent->SetHiddenValue(V8HiddenPropertyName::state(), state);
+    popStateEvent->SetHiddenValue(V8HiddenPropertyName::state(isolate), state);
     return state;
 }
 
 void V8PopStateEvent::stateAttributeGetterCustom(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
 {
-    v8::Handle<v8::Value> result = info.Holder()->GetHiddenValue(V8HiddenPropertyName::state());
+    v8::Handle<v8::Value> result = info.Holder()->GetHiddenValue(V8HiddenPropertyName::state(info.GetIsolate()));
 
     if (!result.IsEmpty()) {
         v8SetReturnValue(info, result);
@@ -61,7 +61,7 @@
         if (!event->serializedState()) {
             // If we're in an isolated world and the event was created in the main world,
             // we need to find the 'state' property on the main world wrapper and clone it.
-            v8::Local<v8::Value> mainWorldState = getHiddenValueFromMainWorldWrapper(info.GetIsolate(), event, V8HiddenPropertyName::state());
+            v8::Local<v8::Value> mainWorldState = getHiddenValueFromMainWorldWrapper(info.GetIsolate(), event, V8HiddenPropertyName::state(info.GetIsolate()));
             if (!mainWorldState.IsEmpty())
                 event->setSerializedState(SerializedScriptValue::createAndSwallowExceptions(mainWorldState, info.GetIsolate()));
         }
@@ -69,7 +69,7 @@
             result = event->serializedState()->deserialize();
         else
             result = v8::Null(info.GetIsolate());
-        v8SetReturnValue(info, cacheState(info.Holder(), result));
+        v8SetReturnValue(info, cacheState(info.Holder(), result, info.GetIsolate()));
         return;
     }
 
@@ -84,19 +84,19 @@
     if (isSameState) {
         v8::Handle<v8::Object> v8History = toV8(history, info.Holder(), info.GetIsolate()).As<v8::Object>();
         if (!history->stateChanged()) {
-            result = v8History->GetHiddenValue(V8HiddenPropertyName::state());
+            result = v8History->GetHiddenValue(V8HiddenPropertyName::state(info.GetIsolate()));
             if (!result.IsEmpty()) {
-                v8SetReturnValue(info, cacheState(info.Holder(), result));
+                v8SetReturnValue(info, cacheState(info.Holder(), result, info.GetIsolate()));
                 return;
             }
         }
         result = event->serializedState()->deserialize(info.GetIsolate());
-        v8History->SetHiddenValue(V8HiddenPropertyName::state(), result);
+        v8History->SetHiddenValue(V8HiddenPropertyName::state(info.GetIsolate()), result);
     } else {
         result = event->serializedState()->deserialize(info.GetIsolate());
     }
 
-    v8SetReturnValue(info, cacheState(info.Holder(), result));
+    v8SetReturnValue(info, cacheState(info.Holder(), result, info.GetIsolate()));
 }
 
 } // namespace WebCore
diff --git a/Source/bindings/v8/custom/V8PromiseCustom.cpp b/Source/bindings/v8/custom/V8PromiseCustom.cpp
index c9dbdb7..a0b7cbf 100644
--- a/Source/bindings/v8/custom/V8PromiseCustom.cpp
+++ b/Source/bindings/v8/custom/V8PromiseCustom.cpp
@@ -32,7 +32,6 @@
 #include "bindings/v8/custom/V8PromiseCustom.h"
 
 #include "V8Promise.h"
-#include "V8PromiseResolver.h"
 #include "bindings/v8/ScopedPersistent.h"
 #include "bindings/v8/ScriptFunctionCall.h"
 #include "bindings/v8/ScriptState.h"
@@ -157,7 +156,6 @@
         result = args[0];
 
     v8::Local<v8::Object> promise = environment->GetInternalField(V8PromiseCustom::WrapperCallbackEnvironmentPromiseIndex).As<v8::Object>();
-    v8::Local<v8::Object> resolver = environment->GetInternalField(V8PromiseCustom::WrapperCallbackEnvironmentPromiseResolverIndex).As<v8::Object>();
     v8::Local<v8::Function> callback = environment->GetInternalField(V8PromiseCustom::WrapperCallbackEnvironmentCallbackIndex).As<v8::Function>();
 
     v8::Local<v8::Value> argv[] = {
@@ -166,18 +164,17 @@
     v8::TryCatch trycatch;
     result = V8ScriptRunner::callFunction(callback, getScriptExecutionContext(), promise, WTF_ARRAY_LENGTH(argv), argv, isolate);
     if (result.IsEmpty()) {
-        V8PromiseCustom::rejectResolver(resolver, trycatch.Exception(), V8PromiseCustom::Synchronous, isolate);
+        V8PromiseCustom::reject(promise, trycatch.Exception(), V8PromiseCustom::Synchronous, isolate);
         return;
     }
-    V8PromiseCustom::resolveResolver(resolver, result, V8PromiseCustom::Synchronous, isolate);
+    V8PromiseCustom::resolve(promise, result, V8PromiseCustom::Synchronous, isolate);
 }
 
-v8::Local<v8::Object> wrapperCallbackEnvironment(v8::Handle<v8::Object> promise, v8::Handle<v8::Object> resolver, v8::Handle<v8::Function> callback, v8::Isolate* isolate)
+v8::Local<v8::Object> wrapperCallbackEnvironment(v8::Handle<v8::Object> promise, v8::Handle<v8::Function> callback, v8::Isolate* isolate)
 {
     v8::Local<v8::ObjectTemplate> objectTemplate = wrapperCallbackEnvironmentObjectTemplate(isolate);
     v8::Local<v8::Object> environment = objectTemplate->NewInstance();
     environment->SetInternalField(V8PromiseCustom::WrapperCallbackEnvironmentPromiseIndex, promise);
-    environment->SetInternalField(V8PromiseCustom::WrapperCallbackEnvironmentPromiseResolverIndex, resolver);
     environment->SetInternalField(V8PromiseCustom::WrapperCallbackEnvironmentCallbackIndex, callback);
     return environment;
 }
@@ -185,34 +182,34 @@
 void promiseFulfillCallback(const v8::FunctionCallbackInfo<v8::Value>& args)
 {
     ASSERT(!args.Data().IsEmpty());
-    v8::Local<v8::Object> resolver = args.Data().As<v8::Object>();
+    v8::Local<v8::Object> promise = args.Data().As<v8::Object>();
     v8::Local<v8::Value> result = v8::Undefined(args.GetIsolate());
     if (args.Length() > 0)
         result = args[0];
 
-    V8PromiseCustom::fulfillResolver(resolver, result, V8PromiseCustom::Synchronous, args.GetIsolate());
+    V8PromiseCustom::fulfill(promise, result, V8PromiseCustom::Synchronous, args.GetIsolate());
 }
 
 void promiseResolveCallback(const v8::FunctionCallbackInfo<v8::Value>& args)
 {
     ASSERT(!args.Data().IsEmpty());
-    v8::Local<v8::Object> resolver = args.Data().As<v8::Object>();
+    v8::Local<v8::Object> promise = args.Data().As<v8::Object>();
     v8::Local<v8::Value> result = v8::Undefined(args.GetIsolate());
     if (args.Length() > 0)
         result = args[0];
 
-    V8PromiseCustom::resolveResolver(resolver, result, V8PromiseCustom::Synchronous, args.GetIsolate());
+    V8PromiseCustom::resolve(promise, result, V8PromiseCustom::Synchronous, args.GetIsolate());
 }
 
 void promiseRejectCallback(const v8::FunctionCallbackInfo<v8::Value>& args)
 {
     ASSERT(!args.Data().IsEmpty());
-    v8::Local<v8::Object> resolver = args.Data().As<v8::Object>();
+    v8::Local<v8::Object> promise = args.Data().As<v8::Object>();
     v8::Local<v8::Value> result = v8::Undefined(args.GetIsolate());
     if (args.Length() > 0)
         result = args[0];
 
-    V8PromiseCustom::rejectResolver(resolver, result, V8PromiseCustom::Synchronous, args.GetIsolate());
+    V8PromiseCustom::reject(promise, result, V8PromiseCustom::Synchronous, args.GetIsolate());
 }
 
 void callCallbacks(v8::Handle<v8::Array> callbacks, v8::Handle<v8::Value> result, V8PromiseCustom::SynchronousMode mode, v8::Isolate* isolate)
@@ -234,7 +231,7 @@
     if (args.Length() > 0)
         result = args[0];
 
-    v8::Local<v8::Object> resolver = environment->GetInternalField(V8PromiseCustom::PromiseEveryEnvironmentPromiseResolverIndex).As<v8::Object>();
+    v8::Local<v8::Object> promise = environment->GetInternalField(V8PromiseCustom::PromiseEveryEnvironmentPromiseIndex).As<v8::Object>();
     v8::Local<v8::Object> countdownWrapper = environment->GetInternalField(V8PromiseCustom::PromiseEveryEnvironmentCountdownIndex).As<v8::Object>();
     v8::Local<v8::Integer> index = environment->GetInternalField(V8PromiseCustom::PromiseEveryEnvironmentIndexIndex).As<v8::Integer>();
     v8::Local<v8::Array> results = environment->GetInternalField(V8PromiseCustom::PromiseEveryEnvironmentResultsIndex).As<v8::Array>();
@@ -244,49 +241,56 @@
     v8::Local<v8::Integer> countdown = countdownWrapper->GetInternalField(V8PromiseCustom::PrimitiveWrapperPrimitiveIndex).As<v8::Integer>();
     ASSERT(countdown->Value() >= 1);
     if (countdown->Value() == 1) {
-        V8PromiseCustom::resolveResolver(resolver, results, V8PromiseCustom::Synchronous, isolate);
+        V8PromiseCustom::resolve(promise, results, V8PromiseCustom::Synchronous, isolate);
         return;
     }
     countdownWrapper->SetInternalField(V8PromiseCustom::PrimitiveWrapperPrimitiveIndex, v8::Integer::New(countdown->Value() - 1, isolate));
 }
 
-void promiseSomeRejectCallback(const v8::FunctionCallbackInfo<v8::Value>& args)
-{
-    v8::Isolate* isolate = args.GetIsolate();
-    ASSERT(!args.Data().IsEmpty());
-    v8::Local<v8::Object> environment = args.Data().As<v8::Object>();
-    v8::Local<v8::Value> result = v8::Undefined(isolate);
-    if (args.Length() > 0)
-        result = args[0];
-
-    v8::Local<v8::Object> resolver = environment->GetInternalField(V8PromiseCustom::PromiseEveryEnvironmentPromiseResolverIndex).As<v8::Object>();
-    v8::Local<v8::Object> countdownWrapper = environment->GetInternalField(V8PromiseCustom::PromiseEveryEnvironmentCountdownIndex).As<v8::Object>();
-    v8::Local<v8::Integer> index = environment->GetInternalField(V8PromiseCustom::PromiseEveryEnvironmentIndexIndex).As<v8::Integer>();
-    v8::Local<v8::Array> results = environment->GetInternalField(V8PromiseCustom::PromiseEveryEnvironmentResultsIndex).As<v8::Array>();
-
-    results->Set(index->Value(), result);
-
-    v8::Local<v8::Integer> countdown = countdownWrapper->GetInternalField(V8PromiseCustom::PrimitiveWrapperPrimitiveIndex).As<v8::Integer>();
-    ASSERT(countdown->Value() >= 1);
-    if (countdown->Value() == 1) {
-        V8PromiseCustom::rejectResolver(resolver, results, V8PromiseCustom::Synchronous, isolate);
-        return;
-    }
-    countdownWrapper->SetInternalField(V8PromiseCustom::PrimitiveWrapperPrimitiveIndex, v8::Integer::New(countdown->Value() - 1, isolate));
-}
-
-v8::Local<v8::Object> promiseEveryEnvironment(v8::Handle<v8::Object> resolver, v8::Handle<v8::Object> countdownWrapper, int index, v8::Handle<v8::Array> results, v8::Isolate* isolate)
+v8::Local<v8::Object> promiseEveryEnvironment(v8::Handle<v8::Object> promise, v8::Handle<v8::Object> countdownWrapper, int index, v8::Handle<v8::Array> results, v8::Isolate* isolate)
 {
     v8::Local<v8::ObjectTemplate> objectTemplate = promiseEveryEnvironmentObjectTemplate(isolate);
     v8::Local<v8::Object> environment = objectTemplate->NewInstance();
 
-    environment->SetInternalField(V8PromiseCustom::PromiseEveryEnvironmentPromiseResolverIndex, resolver);
+    environment->SetInternalField(V8PromiseCustom::PromiseEveryEnvironmentPromiseIndex, promise);
     environment->SetInternalField(V8PromiseCustom::PromiseEveryEnvironmentCountdownIndex, countdownWrapper);
     environment->SetInternalField(V8PromiseCustom::PromiseEveryEnvironmentIndexIndex, v8::Integer::New(index, isolate));
     environment->SetInternalField(V8PromiseCustom::PromiseEveryEnvironmentResultsIndex, results);
     return environment;
 }
 
+void promiseResolve(const v8::FunctionCallbackInfo<v8::Value>& args)
+{
+    v8::Local<v8::Object> promise = args.Data().As<v8::Object>();
+    ASSERT(!promise.IsEmpty());
+    v8::Local<v8::Object> internal = V8PromiseCustom::getInternal(promise);
+    if (V8PromiseCustom::getState(internal) != V8PromiseCustom::Pending)
+        return;
+    v8::Isolate* isolate = args.GetIsolate();
+    V8PromiseCustom::setState(V8PromiseCustom::getInternal(promise), V8PromiseCustom::Following, isolate);
+
+    v8::Local<v8::Value> result = v8::Undefined(isolate);
+    if (args.Length() > 0)
+        result = args[0];
+    V8PromiseCustom::resolve(promise, result, V8PromiseCustom::Asynchronous, isolate);
+}
+
+void promiseReject(const v8::FunctionCallbackInfo<v8::Value>& args)
+{
+    v8::Local<v8::Object> promise = args.Data().As<v8::Object>();
+    ASSERT(!promise.IsEmpty());
+    v8::Local<v8::Object> internal = V8PromiseCustom::getInternal(promise);
+    if (V8PromiseCustom::getState(internal) != V8PromiseCustom::Pending)
+        return;
+    v8::Isolate* isolate = args.GetIsolate();
+    V8PromiseCustom::setState(V8PromiseCustom::getInternal(promise), V8PromiseCustom::Following, isolate);
+
+    v8::Local<v8::Value> result = v8::Undefined(isolate);
+    if (args.Length() > 0)
+        result = args[0];
+    V8PromiseCustom::reject(promise, result, V8PromiseCustom::Asynchronous, isolate);
+}
+
 } // namespace
 
 void V8Promise::constructorCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
@@ -298,16 +302,16 @@
         return;
     }
     v8::Local<v8::Function> init = args[0].As<v8::Function>();
-    v8::Local<v8::Object> promise, resolver;
-    V8PromiseCustom::createPromise(args.Holder(), &promise, &resolver, isolate);
+    v8::Local<v8::Object> promise = V8PromiseCustom::createPromise(args.Holder(), isolate);
     v8::Handle<v8::Value> argv[] = {
-        resolver,
+        createClosure(promiseResolve, promise, isolate),
+        createClosure(promiseReject, promise, isolate)
     };
     v8::TryCatch trycatch;
     if (V8ScriptRunner::callFunction(init, getScriptExecutionContext(), promise, WTF_ARRAY_LENGTH(argv), argv, isolate).IsEmpty()) {
         // An exception is thrown. Reject the promise if its resolved flag is unset.
-        if (!V8PromiseCustom::isInternalDetached(resolver) && V8PromiseCustom::getState(V8PromiseCustom::getInternal(resolver)) == V8PromiseCustom::Pending)
-            V8PromiseCustom::rejectResolver(resolver, trycatch.Exception(), V8PromiseCustom::Asynchronous, isolate);
+        if (V8PromiseCustom::getState(V8PromiseCustom::getInternal(promise)) == V8PromiseCustom::Pending)
+            V8PromiseCustom::reject(promise, trycatch.Exception(), V8PromiseCustom::Asynchronous, isolate);
     }
     v8SetReturnValue(args, promise);
     return;
@@ -317,25 +321,24 @@
 {
     v8::Isolate* isolate = args.GetIsolate();
     v8::Local<v8::Function> fulfillWrapper, rejectWrapper;
-    v8::Local<v8::Object> promise, resolver;
-    V8PromiseCustom::createPromise(args.Holder(), &promise, &resolver, isolate);
+    v8::Local<v8::Object> promise = V8PromiseCustom::createPromise(args.Holder(), isolate);
     if (args.Length() > 0 && !args[0]->IsUndefined()) {
         if (!args[0]->IsFunction()) {
             v8SetReturnValue(args, throwTypeError("fulfillCallback must be a function or undefined", isolate));
             return;
         }
-        fulfillWrapper = createClosure(wrapperCallback, wrapperCallbackEnvironment(promise, resolver, args[0].As<v8::Function>(), isolate));
+        fulfillWrapper = createClosure(wrapperCallback, wrapperCallbackEnvironment(promise, args[0].As<v8::Function>(), isolate), isolate);
     } else {
-        fulfillWrapper = createClosure(promiseFulfillCallback, resolver);
+        fulfillWrapper = createClosure(promiseFulfillCallback, promise, isolate);
     }
     if (args.Length() > 1 && !args[1]->IsUndefined()) {
         if (!args[1]->IsFunction()) {
             v8SetReturnValue(args, throwTypeError("rejectCallback must be a function or undefined", isolate));
             return;
         }
-        rejectWrapper = createClosure(wrapperCallback, wrapperCallbackEnvironment(promise, resolver, args[1].As<v8::Function>(), isolate));
+        rejectWrapper = createClosure(wrapperCallback, wrapperCallbackEnvironment(promise, args[1].As<v8::Function>(), isolate), isolate);
     } else {
-        rejectWrapper = createClosure(promiseRejectCallback, resolver);
+        rejectWrapper = createClosure(promiseRejectCallback, promise, isolate);
     }
     V8PromiseCustom::append(args.Holder(), fulfillWrapper, rejectWrapper, isolate);
     v8SetReturnValue(args, promise);
@@ -345,36 +348,22 @@
 {
     v8::Isolate* isolate = args.GetIsolate();
     v8::Local<v8::Function> fulfillWrapper, rejectWrapper;
-    v8::Local<v8::Object> promise, resolver;
-    V8PromiseCustom::createPromise(args.Holder(), &promise, &resolver, isolate);
+    v8::Local<v8::Object> promise = V8PromiseCustom::createPromise(args.Holder(), isolate);
 
     if (args.Length() > 0 && !args[0]->IsUndefined()) {
         if (!args[0]->IsFunction()) {
             v8SetReturnValue(args, throwTypeError("rejectCallback must be a function or undefined", isolate));
             return;
         }
-        rejectWrapper = createClosure(wrapperCallback, wrapperCallbackEnvironment(promise, resolver, args[0].As<v8::Function>(), isolate));
+        rejectWrapper = createClosure(wrapperCallback, wrapperCallbackEnvironment(promise, args[0].As<v8::Function>(), isolate), isolate);
     } else {
-        rejectWrapper = createClosure(promiseRejectCallback, resolver);
+        rejectWrapper = createClosure(promiseRejectCallback, promise, isolate);
     }
-    fulfillWrapper = createClosure(promiseFulfillCallback, resolver);
+    fulfillWrapper = createClosure(promiseFulfillCallback, promise, isolate);
     V8PromiseCustom::append(args.Holder(), fulfillWrapper, rejectWrapper, isolate);
     v8SetReturnValue(args, promise);
 }
 
-void V8Promise::fulfillMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
-{
-    v8::Isolate* isolate = args.GetIsolate();
-    v8::Local<v8::Value> result = v8::Undefined(isolate);
-    if (args.Length() > 0)
-        result = args[0];
-
-    v8::Local<v8::Object> promise, resolver;
-    V8PromiseCustom::createPromise(args.Holder(), &promise, &resolver, isolate);
-    V8PromiseCustom::fulfillResolver(resolver, result, V8PromiseCustom::Asynchronous, isolate);
-    v8SetReturnValue(args, promise);
-}
-
 void V8Promise::resolveMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
 {
     v8::Isolate* isolate = args.GetIsolate();
@@ -382,9 +371,8 @@
     if (args.Length() > 0)
         result = args[0];
 
-    v8::Local<v8::Object> promise, resolver;
-    V8PromiseCustom::createPromise(args.Holder(), &promise, &resolver, isolate);
-    V8PromiseCustom::resolveResolver(resolver, result, V8PromiseCustom::Asynchronous, isolate);
+    v8::Local<v8::Object> promise = V8PromiseCustom::createPromise(args.Holder(), isolate);
+    V8PromiseCustom::resolve(promise, result, V8PromiseCustom::Asynchronous, isolate);
     v8SetReturnValue(args, promise);
 }
 
@@ -395,31 +383,28 @@
     if (args.Length() > 0)
         result = args[0];
 
-    v8::Local<v8::Object> promise, resolver;
-    V8PromiseCustom::createPromise(args.Holder(), &promise, &resolver, isolate);
-    V8PromiseCustom::rejectResolver(resolver, result, V8PromiseCustom::Asynchronous, isolate);
+    v8::Local<v8::Object> promise = V8PromiseCustom::createPromise(args.Holder(), isolate);
+    V8PromiseCustom::reject(promise, result, V8PromiseCustom::Asynchronous, isolate);
     v8SetReturnValue(args, promise);
 }
 
 void V8Promise::anyMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
 {
     v8::Isolate* isolate = args.GetIsolate();
-    v8::Local<v8::Object> promise, resolver;
-    V8PromiseCustom::createPromise(args.Holder(), &promise, &resolver, isolate);
+    v8::Local<v8::Object> promise = V8PromiseCustom::createPromise(args.Holder(), isolate);
 
     if (!args.Length()) {
-        V8PromiseCustom::resolveResolver(resolver, v8::Undefined(isolate), V8PromiseCustom::Asynchronous, isolate);
+        V8PromiseCustom::resolve(promise, v8::Undefined(isolate), V8PromiseCustom::Asynchronous, isolate);
         v8SetReturnValue(args, promise);
         return;
     }
 
-    v8::Local<v8::Function> fulfillCallback = createClosure(promiseResolveCallback, resolver);
-    v8::Local<v8::Function> rejectCallback = createClosure(promiseRejectCallback, resolver);
+    v8::Local<v8::Function> fulfillCallback = createClosure(promiseResolveCallback, promise, isolate);
+    v8::Local<v8::Function> rejectCallback = createClosure(promiseRejectCallback, promise, isolate);
 
     for (int i = 0; i < args.Length(); ++i) {
-        v8::Local<v8::Object> eachPromise, eachResolver;
-        V8PromiseCustom::createPromise(args.Holder(), &eachPromise, &eachResolver, isolate);
-        V8PromiseCustom::resolveResolver(eachResolver, args[i], V8PromiseCustom::Asynchronous, isolate);
+        v8::Local<v8::Object> eachPromise = V8PromiseCustom::createPromise(args.Holder(), isolate);
+        V8PromiseCustom::resolve(eachPromise, args[i], V8PromiseCustom::Asynchronous, isolate);
         V8PromiseCustom::append(eachPromise, fulfillCallback, rejectCallback, isolate);
     }
     v8SetReturnValue(args, promise);
@@ -428,11 +413,10 @@
 void V8Promise::everyMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
 {
     v8::Isolate* isolate = args.GetIsolate();
-    v8::Local<v8::Object> promise, resolver;
-    V8PromiseCustom::createPromise(args.Holder(), &promise, &resolver, isolate);
+    v8::Local<v8::Object> promise = V8PromiseCustom::createPromise(args.Holder(), isolate);
 
     if (!args.Length()) {
-        V8PromiseCustom::resolveResolver(resolver, v8::Undefined(isolate), V8PromiseCustom::Asynchronous, isolate);
+        V8PromiseCustom::resolve(promise, v8::Undefined(isolate), V8PromiseCustom::Asynchronous, isolate);
         v8SetReturnValue(args, promise);
         return;
     }
@@ -442,43 +426,12 @@
     countdownWrapper->SetInternalField(V8PromiseCustom::PrimitiveWrapperPrimitiveIndex, v8::Integer::New(args.Length(), isolate));
     v8::Local<v8::Array> results = v8::Array::New();
 
-    v8::Local<v8::Function> rejectCallback = createClosure(promiseRejectCallback, resolver);
+    v8::Local<v8::Function> rejectCallback = createClosure(promiseRejectCallback, promise, isolate);
     for (int i = 0; i < args.Length(); ++i) {
-        v8::Local<v8::Object> environment = promiseEveryEnvironment(resolver, countdownWrapper, i, results, isolate);
-        v8::Local<v8::Function> fulfillCallback = v8::FunctionTemplate::New(promiseEveryFulfillCallback, environment)->GetFunction();
-        v8::Local<v8::Object> eachPromise, eachResolver;
-        V8PromiseCustom::createPromise(args.Holder(), &eachPromise, &eachResolver, isolate);
-        V8PromiseCustom::resolveResolver(eachResolver, args[i], V8PromiseCustom::Asynchronous, isolate);
-        V8PromiseCustom::append(eachPromise, fulfillCallback, rejectCallback, isolate);
-    }
-    v8SetReturnValue(args, promise);
-}
-
-void V8Promise::someMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
-{
-    v8::Isolate* isolate = args.GetIsolate();
-    v8::Local<v8::Object> promise, resolver;
-    V8PromiseCustom::createPromise(args.Holder(), &promise, &resolver, isolate);
-
-    if (!args.Length()) {
-        V8PromiseCustom::resolveResolver(resolver, v8::Undefined(isolate), V8PromiseCustom::Asynchronous, isolate);
-        v8SetReturnValue(args, promise);
-        return;
-    }
-
-    // Promise.some also uses PromiseEveryEnvironment.
-    v8::Local<v8::ObjectTemplate> objectTemplate = primitiveWrapperObjectTemplate(isolate);
-    v8::Local<v8::Object> countdownWrapper = objectTemplate->NewInstance();
-    countdownWrapper->SetInternalField(V8PromiseCustom::PrimitiveWrapperPrimitiveIndex, v8::Integer::New(args.Length(), isolate));
-    v8::Local<v8::Array> results = v8::Array::New();
-
-    v8::Local<v8::Function> fulfillCallback = createClosure(promiseResolveCallback, resolver);
-    for (int i = 0; i < args.Length(); ++i) {
-        v8::Local<v8::Object> environment = promiseEveryEnvironment(resolver, countdownWrapper, i, results, isolate);
-        v8::Local<v8::Object> eachPromise, eachResolver;
-        v8::Local<v8::Function> rejectCallback = v8::FunctionTemplate::New(promiseSomeRejectCallback, environment)->GetFunction();
-        V8PromiseCustom::createPromise(args.Holder(), &eachPromise, &eachResolver, isolate);
-        V8PromiseCustom::resolveResolver(eachResolver, args[i], V8PromiseCustom::Asynchronous, isolate);
+        v8::Local<v8::Object> environment = promiseEveryEnvironment(promise, countdownWrapper, i, results, isolate);
+        v8::Local<v8::Function> fulfillCallback = createClosure(promiseEveryFulfillCallback, environment, isolate);
+        v8::Local<v8::Object> eachPromise = V8PromiseCustom::createPromise(args.Holder(), isolate);
+        V8PromiseCustom::resolve(eachPromise, args[i], V8PromiseCustom::Asynchronous, isolate);
         V8PromiseCustom::append(eachPromise, fulfillCallback, rejectCallback, isolate);
     }
     v8SetReturnValue(args, promise);
@@ -486,42 +439,43 @@
 
 //
 // -- V8PromiseCustom --
-void V8PromiseCustom::createPromise(v8::Handle<v8::Object> creationContext, v8::Local<v8::Object>* promise, v8::Local<v8::Object>* resolver, v8::Isolate* isolate)
+v8::Local<v8::Object> V8PromiseCustom::createPromise(v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
 {
     v8::Local<v8::ObjectTemplate> internalTemplate = internalObjectTemplate(isolate);
     v8::Local<v8::Object> internal = internalTemplate->NewInstance();
-    *promise = V8DOMWrapper::createWrapper(creationContext, &V8Promise::info, 0, isolate);
-    *resolver = V8DOMWrapper::createWrapper(creationContext, &V8PromiseResolver::info, 0, isolate);
+    v8::Local<v8::Object> promise = V8DOMWrapper::createWrapper(creationContext, &V8Promise::info, 0, isolate);
 
     clearInternal(internal, V8PromiseCustom::Pending, v8::Undefined(isolate), isolate);
 
-    (*promise)->SetInternalField(v8DOMWrapperObjectIndex, internal);
-    (*resolver)->SetInternalField(v8DOMWrapperObjectIndex, internal);
+    promise->SetInternalField(v8DOMWrapperObjectIndex, internal);
+    return promise;
 }
 
-void V8PromiseCustom::fulfillResolver(v8::Handle<v8::Object> resolver, v8::Handle<v8::Value> result, SynchronousMode mode, v8::Isolate* isolate)
+void V8PromiseCustom::fulfill(v8::Handle<v8::Object> promise, v8::Handle<v8::Value> result, SynchronousMode mode, v8::Isolate* isolate)
 {
-    if (isInternalDetached(resolver))
+    v8::Local<v8::Object> internal = getInternal(promise);
+    PromiseState state = getState(internal);
+    if (state == Fulfilled || state == Rejected)
         return;
-    v8::Local<v8::Object> internal = getInternal(resolver);
-    ASSERT(getState(internal) == Pending || getState(internal) == PendingWithResolvedFlagSet);
+
+    ASSERT(state == Pending || state == Following);
     v8::Local<v8::Array> callbacks = internal->GetInternalField(V8PromiseCustom::InternalFulfillCallbackIndex).As<v8::Array>();
     clearInternal(internal, Fulfilled, result, isolate);
-    detachInternal(resolver, isolate);
 
     callCallbacks(callbacks, result, mode, isolate);
 }
 
-void V8PromiseCustom::resolveResolver(v8::Handle<v8::Object> resolver, v8::Handle<v8::Value> result, SynchronousMode mode, v8::Isolate* isolate)
+void V8PromiseCustom::resolve(v8::Handle<v8::Object> promise, v8::Handle<v8::Value> result, SynchronousMode mode, v8::Isolate* isolate)
 {
     ASSERT(!result.IsEmpty());
+
     v8::Local<v8::Value> then;
     if (result->IsObject()) {
         v8::TryCatch trycatch;
         then = result.As<v8::Object>()->Get(v8::String::NewSymbol("then"));
         if (then.IsEmpty()) {
             // If calling the [[Get]] internal method threw an exception, catch it and run reject.
-            rejectResolver(resolver, trycatch.Exception(), mode, isolate);
+            reject(promise, trycatch.Exception(), mode, isolate);
             return;
         }
     }
@@ -530,26 +484,27 @@
         ASSERT(result->IsObject());
         v8::TryCatch trycatch;
         v8::Handle<v8::Value> argv[] = {
-            createClosure(promiseResolveCallback, resolver),
-            createClosure(promiseRejectCallback, resolver),
+            createClosure(promiseResolveCallback, promise, isolate),
+            createClosure(promiseRejectCallback, promise, isolate),
         };
         if (V8ScriptRunner::callFunction(then.As<v8::Function>(), getScriptExecutionContext(), result.As<v8::Object>(), WTF_ARRAY_LENGTH(argv), argv, isolate).IsEmpty())
-            rejectResolver(resolver, trycatch.Exception(), mode, isolate);
+            reject(promise, trycatch.Exception(), mode, isolate);
         return;
     }
 
-    fulfillResolver(resolver, result, mode, isolate);
+    fulfill(promise, result, mode, isolate);
 }
 
-void V8PromiseCustom::rejectResolver(v8::Handle<v8::Object> resolver, v8::Handle<v8::Value> result, SynchronousMode mode, v8::Isolate* isolate)
+void V8PromiseCustom::reject(v8::Handle<v8::Object> promise, v8::Handle<v8::Value> result, SynchronousMode mode, v8::Isolate* isolate)
 {
-    if (isInternalDetached(resolver))
+    v8::Local<v8::Object> internal = getInternal(promise);
+    PromiseState state = getState(internal);
+    if (state == Fulfilled || state == Rejected)
         return;
-    v8::Local<v8::Object> internal = getInternal(resolver);
-    ASSERT(getState(internal) == Pending || getState(internal) == PendingWithResolvedFlagSet);
+
+    ASSERT(state == Pending || state == Following);
     v8::Local<v8::Array> callbacks = internal->GetInternalField(V8PromiseCustom::InternalRejectCallbackIndex).As<v8::Array>();
     clearInternal(internal, Rejected, result, isolate);
-    detachInternal(resolver, isolate);
 
     callCallbacks(callbacks, result, mode, isolate);
 }
@@ -577,7 +532,7 @@
         return;
     }
 
-    ASSERT(state == Pending || state == PendingWithResolvedFlagSet);
+    ASSERT(state == Pending || state == Following);
     if (!fulfillCallback.IsEmpty()) {
         v8::Local<v8::Array> callbacks = internal->GetInternalField(InternalFulfillCallbackIndex).As<v8::Array>();
         callbacks->Set(callbacks->Length(), fulfillCallback);
@@ -588,25 +543,12 @@
     }
 }
 
-v8::Local<v8::Object> V8PromiseCustom::getInternal(v8::Handle<v8::Object> promiseOrResolver)
+v8::Local<v8::Object> V8PromiseCustom::getInternal(v8::Handle<v8::Object> promise)
 {
-    v8::Local<v8::Value> value = promiseOrResolver->GetInternalField(v8DOMWrapperObjectIndex);
-    // This function cannot be called when the internal object is detached, so the value must be an object.
+    v8::Local<v8::Value> value = promise->GetInternalField(v8DOMWrapperObjectIndex);
     return value.As<v8::Object>();
 }
 
-bool V8PromiseCustom::isInternalDetached(v8::Handle<v8::Object> resolver)
-{
-    v8::Local<v8::Value> value = resolver->GetInternalField(v8DOMWrapperObjectIndex);
-    ASSERT(!value.IsEmpty());
-    return value->IsUndefined();
-}
-
-void V8PromiseCustom::detachInternal(v8::Handle<v8::Object> resolver, v8::Isolate* isolate)
-{
-    resolver->SetInternalField(v8DOMWrapperObjectIndex, v8::Undefined(isolate));
-}
-
 void V8PromiseCustom::clearInternal(v8::Handle<v8::Object> internal, PromiseState state, v8::Handle<v8::Value> value, v8::Isolate* isolate)
 {
     setState(internal, state, isolate);
@@ -620,13 +562,13 @@
     v8::Handle<v8::Value> value = internal->GetInternalField(V8PromiseCustom::InternalStateIndex);
     bool ok = false;
     uint32_t number = toInt32(value, ok);
-    ASSERT(ok && (number == Pending || number == Fulfilled || number == Rejected || number == PendingWithResolvedFlagSet));
+    ASSERT(ok && (number == Pending || number == Fulfilled || number == Rejected || number == Following));
     return static_cast<PromiseState>(number);
 }
 
 void V8PromiseCustom::setState(v8::Handle<v8::Object> internal, PromiseState state, v8::Isolate* isolate)
 {
-    ASSERT(state == Pending || state == Fulfilled || state == Rejected || state == PendingWithResolvedFlagSet);
+    ASSERT(state == Pending || state == Fulfilled || state == Rejected || state == Following);
     internal->SetInternalField(V8PromiseCustom::InternalStateIndex, v8::Integer::New(state, isolate));
 }
 
diff --git a/Source/bindings/v8/custom/V8PromiseCustom.h b/Source/bindings/v8/custom/V8PromiseCustom.h
index 8b0957c..42e1bd9 100644
--- a/Source/bindings/v8/custom/V8PromiseCustom.h
+++ b/Source/bindings/v8/custom/V8PromiseCustom.h
@@ -25,6 +25,8 @@
 #ifndef V8PromiseCustom_h
 #define V8PromiseCustom_h
 
+#include "bindings/v8/WrapperTypeInfo.h"
+
 #include <v8.h>
 
 namespace WebCore {
@@ -41,13 +43,12 @@
 
     enum WrapperCallbackEnvironmentFieldIndex {
         WrapperCallbackEnvironmentPromiseIndex,
-        WrapperCallbackEnvironmentPromiseResolverIndex,
         WrapperCallbackEnvironmentCallbackIndex,
         WrapperCallbackEnvironmentFieldCount, // This entry must always be at the bottom.
     };
 
     enum PromiseEveryEnvironmentFieldIndex {
-        PromiseEveryEnvironmentPromiseResolverIndex,
+        PromiseEveryEnvironmentPromiseIndex,
         PromiseEveryEnvironmentCountdownIndex,
         PromiseEveryEnvironmentIndexIndex,
         PromiseEveryEnvironmentResultsIndex,
@@ -63,7 +64,7 @@
         Pending,
         Fulfilled,
         Rejected,
-        PendingWithResolvedFlagSet,
+        Following,
     };
 
     enum SynchronousMode {
@@ -71,40 +72,30 @@
         Asynchronous,
     };
 
-    // Create Promise and PromiseResolver instances and set them to |promise| and |resolver| respectively.
-    static void createPromise(v8::Handle<v8::Object> creationContext, v8::Local<v8::Object>* promise, v8::Local<v8::Object>* resolver, v8::Isolate*);
+    static v8::Local<v8::Object> createPromise(v8::Handle<v8::Object> creationContext, v8::Isolate*);
 
-    // |resolver| must be a PromiseResolver instance.
-    static void fulfillResolver(v8::Handle<v8::Object> resolver, v8::Handle<v8::Value> result, SynchronousMode, v8::Isolate*);
-    // |resolver| must be a PromiseResolver instance.
-    static void resolveResolver(v8::Handle<v8::Object> resolver, v8::Handle<v8::Value> result, SynchronousMode, v8::Isolate*);
-    // |resolver| must be a PromiseResolver instance.
-    static void rejectResolver(v8::Handle<v8::Object> resolver, v8::Handle<v8::Value> result, SynchronousMode, v8::Isolate*);
+    // |promise| must be a Promise instance.
+    static void fulfill(v8::Handle<v8::Object> promise, v8::Handle<v8::Value> result, SynchronousMode, v8::Isolate*);
+    // |promise| must be a Promise instance.
+    static void resolve(v8::Handle<v8::Object> promise, v8::Handle<v8::Value> result, SynchronousMode, v8::Isolate*);
+    // |promise| must be a Promise instance.
+    static void reject(v8::Handle<v8::Object> promise, v8::Handle<v8::Value> result, SynchronousMode, v8::Isolate*);
 
     // |promise| must be a Promise instance.
     // |fulfillCallback| and |rejectCallback| can be an empty function respectively.
     static void append(v8::Handle<v8::Object> promise, v8::Handle<v8::Function> fulfillCallback, v8::Handle<v8::Function> rejectCallback, v8::Isolate*);
 
-    // This function can take either Promise or PromiseResolver objects.
-    // This function cannot be called when the internal object is detached from |promiseOrResolver|.
-    // Note that internal object can be detached only from PromiseResolver.
-    static v8::Local<v8::Object> getInternal(v8::Handle<v8::Object> promiseOrResolver);
+    // |promise| must be a Promise instance.
+    static v8::Local<v8::Object> getInternal(v8::Handle<v8::Object> promise);
 
-    // Return true if the internal object is detached from |resolver|.
-    // |resolver| must be a PromiseResolver instance.
-    static bool isInternalDetached(v8::Handle<v8::Object> resolver);
-
-    // Detach the internal object from |resolver|.
-    // |resolver| must be a PromiseResolver instance.
-    static void detachInternal(v8::Handle<v8::Object> resolver, v8::Isolate*);
-
-    // Clear the Promise / PromiseResolver internal object with the given state and result.
+    // |internal| must be a Promise internal object.
+    // Clear the Promise internal object with the given state and result.
     // This function clears callbacks in the object.
     static void clearInternal(v8::Handle<v8::Object> internal, PromiseState, v8::Handle<v8::Value> result, v8::Isolate*);
 
-    // |internal| must be an Promise / PromiseResolver internal object.
+    // |internal| must be a Promise internal object.
     static PromiseState getState(v8::Handle<v8::Object> internal);
-    // |internal| must be an Promise / PromiseResolver internal object.
+    // |internal| must be a Promise internal object.
     static void setState(v8::Handle<v8::Object> internal, PromiseState, v8::Isolate*);
 
     // Call |function| synchronously or asynchronously, depending on |mode|.
diff --git a/Source/bindings/v8/custom/V8PromiseResolverCustom.cpp b/Source/bindings/v8/custom/V8PromiseResolverCustom.cpp
deleted file mode 100644
index 9eb858d..0000000
--- a/Source/bindings/v8/custom/V8PromiseResolverCustom.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * 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
- * 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 "V8PromiseResolver.h"
-
-#include "bindings/v8/V8Binding.h"
-#include "bindings/v8/custom/V8PromiseCustom.h"
-#include <v8.h>
-
-namespace WebCore {
-
-void V8PromiseResolver::fulfillMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
-{
-    v8::Local<v8::Object> resolver = args.This();
-    if (V8PromiseCustom::isInternalDetached(resolver))
-        return;
-    v8::Local<v8::Object> internal = V8PromiseCustom::getInternal(resolver);
-    if (V8PromiseCustom::getState(internal) != V8PromiseCustom::Pending)
-        return;
-    v8::Isolate* isolate = args.GetIsolate();
-    V8PromiseCustom::setState(internal, V8PromiseCustom::PendingWithResolvedFlagSet, isolate);
-
-    v8::Local<v8::Value> result = v8::Undefined(isolate);
-    if (args.Length() > 0)
-        result = args[0];
-    V8PromiseCustom::fulfillResolver(resolver, result, V8PromiseCustom::Asynchronous, isolate);
-}
-
-void V8PromiseResolver::resolveMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
-{
-    v8::Local<v8::Object> resolver = args.This();
-    if (V8PromiseCustom::isInternalDetached(resolver))
-        return;
-    v8::Local<v8::Object> internal = V8PromiseCustom::getInternal(resolver);
-    if (V8PromiseCustom::getState(internal) != V8PromiseCustom::Pending)
-        return;
-    v8::Isolate* isolate = args.GetIsolate();
-    V8PromiseCustom::setState(internal, V8PromiseCustom::PendingWithResolvedFlagSet, isolate);
-
-    v8::Local<v8::Value> result = v8::Undefined(isolate);
-    if (args.Length() > 0)
-        result = args[0];
-    V8PromiseCustom::resolveResolver(resolver, result, V8PromiseCustom::Asynchronous, isolate);
-}
-
-void V8PromiseResolver::rejectMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
-{
-    v8::Local<v8::Object> resolver = args.This();
-    if (V8PromiseCustom::isInternalDetached(resolver))
-        return;
-    v8::Local<v8::Object> internal = V8PromiseCustom::getInternal(resolver);
-    if (V8PromiseCustom::getState(internal) != V8PromiseCustom::Pending)
-        return;
-    v8::Isolate* isolate = args.GetIsolate();
-    V8PromiseCustom::setState(internal, V8PromiseCustom::PendingWithResolvedFlagSet, isolate);
-
-    v8::Local<v8::Value> result = v8::Undefined(isolate);
-    if (args.Length() > 0)
-        result = args[0];
-    V8PromiseCustom::rejectResolver(resolver, result, V8PromiseCustom::Asynchronous, isolate);
-}
-
-} // namespace WebCore
diff --git a/Source/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp b/Source/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp
index b048ba1..ed4b39e 100644
--- a/Source/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp
+++ b/Source/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp
@@ -177,7 +177,7 @@
         return v8::Null(isolate);
     v8::Handle<v8::Value> extensionObject;
     const char* referenceName = 0;
-    switch (extension->getName()) {
+    switch (extension->name()) {
     case WebGLExtension::ANGLEInstancedArraysName:
         extensionObject = toV8(static_cast<ANGLEInstancedArrays*>(extension), contextObject, isolate);
         referenceName = "angleInstancedArraysName";
diff --git a/Source/bindings/v8/custom/V8WindowCustom.cpp b/Source/bindings/v8/custom/V8WindowCustom.cpp
index 92d70f1..e0cdbc3 100644
--- a/Source/bindings/v8/custom/V8WindowCustom.cpp
+++ b/Source/bindings/v8/custom/V8WindowCustom.cpp
@@ -85,7 +85,7 @@
     ScriptExecutionContext* scriptContext = static_cast<ScriptExecutionContext*>(imp->document());
 
     if (!scriptContext) {
-        es.throwDOMException(InvalidAccessError);
+        es.throwUninformativeAndGenericDOMException(InvalidAccessError);
         return;
     }
 
@@ -172,7 +172,7 @@
     if (context.IsEmpty())
         return;
 
-    v8::Handle<v8::String> eventSymbol = V8HiddenPropertyName::event();
+    v8::Handle<v8::String> eventSymbol = V8HiddenPropertyName::event(info.GetIsolate());
     v8::Handle<v8::Value> jsEvent = context->Global()->GetHiddenValue(eventSymbol);
     if (jsEvent.IsEmpty())
         return;
@@ -197,7 +197,7 @@
     if (context.IsEmpty())
         return;
 
-    v8::Handle<v8::String> eventSymbol = V8HiddenPropertyName::event();
+    v8::Handle<v8::String> eventSymbol = V8HiddenPropertyName::event(info.GetIsolate());
     context->Global()->SetHiddenValue(eventSymbol, value);
 }
 
diff --git a/Source/bindings/v8/custom/V8XMLHttpRequestCustom.cpp b/Source/bindings/v8/custom/V8XMLHttpRequestCustom.cpp
index df69492..aac8a68 100644
--- a/Source/bindings/v8/custom/V8XMLHttpRequestCustom.cpp
+++ b/Source/bindings/v8/custom/V8XMLHttpRequestCustom.cpp
@@ -146,9 +146,8 @@
     case XMLHttpRequest::ResponseTypeArrayBuffer:
         {
             ArrayBuffer* arrayBuffer = xmlHttpRequest->responseArrayBuffer();
-            if (arrayBuffer && !arrayBuffer->hasDeallocationObserver()) {
+            if (arrayBuffer) {
                 arrayBuffer->setDeallocationObserver(V8ArrayBufferDeallocationObserver::instance());
-                v8::V8::AdjustAmountOfExternalAllocatedMemory(arrayBuffer->byteLength());
             }
             v8SetReturnValueFast(info, arrayBuffer, xmlHttpRequest);
             return;