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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp

Issue 2735983002: Ensure WindowProxy reinitialization on navigations if needed. (Closed)
Patch Set: Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008, 2009, 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2008, 2009, 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 v8::Local<v8::Context> context = m_scriptState->context(); 95 v8::Local<v8::Context> context = m_scriptState->context();
96 if (m_globalProxy.isEmpty()) { 96 if (m_globalProxy.isEmpty()) {
97 m_globalProxy.set(isolate(), context->Global()); 97 m_globalProxy.set(isolate(), context->Global());
98 CHECK(!m_globalProxy.isEmpty()); 98 CHECK(!m_globalProxy.isEmpty());
99 } 99 }
100 100
101 setupWindowPrototypeChain(); 101 setupWindowPrototypeChain();
102 102
103 SecurityOrigin* origin = 0; 103 SecurityOrigin* origin = 0;
104 if (m_world->isMainWorld()) { 104 if (m_world->isMainWorld()) {
105 // ActivityLogger for main world is updated within updateDocument(). 105 // ActivityLogger for main world is updated within updateDocumentInternal().
106 updateDocument(); 106 updateDocumentInternal();
107 origin = frame()->document()->getSecurityOrigin(); 107 origin = frame()->document()->getSecurityOrigin();
108 // FIXME: Can this be removed when CSP moves to browser? 108 // FIXME: Can this be removed when CSP moves to browser?
109 ContentSecurityPolicy* csp = frame()->document()->contentSecurityPolicy(); 109 ContentSecurityPolicy* csp = frame()->document()->contentSecurityPolicy();
110 context->AllowCodeGenerationFromStrings( 110 context->AllowCodeGenerationFromStrings(
111 csp->allowEval(0, SecurityViolationReportingPolicy::SuppressReporting)); 111 csp->allowEval(0, SecurityViolationReportingPolicy::SuppressReporting));
112 context->SetErrorMessageForCodeGenerationFromStrings( 112 context->SetErrorMessageForCodeGenerationFromStrings(
113 v8String(isolate(), csp->evalDisabledErrorMessage())); 113 v8String(isolate(), csp->evalDisabledErrorMessage()));
114 } else { 114 } else {
115 updateActivityLogger(); 115 updateActivityLogger();
116 origin = m_world->isolatedWorldSecurityOrigin(); 116 origin = m_world->isolatedWorldSecurityOrigin();
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 // as the security token. 236 // as the security token.
237 context->SetSecurityToken(v8AtomicString(isolate(), token)); 237 context->SetSecurityToken(v8AtomicString(isolate(), token));
238 } 238 }
239 239
240 void LocalWindowProxy::updateDocument() { 240 void LocalWindowProxy::updateDocument() {
241 DCHECK(m_world->isMainWorld()); 241 DCHECK(m_world->isMainWorld());
242 // For an uninitialized main window proxy, there's nothing we need 242 // For an uninitialized main window proxy, there's nothing we need
243 // to update. The update is done when the window proxy gets initialized later. 243 // to update. The update is done when the window proxy gets initialized later.
244 if (m_lifecycle == Lifecycle::ContextUninitialized) 244 if (m_lifecycle == Lifecycle::ContextUninitialized)
245 return; 245 return;
246 // TODO(yukishiino): Is it okay to not update document when the context 246
247 // is detached? It's not trivial to fix this because udpateDocumentProperty 247 // If this WindowProxy was previously initialized, reinitialize it now to
248 // requires a not-yet-detached context to instantiate a document wrapper. 248 // preserve JS object identity. Otherwise, extant references to the
249 if (m_lifecycle == Lifecycle::ContextDetached) 249 // WindowProxy will be broken.
250 if (m_lifecycle == Lifecycle::ContextDetached) {
251 initialize();
252 DCHECK_EQ(Lifecycle::ContextInitialized, m_lifecycle);
253 // Initialization internally updates the document properties, so just
254 // return afterwards.
250 return; 255 return;
256 }
251 257
258 updateDocumentInternal();
259 }
260
261 void LocalWindowProxy::updateDocumentInternal() {
252 updateActivityLogger(); 262 updateActivityLogger();
253 updateDocumentProperty(); 263 updateDocumentProperty();
254 updateSecurityOrigin(frame()->document()->getSecurityOrigin()); 264 updateSecurityOrigin(frame()->document()->getSecurityOrigin());
255 } 265 }
256 266
257 static v8::Local<v8::Value> getNamedProperty( 267 static v8::Local<v8::Value> getNamedProperty(
258 HTMLDocument* htmlDocument, 268 HTMLDocument* htmlDocument,
259 const AtomicString& key, 269 const AtomicString& key,
260 v8::Local<v8::Object> creationContext, 270 v8::Local<v8::Object> creationContext,
261 v8::Isolate* isolate) { 271 v8::Isolate* isolate) {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 365
356 setSecurityToken(origin); 366 setSecurityToken(origin);
357 } 367 }
358 368
359 LocalWindowProxy::LocalWindowProxy(v8::Isolate* isolate, 369 LocalWindowProxy::LocalWindowProxy(v8::Isolate* isolate,
360 LocalFrame& frame, 370 LocalFrame& frame,
361 RefPtr<DOMWrapperWorld> world) 371 RefPtr<DOMWrapperWorld> world)
362 : WindowProxy(isolate, frame, std::move(world)) {} 372 : WindowProxy(isolate, frame, std::move(world)) {}
363 373
364 } // namespace blink 374 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.h ('k') | third_party/WebKit/Source/web/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698