Skip to content

Commit

Permalink
Bug 1691814 - [remote] Improve failure message for timestamp assertio…
Browse files Browse the repository at this point in the history
…ns. r=remote-protocol-reviewers,jdescottes

Differential Revision: https://phabricator.services.mozilla.com/D104578
  • Loading branch information
whimboo committed Feb 13, 2021
1 parent 198eb87 commit a8048b6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
8 changes: 4 additions & 4 deletions remote/test/browser/page/browser_domContentEventFired.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ async function runContentEventFiredTest(client, expectedEventCount, callback) {
},
});

const timeStart = Date.now() / 1000;
const timeBefore = Date.now() / 1000;
await callback();
const domContentEventFiredEvents = await history.record();
const timeEnd = Date.now() / 1000;
const timeAfter = Date.now() / 1000;

is(
domContentEventFiredEvents.length,
Expand All @@ -98,7 +98,7 @@ async function runContentEventFiredTest(client, expectedEventCount, callback) {

const timestamp = domContentEventFiredEvents[0].payload.timestamp;
ok(
timestamp >= timeStart && timestamp <= timeEnd,
`Timestamp in expected range [${timeStart} - ${timeEnd}]`
timestamp >= timeBefore && timestamp <= timeAfter,
`Timestamp ${timestamp} in expected range [${timeBefore} - ${timeAfter}]`
);
}
8 changes: 4 additions & 4 deletions remote/test/browser/page/browser_loadEventFired.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ async function runLoadEventFiredTest(client, expectedEventCount, callback) {
},
});

const timeStart = Date.now() / 1000;
const timeBefore = Date.now() / 1000;
await callback();
const loadEventFiredEvents = await history.record();
const timeEnd = Date.now() / 1000;
const timeAfter = Date.now() / 1000;

is(
loadEventFiredEvents.length,
Expand All @@ -98,7 +98,7 @@ async function runLoadEventFiredTest(client, expectedEventCount, callback) {

const timestamp = loadEventFiredEvents[0].payload.timestamp;
ok(
timestamp >= timeStart && timestamp <= timeEnd,
`Timestamp in expected range [${timeStart} - ${timeEnd}]`
timestamp >= timeBefore && timestamp <= timeAfter,
`Timestamp ${timestamp} in expected range [${timeBefore} - ${timeAfter}]`
);
}
6 changes: 4 additions & 2 deletions remote/test/browser/runtime/browser_consoleAPICalled.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,11 @@ async function runConsoleTest(client, eventCount, callback, options = {}) {

// Check basic details for consoleAPICalled events
consoleAPIentries.forEach(({ payload }) => {
const timestamp = payload.timestamp;

ok(
payload.timestamp >= timeBefore && payload.timestamp <= timeAfter,
"Got valid timestamp"
timestamp >= timeBefore && timestamp <= timeAfter,
`Timestamp ${timestamp} in expected range [${timeBefore} - ${timeAfter}]`
);
});

Expand Down
2 changes: 1 addition & 1 deletion remote/test/browser/runtime/browser_exceptionThrown.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ async function runExceptionThrownTest(
is(typeof details, "object", "Got expected 'exceptionDetails' property");
ok(
timestamp >= timeBefore && timestamp <= timeAfter,
"Got valid timestamp"
`Timestamp ${timestamp} in expected range [${timeBefore} - ${timeAfter}]`
);
});

Expand Down

0 comments on commit a8048b6

Please sign in to comment.