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

Side by Side Diff: third_party/WebKit/Source/core/frame/LocalFrame.cpp

Issue 1657583002: Disallow scripting earlier in LocalFrame::detach(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add comments and move script forbidden scope. Created 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3 * 1999 Lars Knoll <knoll@kde.org> 3 * 1999 Lars Knoll <knoll@kde.org>
4 * 1999 Antti Koivisto <koivisto@kde.org> 4 * 1999 Antti Koivisto <koivisto@kde.org>
5 * 2000 Simon Hausmann <hausmann@kde.org> 5 * 2000 Simon Hausmann <hausmann@kde.org>
6 * 2000 Stefan Schimanski <1Stein@gmx.de> 6 * 2000 Stefan Schimanski <1Stein@gmx.de>
7 * 2001 George Staikos <staikos@kde.org> 7 * 2001 George Staikos <staikos@kde.org>
8 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. 8 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
9 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com> 9 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com>
10 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 10 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 // All done if detaching the subframes brought about a detach of this frame also. 327 // All done if detaching the subframes brought about a detach of this frame also.
328 if (!client()) 328 if (!client())
329 return; 329 return;
330 330
331 // stopAllLoaders() needs to be called after detachChildren(), because detac hChildren() 331 // stopAllLoaders() needs to be called after detachChildren(), because detac hChildren()
332 // will trigger the unload event handlers of any child frames, and those eve nt 332 // will trigger the unload event handlers of any child frames, and those eve nt
333 // handlers might start a new subresource load in this frame. 333 // handlers might start a new subresource load in this frame.
334 m_loader.stopAllLoaders(); 334 m_loader.stopAllLoaders();
335 m_loader.detach(); 335 m_loader.detach();
336 document()->detach(); 336 document()->detach();
337 // This is the earliest that scripting can be disabled:
338 // - FrameLoader::detach() can fire XHR abort events
339 // - Document::detach()'s deferred widget updates can run script.
340 ScriptForbiddenScope forbidScript;
337 m_loader.clear(); 341 m_loader.clear();
338 if (!client()) 342 if (!client())
339 return; 343 return;
340 344
341 client()->willBeDetached(); 345 client()->willBeDetached();
342 // Notify ScriptController that the frame is closing, since its cleanup ends up calling 346 // Notify ScriptController that the frame is closing, since its cleanup ends up calling
343 // back to FrameLoaderClient via WindowProxy. 347 // back to FrameLoaderClient via WindowProxy.
344 script().clearForClose(); 348 script().clearForClose();
345 ScriptForbiddenScope forbidScript;
346 setView(nullptr); 349 setView(nullptr);
347 willDetachFrameHost(); 350 willDetachFrameHost();
348 InspectorInstrumentation::frameDetachedFromParent(this); 351 InspectorInstrumentation::frameDetachedFromParent(this);
349 Frame::detach(type); 352 Frame::detach(type);
350 353
351 // Signal frame destruction here rather than in the destructor. 354 // Signal frame destruction here rather than in the destructor.
352 // Main motivation is to avoid being dependent on its exact timing (Oilpan.) 355 // Main motivation is to avoid being dependent on its exact timing (Oilpan.)
353 LocalFrameLifecycleNotifier::notifyContextDestroyed(); 356 LocalFrameLifecycleNotifier::notifyContextDestroyed();
354 // TODO(dcheng): Temporary, to debug https://crbug.com/531291. 357 // TODO(dcheng): Temporary, to debug https://crbug.com/531291.
355 // If this is true, we somehow re-entered LocalFrame::detach. But this is 358 // If this is true, we somehow re-entered LocalFrame::detach. But this is
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 { 906 {
904 m_frame->disableNavigation(); 907 m_frame->disableNavigation();
905 } 908 }
906 909
907 FrameNavigationDisabler::~FrameNavigationDisabler() 910 FrameNavigationDisabler::~FrameNavigationDisabler()
908 { 911 {
909 m_frame->enableNavigation(); 912 m_frame->enableNavigation();
910 } 913 }
911 914
912 } // namespace blink 915 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698