2017-01-17 20:21:38 +00:00
|
|
|
// Copyright 2017 the V8 project authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2017-05-19 00:35:45 +00:00
|
|
|
let {session, contextGroup, Protocol} = InspectorTest.start('Checks format of console.timeEnd output');
|
2017-01-17 20:21:38 +00:00
|
|
|
|
|
|
|
Protocol.Runtime.enable();
|
|
|
|
Protocol.Runtime.onConsoleAPICalled(message => {
|
|
|
|
InspectorTest.log(message.params.args[0].value);
|
|
|
|
});
|
|
|
|
|
2017-10-16 22:08:42 +00:00
|
|
|
InspectorTest.runAsyncTestSuite([
|
|
|
|
function zero() {
|
|
|
|
return checkInterval(0.0);
|
2017-01-17 20:21:38 +00:00
|
|
|
},
|
2017-10-16 22:08:42 +00:00
|
|
|
function verySmall() {
|
|
|
|
return checkInterval(1e-15);
|
2017-01-17 20:21:38 +00:00
|
|
|
},
|
2017-10-16 22:08:42 +00:00
|
|
|
function small() {
|
|
|
|
return checkInterval(0.001);
|
2017-01-17 20:21:38 +00:00
|
|
|
},
|
2017-10-16 22:08:42 +00:00
|
|
|
function regular() {
|
|
|
|
return checkInterval(1.2345);
|
2017-01-17 20:21:38 +00:00
|
|
|
},
|
2017-10-16 22:08:42 +00:00
|
|
|
function big() {
|
|
|
|
return checkInterval(10000.2345);
|
2017-01-17 20:21:38 +00:00
|
|
|
},
|
2017-10-16 22:08:42 +00:00
|
|
|
function veryBig() {
|
|
|
|
return checkInterval(1e+15 + 0.2345);
|
2017-01-17 20:21:38 +00:00
|
|
|
},
|
2017-10-16 22:08:42 +00:00
|
|
|
function huge() {
|
|
|
|
return checkInterval(1e+42);
|
|
|
|
},
|
|
|
|
function undefinedAsLabel() {
|
|
|
|
return checkInterval(1.0, 'undefined');
|
|
|
|
},
|
|
|
|
function emptyAsLabel() {
|
|
|
|
return checkInterval(1.0, '');
|
2017-01-17 20:21:38 +00:00
|
|
|
}
|
|
|
|
]);
|
|
|
|
|
2017-10-16 22:08:42 +00:00
|
|
|
async function checkInterval(time, label) {
|
|
|
|
label = label === undefined ? '\'timeEnd\'' : label;
|
2017-02-28 20:22:24 +00:00
|
|
|
utils.setCurrentTimeMSForTest(0.0);
|
2017-10-16 22:08:42 +00:00
|
|
|
Protocol.Runtime.evaluate({
|
2020-05-09 00:35:12 +00:00
|
|
|
expression: `console.log('js: ' + ${time} + ' ms')`
|
2017-10-16 22:08:42 +00:00
|
|
|
});
|
|
|
|
await Protocol.Runtime.evaluate({expression: `console.time(${label})`});
|
|
|
|
utils.setCurrentTimeMSForTest(time);
|
|
|
|
await Protocol.Runtime.evaluate({expression: `console.timeEnd(${label})`});
|
2017-01-17 20:21:38 +00:00
|
|
|
}
|