/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
var { DelayedInit } = ChromeUtils.importESModule( "resource://gre/modules/DelayedInit.sys.mjs"
); var { XPCOMUtils } = ChromeUtils.importESModule( "resource://gre/modules/XPCOMUtils.sys.mjs"
);
// By default all layers are discarded when a browser is set to inactive. // GeckoView by default sets browsers to inactive every time they're not // visible. To avoid flickering when changing tabs, we preserve layers for // all loaded tabs.
browser.preserveLayers(true); // GeckoView browsers start off as active (for now at least). // See bug 1815015 for an attempt at making them start off inactive.
browser.docShellIsActive = true;
// Defer a notification callback if an applink navigation is in progress, // waiting for the navigation to complete (or a timeout) before idle- // dispatching the callback. Fires immediately if no applink is pending.
_maybeDeferForApplink(notifyFn, timeoutMs = 5000) { const applinkNav = this._applinkNavigation; if (applinkNav) { const timeoutPromise = new Promise(resolve => {
setTimeout(resolve, timeoutMs);
});
Promise.race([applinkNav.promise, timeoutPromise]).then(() => { this._applinkNavigation = null;
Services.tm.idleDispatchToMainThread(notifyFn);
});
} else {
notifyFn();
}
},
case"GeckoView:UpdateInitData": { // Replace all settings during a transfer. const initData = this._initData; this._updateSettings(initData.settings);
// Update module enabled states. for (const name in initData.modules) { const module = this._modules.get(name); if (module) {
module.enabled = initData.modules[name];
}
} break;
}
// We don't support having more than one main process script, so let's // check that we're not accidentally defining two. We could support this if // needed by making _impl an array for each phase impl. if (onInit?.resource !== undefined && onEnable?.resource !== undefined) { thrownew Error( "Only one main process script is allowed for each module."
);
}
this._impl = null; this._contentModuleLoaded = false; this._enabled = false; // Only enable once we performed initialization. this._enabledOnInit = enabled;
// For init, load resource _before_ initializing browser to support the // onInitBrowser() override. However, load content module after initializing // browser, because we don't have a message manager before then. this._loadResource(onInit); this._loadActors(onInit); if (this._enabledOnInit) { this._loadActors(onEnable);
}
function createBrowser(settings) { const browser = (window.browser = document.createXULElement("browser")); // Identify this `<browser>` element uniquely to Marionette, devtools, etc. // Use the JSM global to create the permanentKey, so that if the // permanentKey is held by something after this window closes, it // doesn't keep the window alive. See also Bug 1501789.
browser.permanentKey = new (Cu.getGlobalForObject(Services).Object)();
// This is only needed for mochitests, so that they honor the // prefers-color-scheme.content-override pref. GeckoView doesn't set this // pref to anything other than the default value otherwise.
browser.style.colorScheme = "env(-moz-content-preferred-color-scheme)";
return browser;
}
function InitLater(fn, object, name) {
return DelayedInit.schedule(fn, object, name, 15000/* 15s max wait */);
}
function startup() {
GeckoViewUtils.initLogging("XUL", window);
Services.tm.dispatchToMainThread(() => { // This should always be the first thing we do here - any additional delayed // initialisation tasks should be added between "browser-delayed-startup-finished" // and "browser-idle-startup-tasks-finished".
// Bug 1496684: Various bits of platform stuff depend on this notification // to learn when a browser window has finished its initial (chrome) // initialisation, especially with regards to the very first window that is // created. Therefore, GeckoView "windows" need to send this, too.
InitLater(() =>
Services.obs.notifyObservers(window, "browser-delayed-startup-finished")
);
// Let the extension code know it can start loading things that were delayed // while GeckoView started up.
InitLater(() => {
window.moduleManager._maybeDeferForApplink(() => {
Services.obs.notifyObservers(window, "extensions-late-startup");
});
});
InitLater(() => { // TODO bug 1730026: this runs too often. It should run once.
RemoteSecuritySettings.init();
});
InitLater(() => { // Initialize safe browsing module. This is required for content // blocking features and manages blocklist downloads and updates.
SafeBrowsing.init();
});
InitLater(() => { // It's enough to run this once to set up FOG. // (See also bug 1730026.)
Services.fog.registerCustomPings();
});
InitLater(() => { // Initialize the blocklist module. // TODO bug 1730026: this runs too often. It should run once.
Blocklist.loadBlocklistAsync();
});
InitLater(() => { // Call the init function for the CaptchaDetectionPingUtils module. // This function adds pref observers that flushes the ping. It also // submits the ping if it has data and has been about 24 hours since the // last submission.
CaptchaDetectionPingUtils.init();
});
// This should always go last, since the idle tasks (except for the ones with // timeouts) should execute in order. Note that this observer notification is // not guaranteed to fire, since the window could close before we get here.
// This notification in particular signals the ScriptPreloader that we have // finished startup, so it can now stop recording script usage and start // updating the startup cache for faster script loading.
InitLater(() =>
Services.obs.notifyObservers(
window, "browser-idle-startup-tasks-finished"
)
);
});
// Move focus to the content window at the end of startup, // so things like text selection can work properly.
ModuleManager.browser.focus();
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.