fix: redirect webview navigation methods (#42981)
This commit is contained in:
		
					parent
					
						
							
								55e7a47d70
							
						
					
				
			
			
				commit
				
					
						4286234721
					
				
			
		
					 2 changed files with 22 additions and 10 deletions
				
			
		| 
						 | 
				
			
			@ -2,7 +2,7 @@ import { webContents } from 'electron/main';
 | 
			
		|||
import { ipcMainInternal } from '@electron/internal/browser/ipc-main-internal';
 | 
			
		||||
import * as ipcMainUtils from '@electron/internal/browser/ipc-main-internal-utils';
 | 
			
		||||
import { parseWebViewWebPreferences } from '@electron/internal/browser/parse-features-string';
 | 
			
		||||
import { syncMethods, asyncMethods, properties } from '@electron/internal/common/web-view-methods';
 | 
			
		||||
import { syncMethods, asyncMethods, properties, navigationHistorySyncMethods } from '@electron/internal/common/web-view-methods';
 | 
			
		||||
import { webViewEvents } from '@electron/internal/browser/web-view-events';
 | 
			
		||||
import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages';
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -311,6 +311,14 @@ handleMessageSync(IPC_MESSAGES.GUEST_VIEW_MANAGER_CALL, function (event, guestIn
 | 
			
		|||
  if (!syncMethods.has(method)) {
 | 
			
		||||
    throw new Error(`Invalid method: ${method}`);
 | 
			
		||||
  }
 | 
			
		||||
  // Redirect history methods to updated navigationHistory property on webContents. See issue #42879.
 | 
			
		||||
  if (navigationHistorySyncMethods.has(method)) {
 | 
			
		||||
    let navigationMethod = method;
 | 
			
		||||
    if (method === 'clearHistory') {
 | 
			
		||||
      navigationMethod = 'clear';
 | 
			
		||||
    }
 | 
			
		||||
    return (guest as any).navigationHistory[navigationMethod](...args);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return (guest as any)[method](...args);
 | 
			
		||||
});
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue