| 
									
										
										
										
											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. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | However Chromium then disallowed scripting in willReleaseScriptContext | 
					
						
							|  |  |  | in https://codereview.chromium.org/1657583002, and crash will happen | 
					
						
							|  |  |  | when there is code doing that. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | This patch reverts the change to fix the crash in Electron. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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
 | 
					
						
							| 
									
										
										
										
											2019-01-24 15:12:21 +05:30
										 |  |  | index e07ace500ef1dd60ce9833e7324e238de1018ae6..950c5ff5b14129ab2ca4b8c929ff583b5523b04b 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
 | 
					
						
							| 
									
										
										
										
											2019-01-16 23:37:52 +05:30
										 |  |  | @@ -403,10 +403,6 @@ void LocalFrame::DetachImpl(FrameDetachType type) {
 | 
					
						
							| 
									
										
										
										
											2018-09-13 22:02:16 -07:00
										 |  |  |    } | 
					
						
							|  |  |  |    CHECK(!view_ || !view_->IsAttached()); | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  | -  // 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()) | 
					
						
							|  |  |  |      return; | 
					
						
							|  |  |  |   | 
					
						
							| 
									
										
										
										
											2019-01-16 23:37:52 +05:30
										 |  |  | @@ -424,6 +420,10 @@ void LocalFrame::DetachImpl(FrameDetachType type) {
 | 
					
						
							| 
									
										
										
										
											2018-09-13 22:02:16 -07:00
										 |  |  |    // Notify ScriptController that the frame is closing, since its cleanup ends | 
					
						
							|  |  |  |    // up calling back to LocalFrameClient via WindowProxy. | 
					
						
							|  |  |  |    GetScriptController().ClearForClose(); | 
					
						
							|  |  |  | +  // 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;
 | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  |    // TODO(crbug.com/729196): Trace why LocalFrameView::DetachFromLayout crashes. | 
					
						
							|  |  |  |    CHECK(!view_->IsAttached()); |