mirror of
https://github.com/servo/servo.git
synced 2025-08-02 04:00:32 +01:00
Issue #8352: Dispatch mozbrowsershowmodalprompt event for alert().
This commit is contained in:
parent
2a3a7a73b5
commit
0d910bb934
7 changed files with 58 additions and 5 deletions
|
@ -4,6 +4,7 @@
|
|||
|
||||
use dom::attr::{Attr, AttrValue};
|
||||
use dom::bindings::codegen::Bindings::BrowserElementBinding::BrowserElementIconChangeEventDetail;
|
||||
use dom::bindings::codegen::Bindings::BrowserElementBinding::BrowserShowModalPromptEventDetail;
|
||||
use dom::bindings::codegen::Bindings::HTMLIFrameElementBinding;
|
||||
use dom::bindings::codegen::Bindings::HTMLIFrameElementBinding::HTMLIFrameElementMethods;
|
||||
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||
|
@ -272,7 +273,7 @@ impl MozBrowserEventDetailBuilder for HTMLIFrameElement {
|
|||
MozBrowserEvent::AsyncScroll | MozBrowserEvent::Close | MozBrowserEvent::ContextMenu |
|
||||
MozBrowserEvent::Error | MozBrowserEvent::LoadEnd | MozBrowserEvent::LoadStart |
|
||||
MozBrowserEvent::OpenWindow | MozBrowserEvent::SecurityChange | MozBrowserEvent::OpenSearch |
|
||||
MozBrowserEvent::ShowModalPrompt | MozBrowserEvent::UsernameAndPasswordRequired => {
|
||||
MozBrowserEvent::UsernameAndPasswordRequired => {
|
||||
rval.set(NullValue());
|
||||
}
|
||||
MozBrowserEvent::LocationChange(ref string) | MozBrowserEvent::TitleChange(ref string) => {
|
||||
|
@ -285,6 +286,14 @@ impl MozBrowserEventDetailBuilder for HTMLIFrameElement {
|
|||
sizes: Some(DOMString::from(sizes)),
|
||||
}.to_jsval(cx, rval);
|
||||
}
|
||||
MozBrowserEvent::ShowModalPrompt(prompt_type, title, message, return_value) => {
|
||||
BrowserShowModalPromptEventDetail {
|
||||
promptType: Some(DOMString::from(prompt_type)),
|
||||
title: Some(DOMString::from(title)),
|
||||
message: Some(DOMString::from(message)),
|
||||
returnValue: Some(DOMString::from(return_value)),
|
||||
}.to_jsval(cx, rval)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,14 @@ dictionary BrowserElementIconChangeEventDetail {
|
|||
DOMString sizes;
|
||||
};
|
||||
|
||||
dictionary BrowserShowModalPromptEventDetail {
|
||||
DOMString promptType;
|
||||
DOMString title;
|
||||
DOMString message;
|
||||
DOMString returnValue;
|
||||
// TODO(simartin) unblock() callback
|
||||
};
|
||||
|
||||
BrowserElement implements BrowserElementCommon;
|
||||
BrowserElement implements BrowserElementPrivileged;
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ use libc;
|
|||
use msg::ParseErrorReporter;
|
||||
use msg::compositor_msg::{LayerId, ScriptToCompositorMsg};
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue