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

Side by Side Diff: third_party/WebKit/Source/core/loader/FrameLoader.cpp

Issue 1642283002: Deal with frame removal by content scripts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Schedule microtask for document_end scripts 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed.
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
5 * Copyright (C) 2008 Alp Toker <alp@atoker.com> 5 * Copyright (C) 2008 Alp Toker <alp@atoker.com>
6 * Copyright (C) Research In Motion Limited 2009. All rights reserved. 6 * Copyright (C) Research In Motion Limited 2009. All rights reserved.
7 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> 7 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com>
8 * Copyright (C) 2011 Google Inc. All rights reserved. 8 * Copyright (C) 2011 Google Inc. All rights reserved.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
(...skipping 19 matching lines...) Expand all
30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */ 33 */
34 34
35 #include "core/loader/FrameLoader.h" 35 #include "core/loader/FrameLoader.h"
36 36
37 #include "bindings/core/v8/DOMWrapperWorld.h" 37 #include "bindings/core/v8/DOMWrapperWorld.h"
38 #include "bindings/core/v8/ScriptController.h" 38 #include "bindings/core/v8/ScriptController.h"
39 #include "bindings/core/v8/SerializedScriptValue.h" 39 #include "bindings/core/v8/SerializedScriptValue.h"
40 #include "bindings/core/v8/V8PerIsolateData.h"
40 #include "core/HTMLNames.h" 41 #include "core/HTMLNames.h"
41 #include "core/dom/Document.h" 42 #include "core/dom/Document.h"
42 #include "core/dom/Element.h" 43 #include "core/dom/Element.h"
44 #include "core/dom/Microtask.h"
43 #include "core/dom/ViewportDescription.h" 45 #include "core/dom/ViewportDescription.h"
44 #include "core/editing/Editor.h" 46 #include "core/editing/Editor.h"
45 #include "core/editing/commands/UndoStack.h" 47 #include "core/editing/commands/UndoStack.h"
46 #include "core/events/GestureEvent.h" 48 #include "core/events/GestureEvent.h"
47 #include "core/events/KeyboardEvent.h" 49 #include "core/events/KeyboardEvent.h"
48 #include "core/events/MouseEvent.h" 50 #include "core/events/MouseEvent.h"
49 #include "core/events/PageTransitionEvent.h" 51 #include "core/events/PageTransitionEvent.h"
50 #include "core/fetch/ResourceFetcher.h" 52 #include "core/fetch/ResourceFetcher.h"
51 #include "core/fetch/ResourceLoader.h" 53 #include "core/fetch/ResourceLoader.h"
52 #include "core/frame/FrameHost.h" 54 #include "core/frame/FrameHost.h"
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 if (m_stateMachine.creatingInitialEmptyDocument()) 483 if (m_stateMachine.creatingInitialEmptyDocument())
482 return; 484 return;
483 485
484 // This can be called from the LocalFrame's destructor, in which case we sho uldn't protect ourselves 486 // This can be called from the LocalFrame's destructor, in which case we sho uldn't protect ourselves
485 // because doing so will cause us to re-enter the destructor when protector goes out of scope. 487 // because doing so will cause us to re-enter the destructor when protector goes out of scope.
486 // Null-checking the FrameView indicates whether or not we're in the destruc tor. 488 // Null-checking the FrameView indicates whether or not we're in the destruc tor.
487 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame->view() ? m_frame.get() : nul lptr); 489 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame->view() ? m_frame.get() : nul lptr);
488 490
489 m_progressTracker->finishedParsing(); 491 m_progressTracker->finishedParsing();
490 492
491 if (client()) 493 if (client()) {
492 client()->dispatchDidFinishDocumentLoad(m_documentLoader ? m_documentLoa der->isCommittedButEmpty() : true); 494 client()->dispatchDidFinishDocumentLoad(m_documentLoader ? m_documentLoa der->isCommittedButEmpty() : true);
495 Microtask::performCheckpoint(V8PerIsolateData::mainThreadIsolate());
496 if (!m_frame->view())
497 return;
498 }
493 499
494 checkCompleted(); 500 checkCompleted();
495 501
496 if (!m_frame->view()) 502 if (!m_frame->view())
497 return; // We are being destroyed by something checkCompleted called. 503 return; // We are being destroyed by something checkCompleted called.
498 504
499 // Check if the scrollbars are really needed for the content. 505 // Check if the scrollbars are really needed for the content.
500 // If not, remove them, relayout, and repaint. 506 // If not, remove them, relayout, and repaint.
501 m_frame->view()->restoreScrollbar(); 507 m_frame->view()->restoreScrollbar();
502 processFragment(m_frame->document()->url(), NavigationToDifferentDocument); 508 processFragment(m_frame->document()->url(), NavigationToDifferentDocument);
(...skipping 975 matching lines...) Expand 10 before | Expand all | Expand 10 after
1478 if (!url.isAboutSrcdocURL()) 1484 if (!url.isAboutSrcdocURL())
1479 return false; 1485 return false;
1480 HTMLFrameOwnerElement* ownerElement = m_frame->deprecatedLocalOwner(); 1486 HTMLFrameOwnerElement* ownerElement = m_frame->deprecatedLocalOwner();
1481 if (!isHTMLIFrameElement(ownerElement)) 1487 if (!isHTMLIFrameElement(ownerElement))
1482 return false; 1488 return false;
1483 return ownerElement->fastHasAttribute(srcdocAttr); 1489 return ownerElement->fastHasAttribute(srcdocAttr);
1484 } 1490 }
1485 1491
1486 void FrameLoader::dispatchDocumentElementAvailable() 1492 void FrameLoader::dispatchDocumentElementAvailable()
1487 { 1493 {
1494 // TODO(robwu): Use ScriptForbiddenScope to prevent scripts from being run
1495 // synchronously in documentElementAvailable.
1488 client()->documentElementAvailable(); 1496 client()->documentElementAvailable();
1497
1498 // Run queued microtasks (scheduled by clients of documentElementAvailable),
1499 // to make sure that the scripts run before the parser continues. This may
1500 // result in a detached frame.
1501 // If this method is called re-entrantly, then the microtask is deferred to
1502 // the next microtask checkpoint.
1503 Microtask::performCheckpoint(V8PerIsolateData::mainThreadIsolate());
1489 } 1504 }
1490 1505
1491 void FrameLoader::dispatchDidClearDocumentOfWindowObject() 1506 void FrameLoader::dispatchDidClearDocumentOfWindowObject()
1492 { 1507 {
1493 if (!m_frame->script().canExecuteScripts(NotAboutToExecuteScript)) 1508 if (!m_frame->script().canExecuteScripts(NotAboutToExecuteScript))
1494 return; 1509 return;
1495 1510
1496 InspectorInstrumentation::didClearDocumentOfWindowObject(m_frame); 1511 InspectorInstrumentation::didClearDocumentOfWindowObject(m_frame);
1497 1512
1498 if (m_dispatchingDidClearWindowObjectInMainWorld) 1513 if (m_dispatchingDidClearWindowObjectInMainWorld)
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1561 // FIXME: We need a way to propagate insecure requests policy flags to 1576 // FIXME: We need a way to propagate insecure requests policy flags to
1562 // out-of-process frames. For now, we'll always use default behavior. 1577 // out-of-process frames. For now, we'll always use default behavior.
1563 if (!parentFrame->isLocalFrame()) 1578 if (!parentFrame->isLocalFrame())
1564 return nullptr; 1579 return nullptr;
1565 1580
1566 ASSERT(toLocalFrame(parentFrame)->document()); 1581 ASSERT(toLocalFrame(parentFrame)->document());
1567 return toLocalFrame(parentFrame)->document()->insecureNavigationsToUpgrade() ; 1582 return toLocalFrame(parentFrame)->document()->insecureNavigationsToUpgrade() ;
1568 } 1583 }
1569 1584
1570 } // namespace blink 1585 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698