Bug 1372261 - Make tps Talos test use the performance timing API instead of Date.now() to avoid clock skew. r?jmaher
MozReview-Commit-ID: CPzaN7T5fJV
--- a/testing/talos/talos/tests/tabswitch/bootstrap.js
+++ b/testing/talos/talos/tests/tabswitch/bootstrap.js
@@ -160,19 +160,18 @@ function loadTPSContentScript(browser) {
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");
- sendAsyncMessage("TPS:ContentSawPaint", {
- time: Date.now().valueOf(),
- });
+ 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;
@@ -187,30 +186,31 @@ function loadTPSContentScript(browser) {
/**
* 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.
*/
function switchToTab(tab) {
let browser = tab.linkedBrowser;
let gBrowser = tab.ownerGlobal.gBrowser;
+ let window = tab.ownerGlobal;
// Single-process tab switching works quite differently from
// multi-process tab switching. In the single-process case, tab
// switching is synchronous, whereas in the multi-process case,
// it is not. The following two tab switching mechanisms encapsulate
// those two differences.
if (browser.isRemoteBrowser) {
return Task.spawn(function*() {
// The multi-process case requires that we load our utility script
// inside the content, since it's the content that will hear a MozAfterPaint
// once the content is presented to the user.
yield loadTPSContentScript(browser);
- let start = Date.now().valueOf();
+ let start = Math.floor(window.performance.timing.navigationStart + window.performance.now());
TalosParentProfiler.resume("start (" + start + "): " + browser.currentURI.spec);
// 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);
@@ -224,17 +224,17 @@ function switchToTab(tab) {
});
}
return Task.spawn(function*() {
let win = browser.ownerGlobal;
let winUtils = win.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
- let start = Date.now().valueOf();
+ let start = Math.floor(window.performance.timing.navigationStart + window.performance.now());
TalosParentProfiler.resume("start (" + start + "): " + browser.currentURI.spec);
// There is no async tab switcher for the single-process case,
// but tabbrowser.xml will still fire this once the updateCurrentBrowser
// method runs.
let switchDone = waitForTabSwitchDone(browser);
// Do our tab switch
gBrowser.selectedTab = tab;
@@ -313,17 +313,18 @@ function waitForContentPresented(browser
return new Promise((resolve) => {
let win = browser.ownerGlobal;
win.addEventListener("MozAfterPaint", function onPaint(event) {
if (event instanceof Ci.nsIDOMNotifyPaintEvent) {
TalosParentProfiler.mark("Content saw transaction id: " + event.transactionId);
if (event.transactionId > lastTransactionId) {
win.removeEventListener("MozAfterPaint", onPaint);
TalosParentProfiler.mark("Content saw MozAfterPaint");
- resolve(Date.now().valueOf());
+ let time = Math.floor(win.performance.timing.navigationStart + win.performance.now());
+ resolve(time);
}
}
});
});
}
/**
* Given some browser, do a garbage collect in the parent, and then