mirror of
https://github.com/electron/electron.git
synced 2026-10-28 11:44:46 +08:00
* feat: preload script URL filters * feat: reject an empty preload script matches array An explicit `matches: []` meant "every URL", the same ambiguity webRequest filters dropped in favor of `<all_urls>`. Registering one now throws and points at `<all_urls>`; omitting `matches` still matches every URL, so existing registrations are unaffected. Also adds coverage that `<all_urls>` matches both an http page and about:blank. * docs: link preload URL filters to MDN match patterns Matches the webRequest filter docs, which already link to MDN. * test: extension protocol * feat: add matchOriginAsFallback to preload script URL filters A document whose URL has no origin of its own (about:, blob:, data:, filesystem:) was only matched by its literal URL, so an about:blank popup escaped its opener's excludeMatches and excludeGlobs. With matchOriginAsFallback, frame preloads match such documents by the origin they inherited from their creator, like match_origin_as_fallback for content scripts. * fix: reject an empty preload script includeGlobs array An explicitly empty includeGlobs array converted to the same state as an omitted one, so the preload ran for every URL instead of none. Reject it at registration, as an empty matches array already is. * test: use vitest assertions in preload URL filter specs main dropped chai in #54439, so the chai-style assertions these specs added no longer match the rest of the suite, and the dirty-chai call forms (to.be.empty(), to.be.false()) are no longer available. * fix: address review feedback on preload script URL filters - Match a data: URL loaded with baseURLForDataURL by its base URL, which is the URL the document commits at. - Never match when URL patterns were not parsed, instead of matching every URL. - Explain a scheme separator mismatch in the invalid pattern error. - Document custom scheme requirements, error page matching and opaque origins with matchOriginAsFallback. - Add specs for baseURLForDataURL, subframes and redirects. * docs: list preload script URL filter conditions Break the URL filter description for ses.registerPreloadScript into bullet lists, and note that in-page navigations do not rerun the preload script.
Official Guides
Please make sure that you use the documents that match your Electron version. The version number should be a part of the page URL. If it's not, you are probably using the documentation of a development branch which may contain API changes that are not compatible with your Electron version. To view older versions of the documentation, you can browse by tag on GitHub by opening the "Switch branches/tags" dropdown and selecting the tag that matches your version.
FAQ
There are questions that are asked quite often. Check this out before creating an issue:
Guides and Tutorials
Getting started
Learning the basics
- Adding Features to Your App
- Notifications
- Recent Documents
- Application Progress
- Custom Dock Menu
- Custom Windows Taskbar
- Custom Linux Desktop Actions
- Keyboard Shortcuts
- Offline/Online Detection
- Represented File for macOS BrowserWindows
- Native File Drag & Drop
- Navigation History
- Window State Persistence
- Offscreen Rendering
- Dark Mode
- Web embeds in Electron
Advanced steps
- Application Architecture
- Accessibility
- Testing and Debugging
- Distribution
- Updates
- Getting Support
Detailed Tutorials
These individual tutorials expand on topics discussed in the guide above.
- Installing Electron
- Electron Releases & Developer Feedback
API References
- Process Object
- Supported Command Line Switches
- Environment Variables
- Chrome Extensions Support
- Breaking API Changes
Custom Web Features:
Modules for the Main Process:
- app
- autoUpdater
- BaseWindow
- BrowserWindow
- contentTracing
- desktopCapturer
- dialog
- globalShortcut
- inAppPurchase
- ImageView
- ipcMain
- Menu
- MenuItem
- MessageChannelMain
- MessagePortMain
- nativeTheme
- net
- netLog
- Notification
- powerMonitor
- powerSaveBlocker
- protocol
- pushNotifications
- safeStorage
- screen
- ServiceWorkerMain
- session
- ShareMenu
- systemPreferences
- TouchBar
- Tray
- utilityProcess
- View
- webContents
- webFrameMain
- WebContentsView
Modules for the Renderer Process (Web Page):
Modules for Both Processes:
- clipboard (non-sandboxed renderers only)
- crashReporter
- nativeImage
- shell (non-sandboxed renderers only)