Auto merge of #8863 - simartin:issue_8352, r=jdm

Issue #8352: Dispatch mozbrowsershowmodalprompt event for alert().

Fixes https://github.com/servo/servo/issues/8352

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8863)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-12-21 02:28:32 +05:30
commit 9a4d82c314
7 changed files with 58 additions and 5 deletions

View file

@ -45,7 +45,7 @@ use libc;
use msg::ParseErrorReporter;
use msg::compositor_msg::LayerId;
use msg::constellation_msg::{ConstellationChan, DocumentState, LoadData};
use msg::constellation_msg::{PipelineId, SubpageId, WindowSizeData};
use msg::constellation_msg::{MozBrowserEvent, PipelineId, SubpageId, WindowSizeData};
use msg::webdriver_msg::{WebDriverJSError, WebDriverJSResult};
use net_traits::ResourceTask;
use net_traits::image_cache_task::{ImageCacheChan, ImageCacheTask};
@ -394,7 +394,7 @@ impl WindowMethods for Window {
fn Alert(&self, s: DOMString) {
// Right now, just print to the console
// Ensure that stderr doesn't trample through the alert() we use to
// communicate test results.
// communicate test results (see executorservo.py in wptrunner).
let stderr = stderr();
let mut stderr = stderr.lock();
let stdout = stdout();
@ -402,6 +402,11 @@ impl WindowMethods for Window {
writeln!(&mut stdout, "ALERT: {}", s).unwrap();
stdout.flush().unwrap();
stderr.flush().unwrap();
// https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowsershowmodalprompt
let event = MozBrowserEvent::ShowModalPrompt("alert".to_owned(), "Alert".to_owned(),
String::from(s), "".to_owned());
self.Document().trigger_mozbrowser_event(event);
}
// https://html.spec.whatwg.org/multipage/#dom-window-close