mirror of https://github.com/gorhill/uBlock.git
Create synthetic event for new windows created from external application
Related discussion: - https://github.com/uBlockOrigin/uAssets/issues/10323#issuecomment-993592288 Synthesize a onCreatedNavigationTarget event for new browser windows created as a result of an external application triggering a navigation event.
This commit is contained in:
parent
01f87e979e
commit
89e67887ee
|
@ -28,6 +28,8 @@
|
||||||
// https://github.com/uBlockOrigin/uBlock-issues/issues/1659
|
// https://github.com/uBlockOrigin/uBlock-issues/issues/1659
|
||||||
// Chromium fails to dispatch onCreatedNavigationTarget() events sometimes,
|
// Chromium fails to dispatch onCreatedNavigationTarget() events sometimes,
|
||||||
// so we synthetize these missing events when this happens.
|
// so we synthetize these missing events when this happens.
|
||||||
|
// https://github.com/uBlockOrigin/uAssets/issues/10323
|
||||||
|
// Also mind whether the new tab is launched from an external application.
|
||||||
|
|
||||||
vAPI.Tabs = class extends vAPI.Tabs {
|
vAPI.Tabs = class extends vAPI.Tabs {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -65,12 +67,11 @@ vAPI.Tabs = class extends vAPI.Tabs {
|
||||||
synthesizeNavigationTargetEvent(details) {
|
synthesizeNavigationTargetEvent(details) {
|
||||||
if ( this.tabIds.has(details.tabId) === false ) { return; }
|
if ( this.tabIds.has(details.tabId) === false ) { return; }
|
||||||
this.tabIds.delete(details.tabId);
|
this.tabIds.delete(details.tabId);
|
||||||
if (
|
const isClientRedirect =
|
||||||
Array.isArray(details.transitionQualifiers) === false ||
|
Array.isArray(details.transitionQualifiers) &&
|
||||||
details.transitionQualifiers.includes('client_redirect') === false
|
details.transitionQualifiers.includes('client_redirect');
|
||||||
) {
|
const isStartPage = details.transitionType === 'start_page';
|
||||||
return;
|
if ( isClientRedirect === false && isStartPage === false ) { return; }
|
||||||
}
|
|
||||||
this.onCreatedNavigationTargetHandler({
|
this.onCreatedNavigationTargetHandler({
|
||||||
tabId: details.tabId,
|
tabId: details.tabId,
|
||||||
sourceTabId: details.tabId,
|
sourceTabId: details.tabId,
|
||||||
|
|
Loading…
Reference in New Issue