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

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

Issue 2395423002: Check if an iframe doesn't get detached twice
Patch Set: Created 4 years, 2 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 | « third_party/WebKit/Source/core/frame/LocalFrame.h ('k') | 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 8 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
9 * rights reserved. 9 * rights reserved.
10 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com> 10 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com>
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 loadType, KURL(), clientRedirectPolicy)); 372 loadType, KURL(), clientRedirectPolicy));
373 request.setClientRedirect(clientRedirectPolicy); 373 request.setClientRedirect(clientRedirectPolicy);
374 m_loader.load(request, loadType); 374 m_loader.load(request, loadType);
375 } else { 375 } else {
376 DCHECK_EQ(FrameLoadTypeReload, loadType); 376 DCHECK_EQ(FrameLoadTypeReload, loadType);
377 m_navigationScheduler->scheduleReload(); 377 m_navigationScheduler->scheduleReload();
378 } 378 }
379 } 379 }
380 380
381 void LocalFrame::detach(FrameDetachType type) { 381 void LocalFrame::detach(FrameDetachType type) {
382 CHECK(!m_detached);
383 m_detached = true;
384
382 PluginScriptForbiddenScope forbidPluginDestructorScripting; 385 PluginScriptForbiddenScope forbidPluginDestructorScripting;
383 m_loader.stopAllLoaders(); 386 m_loader.stopAllLoaders();
dcheng 2016/10/08 04:59:50 This can run script by causing a frame to be consi
384 // Don't allow any new child frames to load in this frame: attaching a new 387 // Don't allow any new child frames to load in this frame: attaching a new
385 // child frame during or after detaching children results in an attached 388 // child frame during or after detaching children results in an attached
386 // frame on a detached DOM tree, which is bad. 389 // frame on a detached DOM tree, which is bad.
387 SubframeLoadingDisabler disabler(*document()); 390 SubframeLoadingDisabler disabler(*document());
dcheng 2016/10/08 04:59:49 At this point, we disallow child frames from being
388 m_loader.dispatchUnloadEvent(); 391 m_loader.dispatchUnloadEvent();
dcheng 2016/10/08 04:59:49 This runs the actual unload / pagehide event, whic
389 detachChildren(); 392 detachChildren();
dcheng 2016/10/08 04:59:49 This recurses into child frames and calls Frame::d
390 393
391 // All done if detaching the subframes brought about a detach of this frame 394 // All done if detaching the subframes brought about a detach of this frame
392 // also. 395 // also.
393 if (!client()) 396 if (!client())
dcheng 2016/10/08 04:59:49 Because we just ran script, we must check that we
394 return; 397 return;
395 398
396 // stopAllLoaders() needs to be called after detachChildren(), because 399 // stopAllLoaders() needs to be called after detachChildren(), because
397 // detachChildren() will trigger the unload event handlers of any child 400 // detachChildren() will trigger the unload event handlers of any child
398 // frames, and those event handlers might start a new subresource load in this 401 // frames, and those event handlers might start a new subresource load in this
399 // frame. 402 // frame.
400 m_loader.stopAllLoaders(); 403 m_loader.stopAllLoaders();
dcheng 2016/10/08 04:59:50 I don't honestly remember what this comment is abo
401 m_loader.detach(); 404 m_loader.detach();
dcheng 2016/10/08 04:59:49 This can also dispatch events: this aborts any XHR
402 document()->shutdown(); 405 document()->shutdown();
dcheng 2016/10/08 04:59:49 Now we shutdown the Document. This is not supposed
403 // This is the earliest that scripting can be disabled: 406 // This is the earliest that scripting can be disabled:
404 // - FrameLoader::detach() can fire XHR abort events 407 // - FrameLoader::detach() can fire XHR abort events
405 // - Document::shutdown()'s deferred widget updates can run script. 408 // - Document::shutdown()'s deferred widget updates can run script.
406 ScriptForbiddenScope forbidScript; 409 ScriptForbiddenScope forbidScript;
dcheng 2016/10/08 04:59:49 Now no more script is allowed, and everything is a
407 m_loader.clear(); 410 m_loader.clear();
408 if (!client()) 411 if (!client())
dcheng 2016/10/08 04:59:49 However, I'm not sure why this check is after m_lo
409 return; 412 return;
410 413
411 client()->willBeDetached(); 414 client()->willBeDetached();
412 // Notify ScriptController that the frame is closing, since its cleanup ends 415 // Notify ScriptController that the frame is closing, since its cleanup ends
413 // up calling back to FrameLoaderClient via WindowProxy. 416 // up calling back to FrameLoaderClient via WindowProxy.
414 script().clearForClose(); 417 script().clearForClose();
415 setView(nullptr); 418 setView(nullptr);
416 419
417 m_host->eventHandlerRegistry().didRemoveAllEventHandlers(*localDOMWindow()); 420 m_host->eventHandlerRegistry().didRemoveAllEventHandlers(*localDOMWindow());
418 421
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 m_editor(Editor::create(*this)), 851 m_editor(Editor::create(*this)),
849 m_spellChecker(SpellChecker::create(*this)), 852 m_spellChecker(SpellChecker::create(*this)),
850 m_selection(FrameSelection::create(this)), 853 m_selection(FrameSelection::create(this)),
851 m_eventHandler(new EventHandler(this)), 854 m_eventHandler(new EventHandler(this)),
852 m_console(FrameConsole::create(*this)), 855 m_console(FrameConsole::create(*this)),
853 m_inputMethodController(InputMethodController::create(*this)), 856 m_inputMethodController(InputMethodController::create(*this)),
854 m_navigationDisableCount(0), 857 m_navigationDisableCount(0),
855 m_pageZoomFactor(parentPageZoomFactor(this)), 858 m_pageZoomFactor(parentPageZoomFactor(this)),
856 m_textZoomFactor(parentTextZoomFactor(this)), 859 m_textZoomFactor(parentTextZoomFactor(this)),
857 m_inViewSourceMode(false), 860 m_inViewSourceMode(false),
858 m_interfaceProvider(interfaceProvider) { 861 m_interfaceProvider(interfaceProvider),
862 m_detached(false) {
859 if (isLocalRoot()) 863 if (isLocalRoot())
860 m_instrumentingAgents = new InstrumentingAgents(); 864 m_instrumentingAgents = new InstrumentingAgents();
861 else 865 else
862 m_instrumentingAgents = localFrameRoot()->m_instrumentingAgents; 866 m_instrumentingAgents = localFrameRoot()->m_instrumentingAgents;
863 } 867 }
864 868
865 WebFrameScheduler* LocalFrame::frameScheduler() { 869 WebFrameScheduler* LocalFrame::frameScheduler() {
866 return m_frameScheduler.get(); 870 return m_frameScheduler.get();
867 } 871 }
868 872
(...skipping 29 matching lines...) Expand all
898 if (m_frame && m_frame->client() && m_frame->client()->frameBlameContext()) 902 if (m_frame && m_frame->client() && m_frame->client()->frameBlameContext())
899 m_frame->client()->frameBlameContext()->Enter(); 903 m_frame->client()->frameBlameContext()->Enter();
900 } 904 }
901 905
902 ScopedFrameBlamer::~ScopedFrameBlamer() { 906 ScopedFrameBlamer::~ScopedFrameBlamer() {
903 if (m_frame && m_frame->client() && m_frame->client()->frameBlameContext()) 907 if (m_frame && m_frame->client() && m_frame->client()->frameBlameContext())
904 m_frame->client()->frameBlameContext()->Leave(); 908 m_frame->client()->frameBlameContext()->Leave();
905 } 909 }
906 910
907 } // namespace blink 911 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/LocalFrame.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698