Bug 1451460 - Get rid of more dead code from the TPS Talos test. r?rwood draft
authorMike Conley <mconley@mozilla.com>
Thu, 05 Apr 2018 15:02:24 -0400
changeset 779378 5f853017deb3c7d8ed39ef72e0a1039db3d00561
parent 779377 7ec74ab5bc2dcea33cb2c6ec6ba1c21360bfbf65
push id105760
push usermconley@mozilla.com
push dateMon, 09 Apr 2018 20:21:39 +0000
reviewersrwood
bugs1451460
milestone61.0a1
Bug 1451460 - Get rid of more dead code from the TPS Talos test. r?rwood MozReview-Commit-ID: KpSJDSmhgiM
testing/talos/talos/tests/tabswitch/api.js
--- a/testing/talos/talos/tests/tabswitch/api.js
+++ b/testing/talos/talos/tests/tabswitch/api.js
@@ -4,28 +4,16 @@
 
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://gre/modules/RemotePageManager.jsm");
 
 let context = {};
 let TalosParentProfiler;
 
-function promiseOneEvent(target, eventName, capture) {
-  return new Promise(resolve => {
-    target.addEventListener(eventName, function handler(event) {
-      resolve();
-    }, {capture, once: true});
-  });
-}
-
-function executeSoon(callback) {
-  Services.tm.dispatchToMainThread(callback);
-}
-
 /**
  * Returns a Promise that resolves when browser-delayed-startup-finished
  * fires for a given window
  *
  * @param win
  *        The window that we're waiting for the notification for.
  * @returns Promise
  */
@@ -84,84 +72,24 @@ function loadTabs(gBrowser, urls) {
       },
     };
 
     gBrowser.addTabsProgressListener(listener);
   });
 }
 
 /**
- * Loads the utility content script for the tps for out-of-process
- * browsers into a browser. This should not be used for in-process
- * browsers.
- *
- * The utility script will send a "TPS:ContentSawPaint" message
- * through the browser's message manager when it sees that its
- * content has been presented to the user.
- *
- * @param browser (<xul:browser>)
- *        The remote browser to load the script in.
- * @returns Promise
- *        Resolves once the script has been loaded and executed in
- *        the remote browser.
- */
-function loadTPSContentScript(browser) {
-  return new Promise((resolve) => {
-    // Here's our utility script. We'll serialize this and send it down
-    // to run in the content process for this browser.
-    let script = function() {
-      ChromeUtils.import("resource://gre/modules/Services.jsm");
-
-      /**
-       * In order to account for the fact that a MozAfterPaint might fire
-       * for a composite that's unrelated to this tab's content being
-       * painted, we'll get the last used layer transaction ID for
-       * this content's refresh driver, and make sure that the MozAfterPaint
-       * that we react to has a greater transaction id.
-       *
-       * Note also that this comment needs to stay inside this comment
-       * block. No // comments allowed when serializing JS to content
-       * scripts this way.
-       */
-      let cwu = content.QueryInterface(Ci.nsIInterfaceRequestor)
-                       .getInterface(Ci.nsIDOMWindowUtils);
-      let lastTransactionId = cwu.lastTransactionId;
-      Services.profiler.AddMarker("Content waiting for id > " + lastTransactionId);
-      addEventListener("MozAfterPaint", function onPaint(event) {
-        Services.profiler.AddMarker("Content saw transaction id: " + event.transactionId);
-        if (event.transactionId > lastTransactionId) {
-          Services.profiler.AddMarker("Content saw correct MozAfterPaint");
-          let time = Math.floor(content.performance.timing.navigationStart + content.performance.now());
-          sendAsyncMessage("TPS:ContentSawPaint", { time });
-          removeEventListener("MozAfterPaint", onPaint);
-        }
-      });
-
-      sendAsyncMessage("TPS:ContentReady");
-    };
-
-    let mm = browser.messageManager;
-    mm.loadFrameScript("data:,(" + script.toString() + ")();", true);
-    mm.addMessageListener("TPS:ContentReady", function onReady() {
-      mm.removeMessageListener("TPS:ContentReady", onReady);
-      resolve();
-    });
-  });
-}
-
-/**
  * For some <xul:tab> in a browser window, have that window switch
  * to that tab. Returns a Promise that resolves ones the tab content
  * has been presented to the user.
  */
 async function switchToTab(tab) {
   let browser = tab.linkedBrowser;
   let gBrowser = tab.ownerGlobal.gBrowser;
 
-  await loadTPSContentScript(browser);
   let start = Cu.now();
 
   // We need to wait for the TabSwitchDone event to make sure
   // that the async tab switcher has shut itself down.
   let switchDone = waitForTabSwitchDone(browser);
   // Set up our promise that will wait for the content to be
   // presented.
   let finishPromise = waitForContentPresented(browser);
@@ -374,48 +302,36 @@ function handleFile(win, file) {
     if (a.split('\"')[0] != "") {
       testURLs.push(parent + "tp5n/" + a.split('\"')[0]);
     }
   });
 
   return testURLs;
 }
 
-var observer = {
-  observe(aSubject, aTopic, aData) {
-    if (aTopic == "tabswitch-urlfile") {
-      handleFile(aSubject, aData);
-    }
-  }
-};
-
 var remotePage;
 
 this.tps = class extends ExtensionAPI {
   getAPI(context) {
     return {
       tps: {
         setup({ frameScriptPath }) {
           const AboutNewTabService = Cc["@mozilla.org/browser/aboutnewtab-service;1"]
                                        .getService(Ci.nsIAboutNewTabService);
           AboutNewTabService.newTabURL = "about:blank";
 
-          // Load into any new windows
-          Services.obs.addObserver(observer, "tabswitch-urlfile");
-
           const frameScriptURL = context.extension.baseURI.resolve(frameScriptPath);
           Services.ppmm.loadFrameScript(frameScriptURL, true);
           remotePage = new RemotePages("about:tabswitch");
           remotePage.addMessageListener("tabswitch-do-test", function doTest(msg) {
             test(msg.target.browser.ownerGlobal);
           });
 
           return () => {
             Services.ppmm.sendAsyncMessage("TPS:Teardown");
-            Services.obs.removeObserver(observer, "tabswitch-urlfile");
             remotePage.destroy();
             AboutNewTabService.resetNewTabURL();
           };
         }
       }
     };
   }
 };