From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- .../performance/StartupContentSubframe.sys.mjs | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 browser/base/content/test/performance/StartupContentSubframe.sys.mjs (limited to 'browser/base/content/test/performance/StartupContentSubframe.sys.mjs') diff --git a/browser/base/content/test/performance/StartupContentSubframe.sys.mjs b/browser/base/content/test/performance/StartupContentSubframe.sys.mjs new file mode 100644 index 0000000000..a78e456afb --- /dev/null +++ b/browser/base/content/test/performance/StartupContentSubframe.sys.mjs @@ -0,0 +1,55 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +/** + * test helper JSWindowActors used by the browser_startup_content_subframe.js test. + */ + +export class StartupContentSubframeParent extends JSWindowActorParent { + receiveMessage(msg) { + // Tell the test about the data we received from the content process. + Services.obs.notifyObservers( + msg.data, + "startup-content-subframe-loaded-scripts" + ); + } +} + +export class StartupContentSubframeChild extends JSWindowActorChild { + async handleEvent(event) { + // When the remote subframe is loaded, an event will be fired to this actor, + // which will cause us to send the `LoadedScripts` message to the parent + // process. + // Wait a spin of the event loop before doing so to ensure we don't + // miss any scripts loaded immediately after the load event. + await new Promise(resolve => Services.tm.dispatchToMainThread(resolve)); + + const Cm = Components.manager; + Cm.QueryInterface(Ci.nsIServiceManager); + const { AppConstants } = ChromeUtils.importESModule( + "resource://gre/modules/AppConstants.sys.mjs" + ); + let collectStacks = AppConstants.NIGHTLY_BUILD || AppConstants.DEBUG; + + let modules = {}; + for (let module of Cu.loadedJSModules) { + modules[module] = collectStacks ? Cu.getModuleImportStack(module) : ""; + } + for (let module of Cu.loadedESModules) { + modules[module] = collectStacks ? Cu.getModuleImportStack(module) : ""; + } + + let services = {}; + for (let contractID of Object.keys(Cc)) { + try { + if (Cm.isServiceInstantiatedByContractID(contractID, Ci.nsISupports)) { + services[contractID] = ""; + } + } catch (e) {} + } + this.sendAsyncMessage("LoadedScripts", { + modules, + services, + }); + } +} -- cgit v1.2.3