Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Unified Diff: third_party/WebKit/Source/bindings/core/v8/WindowProxy.cpp

Issue 2736533002: Add CHECKs to try to narrow down cause of bad internal fields in Window DOM wrapper (Closed)
Patch Set: "add missing HandleScope" Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/web/WebRemoteFrameImpl.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/bindings/core/v8/WindowProxy.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/WindowProxy.cpp b/third_party/WebKit/Source/bindings/core/v8/WindowProxy.cpp
index 4a311463dd45a533bb99792e09c15e916871edfc..67d3a448b040dea675c217365c881c62f69b6f76 100644
--- a/third_party/WebKit/Source/bindings/core/v8/WindowProxy.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/WindowProxy.cpp
@@ -33,9 +33,11 @@
#include <utility>
#include "bindings/core/v8/V8DOMWrapper.h"
+#include "bindings/core/v8/V8Window.h"
#include "core/frame/Frame.h"
#include "v8/include/v8.h"
#include "wtf/Assertions.h"
+#include "wtf/debug/Alias.h"
namespace blink {
@@ -130,11 +132,40 @@ void WindowProxy::setGlobal(v8::Local<v8::Object> global) {
// If there are JS code holds a closure to the old inner window,
// it won't be able to reach the outer window via its global object.
void WindowProxy::initializeIfNeeded() {
+ v8::HandleScope handleScope(m_isolate);
+ Lifecycle oldLifecycle = m_lifecycle;
+ DOMWindow* window = m_frame->domWindow();
+ bool isLocal = window->isLocalDOMWindow();
+ // Prevent these locals from getting optimized out, and hopefully, the heap
+ // contents captured into minidumps.
+ WTF::debug::alias(&oldLifecycle);
+ WTF::debug::alias(&window);
+ WTF::debug::alias(&isLocal);
+
// TODO(haraken): It is wrong to re-initialize an already detached window
// proxy. This must be 'if(m_lifecycle == Lifecycle::ContextUninitialized)'.
if (m_lifecycle != Lifecycle::ContextInitialized) {
initialize();
+ // Note: this set of CHECKs is intentionally duplicated below to distinguish
+ // between initializing the global with null internal fields or returning a
+ // global that claims to be initialized but has null internal fields.
+ v8::Local<v8::Object> globalProxy = m_globalProxy.newLocal(m_isolate);
+ CHECK(!globalProxy.IsEmpty());
+ CHECK(V8Window::hasInstance(globalProxy, m_isolate));
+ CHECK(window);
+ CHECK_EQ(window, V8Window::toImpl(globalProxy));
+ } else {
+ v8::Local<v8::Object> globalProxy = m_globalProxy.newLocal(m_isolate);
+ CHECK(!globalProxy.IsEmpty());
+ CHECK(V8Window::hasInstance(globalProxy, m_isolate));
+ CHECK(window);
+ CHECK_EQ(window, V8Window::toImpl(globalProxy));
}
+
+ // Sanity check: WindowProxy's frame's window should still be the same
+ DOMWindow* window2 = m_frame->domWindow();
+ WTF::debug::alias(&window2);
+ CHECK_EQ(window, window2);
}
} // namespace blink
« no previous file with comments | « no previous file | third_party/WebKit/Source/web/WebRemoteFrameImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698