mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
implement console.timeLog
(#33377)
* Implement console.timeLog Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Adjust WPT expectations Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> --------- Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This commit is contained in:
parent
8c0a566860
commit
cc3c69b953
6 changed files with 34 additions and 54 deletions
|
@ -271,18 +271,29 @@ impl Console {
|
|||
};
|
||||
}
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/Console/time
|
||||
// https://console.spec.whatwg.org/#time
|
||||
pub fn Time(global: &GlobalScope, label: DOMString) {
|
||||
if let Ok(()) = global.time(label.clone()) {
|
||||
let message = DOMString::from(format!("{}: timer started", label));
|
||||
let message = DOMString::from(format!("{label}: timer started"));
|
||||
console_message(global, message, LogLevel::Log);
|
||||
}
|
||||
}
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/Console/timeEnd
|
||||
// https://console.spec.whatwg.org/#timelog
|
||||
pub fn TimeLog(_cx: JSContext, global: &GlobalScope, label: DOMString, data: Vec<HandleValue>) {
|
||||
if let Ok(delta) = global.time_log(&label) {
|
||||
let message = DOMString::from(format!(
|
||||
"{label}: {delta}ms {}",
|
||||
stringify_handle_values(data)
|
||||
));
|
||||
console_message(global, message, LogLevel::Log);
|
||||
}
|
||||
}
|
||||
|
||||
// https://console.spec.whatwg.org/#timeend
|
||||
pub fn TimeEnd(global: &GlobalScope, label: DOMString) {
|
||||
if let Ok(delta) = global.time_end(&label) {
|
||||
let message = DOMString::from(format!("{}: {}ms", label, delta));
|
||||
let message = DOMString::from(format!("{label}: {delta}ms"));
|
||||
console_message(global, message, LogLevel::Log);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue