mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
auto merge of #2618 : Ms2ger/servo/console-assert, r=jdm
This commit is contained in:
commit
01a93d82bf
2 changed files with 12 additions and 0 deletions
|
@ -31,6 +31,7 @@ pub trait ConsoleMethods {
|
||||||
fn Info(&self, message: DOMString);
|
fn Info(&self, message: DOMString);
|
||||||
fn Warn(&self, message: DOMString);
|
fn Warn(&self, message: DOMString);
|
||||||
fn Error(&self, message: DOMString);
|
fn Error(&self, message: DOMString);
|
||||||
|
fn Assert(&self, condition: bool, message: Option<DOMString>);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ConsoleMethods for JSRef<'a, Console> {
|
impl<'a> ConsoleMethods for JSRef<'a, Console> {
|
||||||
|
@ -53,6 +54,16 @@ impl<'a> ConsoleMethods for JSRef<'a, Console> {
|
||||||
fn Error(&self, message: DOMString) {
|
fn Error(&self, message: DOMString) {
|
||||||
println!("{:s}", message);
|
println!("{:s}", message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn Assert(&self, condition: bool, message: Option<DOMString>) {
|
||||||
|
if !condition {
|
||||||
|
let message = match message {
|
||||||
|
Some(ref message) => message.as_slice(),
|
||||||
|
None => "no message",
|
||||||
|
};
|
||||||
|
println!("Assertion failed: {:s}", message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Reflectable for Console {
|
impl Reflectable for Console {
|
||||||
|
|
|
@ -17,4 +17,5 @@ interface Console {
|
||||||
void info(DOMString message);
|
void info(DOMString message);
|
||||||
void warn(DOMString message);
|
void warn(DOMString message);
|
||||||
void error(DOMString message);
|
void error(DOMString message);
|
||||||
|
void assert(boolean condition, optional DOMString message);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue