2018-10-24 11:24:11 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-20 17:30:26 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								From: Cheng Zhao <zcbenz@gmail.com>
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								Date: Thu, 20 Sep 2018 17:45:03 -0700
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								Subject: blink_local_frame.patch
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								According to electron/electron#3699, it is unreliable to use |unload|
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								event for process.exit('exit'), so we have to do that in
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								willReleaseScriptContext.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-01-12 15:31:23 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								Refs changes in:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								* https://codereview.chromium.org/1657583002
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								* https://chromium-review.googlesource.com/c/chromium/src/+/2596880
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								* https://chromium-review.googlesource.com/c/chromium/src/+/2597169
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-20 17:30:26 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-01-12 15:31:23 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								This patch reverts the changes to fix associated crashes in Electron.
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-20 17:30:26 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-01-12 15:31:23 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								diff --git a/third_party/blink/renderer/core/frame/frame.cc b/third_party/blink/renderer/core/frame/frame.cc
							 | 
						
					
						
							
								
									
										
										
										
											2025-01-10 10:52:34 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								index e662d4d61595735a30d5c721147a95698d4da3d9..6a0388aad469422dd1c0c2164f8aa858c55cce70 100644
							 | 
						
					
						
							
								
									
										
										
										
											2021-01-12 15:31:23 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								--- a/third_party/blink/renderer/core/frame/frame.cc
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+++ b/third_party/blink/renderer/core/frame/frame.cc
							 | 
						
					
						
							
								
									
										
										
										
											2024-11-25 10:45:47 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -134,14 +134,6 @@ bool Frame::Detach(FrameDetachType type) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-01-12 15:31:23 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   DCHECK(!IsDetached());
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								-  // TODO(dcheng): FocusController::FrameDetached() *should* fire JS events,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								-  // hence the above check for `client_` being null. However, when this was
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								-  // previously placed before the `FrameDetached()` call, nothing crashes, which
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								-  // is suspicious. Investigate if we really don't need to fire JS events--and
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								-  // if we don't, move `forbid_scripts` up to be instantiated sooner and
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								-  // simplify this code.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								-  ScriptForbiddenScope forbid_scripts;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   if (type == FrameDetachType::kRemove) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								     if (provisional_frame_) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								       provisional_frame_->Detach(FrameDetachType::kRemove);
							 | 
						
					
						
							
								
									
										
										
										
											2024-11-25 10:45:47 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -165,6 +157,14 @@ bool Frame::Detach(FrameDetachType type) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-01-12 15:31:23 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     GetWindowProxyManager()->ClearForSwap();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+  // TODO(dcheng): FocusController::FrameDetached() *should* fire JS events,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+  // hence the above check for `client_` being null. However, when this was
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+  // previously placed before the `FrameDetached()` call, nothing crashes, which
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+  // is suspicious. Investigate if we really don't need to fire JS events--and
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+  // if we don't, move `forbid_scripts` up to be instantiated sooner and
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+  // simplify this code.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+  ScriptForbiddenScope forbid_scripts;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   // After this, we must no longer talk to the client since this clears
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   // its owning reference back to our owning LocalFrame.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   client_->Detached(type);
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-13 22:02:16 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								diff --git a/third_party/blink/renderer/core/frame/local_frame.cc b/third_party/blink/renderer/core/frame/local_frame.cc
							 | 
						
					
						
							
								
									
										
										
										
											2025-02-06 15:30:54 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								index 45f2159c6fdfc277850d10697aa1f42cd2f72095..137fd9845e72adbe8792207cb620caf7ec2a5bff 100644
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-13 22:02:16 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								--- a/third_party/blink/renderer/core/frame/local_frame.cc
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+++ b/third_party/blink/renderer/core/frame/local_frame.cc
							 | 
						
					
						
							
								
									
										
										
										
											2025-01-10 10:52:34 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -748,10 +748,6 @@ bool LocalFrame::DetachImpl(FrameDetachType type) {
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-13 22:02:16 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   }
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-21 01:00:36 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								   DCHECK(!view_ || !view_->IsAttached());
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-13 22:02:16 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								-  // This is the earliest that scripting can be disabled:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								-  // - FrameLoader::Detach() can fire XHR abort events
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								-  // - Document::Shutdown() can dispose plugins which can run script.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								-  ScriptForbiddenScope forbid_script;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   if (!Client())
							 | 
						
					
						
							
								
									
										
										
										
											2021-01-12 15:31:23 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     return false;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2025-01-10 10:52:34 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -805,6 +801,11 @@ bool LocalFrame::DetachImpl(FrameDetachType type) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-01-12 15:31:23 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								   DCHECK(!view_->IsAttached());
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   Client()->WillBeDetached();
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-13 22:02:16 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+  // This is the earliest that scripting can be disabled:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+  // - FrameLoader::Detach() can fire XHR abort events
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+  // - Document::Shutdown() can dispose plugins which can run script.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+  ScriptForbiddenScope forbid_script;
							 | 
						
					
						
							
								
									
										
										
										
											2021-01-12 15:31:23 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-13 22:02:16 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   // TODO(crbug.com/729196): Trace why LocalFrameView::DetachFromLayout crashes.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   CHECK(!view_->IsAttached());
							 | 
						
					
						
							
								
									
										
										
										
											2021-01-12 15:31:23 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								   SetView(nullptr);
							 |