diff options
author | bors-servo <metajack+bors@gmail.com> | 2015-08-03 13:17:47 -0600 |
---|---|---|
committer | bors-servo <metajack+bors@gmail.com> | 2015-08-03 13:17:47 -0600 |
commit | 86476804cac668133b6964c8f551918163aa66d7 (patch) | |
tree | d02bf89652e04e0e859f2ee245db6f0dffea71d9 /components/script | |
parent | 028707f5cd3263fd1476669207f67d5b9d5d4806 (diff) | |
parent | 2a7f262b7df8761261a0fa618394f4e991733a5e (diff) | |
download | servo-86476804cac668133b6964c8f551918163aa66d7.tar.gz servo-86476804cac668133b6964c8f551918163aa66d7.zip |
Auto merge of #6917 - Ms2ger:lock-alert, r=metajack
Lock and flush stdout in Window#alert.
We use alert() to communicate test results to wptrunner. Unfortunately,
sometimes the alert output is interleaved with other output on stdout,
causing wptrunner to classify the test result as a timeout. I hope this will
avoid that scenario.
<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6917)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script')
-rw-r--r-- | components/script/dom/window.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index d7a9e9f243a..4e90cc71012 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -72,6 +72,7 @@ use std::cell::{Cell, Ref, RefMut, RefCell}; use std::collections::HashSet; use std::default::Default; use std::ffi::CString; +use std::io::{stdout, Write}; use std::mem as std_mem; use std::rc::Rc; use std::sync::Arc; @@ -342,7 +343,10 @@ impl<'a> WindowMethods for &'a Window { // https://html.spec.whatwg.org/#dom-alert fn Alert(self, s: DOMString) { // Right now, just print to the console - println!("ALERT: {}", s); + let stdout = stdout(); + let mut stdout = stdout.lock(); + writeln!(&mut stdout, "ALERT: {}", s).unwrap(); + stdout.flush().unwrap(); } // https://html.spec.whatwg.org/multipage/#dom-window-close |