Skip to content

Commit

Permalink
Vomnibar: not use onunload to avoid console warnings
Browse files Browse the repository at this point in the history
if a page use CSP to limit unload events, then there will be a warning
  • Loading branch information
gdh1995 committed Mar 7, 2024
1 parent 2a1b87d commit dae2bc1
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion background/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ if (Build.MV3 && !OnFirefox && (!OnChrome || Build.MinCVer < BrowserVer.MinCSAcc

// @ts-ignore // will run only on <kbd>F5</kbd>, not on runtime.reload
Build.MV3 || ((window as Window) // `window.` is necessary on Chrome 32
.onunload = (): void => {
.onpagehide = (): void => {
for (let port of framesForOmni_) {
port.disconnect()
}
Expand Down
2 changes: 1 addition & 1 deletion content/local_links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { find_box } from "./mode_find"
import { omni_box } from "./omni"
import {
kSafeAllSelector, coreHints, addChildFrame_, mode1_, forHover_, hintOptions, wantDialogMode_,
isClickListened_, set_isClickListened_, tooHigh_, useFilter_, hintChars, hintManager, hintMode_
isClickListened_, set_isClickListened_, tooHigh_, useFilter_, hintChars, hintManager
} from "./link_hints"
import { shouldScroll_s, getPixelScaleToScroll, scrolled, set_scrolled, suppressScroll } from "./scroller"
import { ui_root, ui_box, helpBox, curModalElement, filterOutInert } from "./dom_ui"
Expand Down
6 changes: 3 additions & 3 deletions front/vomnibar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1737,7 +1737,7 @@ var VCID_: string | undefined = VCID_ || "", VHost_: string | undefined = VHost_
? e.isTrusted : e.isTrusted !== false) && VPort_._port && doRefresh_(17)
};
},
OnUnload_ (e?: Event): void {
OnPageHide_ (e?: Event): void {
if (!VPort_
|| e && (Build.MinCVer >= BrowserVer.Min$Event$$IsTrusted || !(Build.BTypes & BrowserType.Chrome)
? !e.isTrusted : e.isTrusted === false)) { return; }
Expand Down Expand Up @@ -2026,7 +2026,7 @@ VPort_ = {
name === kBgReq.omni_returnFocus ? VPort_.postToOwner_({ N: VomnibarNS.kFReq.focus, l: response.l }) :
name === kBgReq.omni_toggleStyle ? Vomnibar_.toggleStyle_(response) :
name === kBgReq.omni_updateOptions ? Vomnibar_.updateOptions_(response) :
name === kBgReq.omni_refresh ? !Vomnibar_.isActive_ && response.d ? Vomnibar_.OnUnload_()
name === kBgReq.omni_refresh ? !Vomnibar_.isActive_ && response.d ? Vomnibar_.OnPageHide_()
: Build.MV3 ? (VPort_._port!.disconnect(), VPort_.connect_(PortType.omnibar | PortType.reconnect)) : 0 :
name === kBgReq.injectorRun || name === kBgReq.showHUD ? 0 :
0;
Expand Down Expand Up @@ -2112,7 +2112,7 @@ if (Build.BTypes === BrowserType.Chrome as number ? false : !(Build.BTypes & Bro
removeEventListener("message", onUnknownMsg, true);
VPort_.postToOwner_ = port.postMessage.bind(port);
port.onmessage = VPort_._OnOwnerMessage;
window.onunload = Vomnibar_.OnUnload_;
window.onpagehide = Vomnibar_.OnPageHide_;
VPort_.postToOwner_({ N: VomnibarNS.kFReq.iframeIsAlive, o: options ? 1 : 0 });
if (options) {
Vomnibar_.activate_(options);
Expand Down
2 changes: 1 addition & 1 deletion pages/show.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ nextTick_((): void => {
void post_(kPgReq.showInit).then((conf): void => { setupPageOs_(conf.os) })
})

window.onunload = destroyObject_;
window.onpagehide = destroyObject_;

body.ondrop = (e): void => {
const files = e.dataTransfer.files
Expand Down

0 comments on commit dae2bc1

Please sign in to comment.