diff --git a/browser/base/content/test/performance/browser_startup_content.js b/browser/base/content/test/performance/browser_startup_content.js index 9bb6d3338588..0af5b56ba630 100644 --- a/browser/base/content/test/performance/browser_startup_content.js +++ b/browser/base/content/test/performance/browser_startup_content.js @@ -98,6 +98,7 @@ const intermittently_loaded_whitelist = { // Test related "resource://testing-common/BrowserTestUtilsChild.jsm", + "resource://testing-common/ContentEventListenerChild.jsm", ]), frameScripts: new Set([]), processScripts: new Set([ diff --git a/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm b/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm index ca7c57fac5f2..c29dde762f94 100644 --- a/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm +++ b/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm @@ -77,10 +77,11 @@ const kAboutPageRegistrationContentScript = "chrome://mochikit/content/tests/BrowserTestUtils/content-about-page-utils.js"; /** - * Create and register BrowserTestUtils Window Actor. + * Create and register the BrowserTestUtils and ContentEventListener window + * actors. */ -function registerActor() { - let actorOptions = { +function registerActors() { + ChromeUtils.registerWindowActor("BrowserTestUtils", { parent: { moduleURI: "resource://testing-common/BrowserTestUtilsParent.jsm", }, @@ -93,30 +94,25 @@ function registerActor() { }, allFrames: true, includeChrome: true, - }; - ChromeUtils.registerWindowActor("BrowserTestUtils", actorOptions); -} + }); -function registerContentEventListenerActor() { - let actorOptions = { + ChromeUtils.registerWindowActor("ContentEventListener", { parent: { moduleURI: "resource://testing-common/ContentEventListenerParent.jsm", }, - child: { moduleURI: "resource://testing-common/ContentEventListenerChild.jsm", events: { // We need to see the creation of all new windows, in case they have - // a browsing context we are interesting in. + // a browsing context we are interested in. DOMWindowCreated: { capture: true }, }, }, allFrames: true, - }; - ChromeUtils.registerWindowActor("ContentEventListener", actorOptions); + }); } -registerActor(); +registerActors(); var BrowserTestUtils = { /** @@ -527,8 +523,6 @@ var BrowserTestUtils = { _contentEventListeners: new Map(), - _contentEventListenerActorRegistered: false, - /** * Waits for the web progress listener associated with this tab to fire a * STATE_STOP for the toplevel document. @@ -1238,10 +1232,6 @@ var BrowserTestUtils = { * fire until it is removed. A callable object is returned that, * when called, removes the event listener. Note that this function * works even if the browser's frameloader is swapped. - * Note: This will only listen for events that either have the browsing - * context of the browser element at the time of the call, or that are fired - * on windows that were created after any call to the function since the start - * of the test. This could be improved if needed. * * @param {xul:browser} browser * The browser element to listen for events in. @@ -1286,35 +1276,6 @@ var BrowserTestUtils = { ); Services.ppmm.sharedData.flush(); - if (!this._contentEventListenerActorRegistered) { - this._contentEventListenerActorRegistered = true; - registerContentEventListenerActor(); - - // We hadn't registered the actor yet, so any existing window - // for browser's BC will not have been created yet. Explicitly - // make sure the actors are created and ready to go now. This - // happens after the updating of sharedData so that the actors - // don't have to get created and do nothing, and then later have - // to be updated. - // Note: As mentioned in the comment at the start of this function, - // this will miss any windows that existed at the time that the function - // was initially called during this test, but that did not have the - // browser's browsing context. - let contextsToVisit = [browser.browsingContext]; - while (contextsToVisit.length) { - let currentContext = contextsToVisit.pop(); - let global = currentContext.currentWindowGlobal; - if (!global) { - continue; - } - let actor = browser.browsingContext.currentWindowGlobal.getActor( - "ContentEventListener" - ); - actor.sendAsyncMessage("ContentEventListener:LateCreate"); - contextsToVisit.push(...currentContext.getChildren()); - } - } - let unregisterFunction = function() { if (!eventListenerState.has(id)) { return; diff --git a/testing/mochitest/BrowserTestUtils/ContentEventListenerChild.jsm b/testing/mochitest/BrowserTestUtils/ContentEventListenerChild.jsm index 6a7c8b40d16d..d1cb12caa4f3 100644 --- a/testing/mochitest/BrowserTestUtils/ContentEventListenerChild.jsm +++ b/testing/mochitest/BrowserTestUtils/ContentEventListenerChild.jsm @@ -25,13 +25,6 @@ class ContentEventListenerChild extends JSWindowActorChild { } } - receiveMessage(msg) { - if (msg.name != "ContentEventListener:LateCreate") { - return; - } - this._updateContentEventListeners(); - } - handleEvent(event) { switch (event.type) { case "DOMWindowCreated": {