mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +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
|
@ -289,7 +289,7 @@ pub enum MozBrowserEvent {
|
||||||
/// Sent when the SSL state changes within a browser `<iframe>`.
|
/// Sent when the SSL state changes within a browser `<iframe>`.
|
||||||
SecurityChange,
|
SecurityChange,
|
||||||
/// Sent when alert(), confirm(), or prompt() is called within a browser `<iframe>`.
|
/// Sent when alert(), confirm(), or prompt() is called within a browser `<iframe>`.
|
||||||
ShowModalPrompt,
|
ShowModalPrompt(String, String, String, String), // TODO(simartin): Handle unblock()
|
||||||
/// Sent when the document.title changes within a browser `<iframe>`.
|
/// Sent when the document.title changes within a browser `<iframe>`.
|
||||||
TitleChange(String),
|
TitleChange(String),
|
||||||
/// Sent when an HTTP authentification is requested.
|
/// Sent when an HTTP authentification is requested.
|
||||||
|
@ -311,7 +311,7 @@ impl MozBrowserEvent {
|
||||||
MozBrowserEvent::LocationChange(_) => "mozbrowserlocationchange",
|
MozBrowserEvent::LocationChange(_) => "mozbrowserlocationchange",
|
||||||
MozBrowserEvent::OpenWindow => "mozbrowseropenwindow",
|
MozBrowserEvent::OpenWindow => "mozbrowseropenwindow",
|
||||||
MozBrowserEvent::SecurityChange => "mozbrowsersecuritychange",
|
MozBrowserEvent::SecurityChange => "mozbrowsersecuritychange",
|
||||||
MozBrowserEvent::ShowModalPrompt => "mozbrowsershowmodalprompt",
|
MozBrowserEvent::ShowModalPrompt(_, _, _, _) => "mozbrowsershowmodalprompt",
|
||||||
MozBrowserEvent::TitleChange(_) => "mozbrowsertitlechange",
|
MozBrowserEvent::TitleChange(_) => "mozbrowsertitlechange",
|
||||||
MozBrowserEvent::UsernameAndPasswordRequired => "mozbrowserusernameandpasswordrequired",
|
MozBrowserEvent::UsernameAndPasswordRequired => "mozbrowserusernameandpasswordrequired",
|
||||||
MozBrowserEvent::OpenSearch => "mozbrowseropensearch"
|
MozBrowserEvent::OpenSearch => "mozbrowseropensearch"
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
use dom::attr::{Attr, AttrValue};
|
use dom::attr::{Attr, AttrValue};
|
||||||
use dom::bindings::codegen::Bindings::BrowserElementBinding::BrowserElementIconChangeEventDetail;
|
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;
|
||||||
use dom::bindings::codegen::Bindings::HTMLIFrameElementBinding::HTMLIFrameElementMethods;
|
use dom::bindings::codegen::Bindings::HTMLIFrameElementBinding::HTMLIFrameElementMethods;
|
||||||
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||||
|
@ -272,7 +273,7 @@ impl MozBrowserEventDetailBuilder for HTMLIFrameElement {
|
||||||
MozBrowserEvent::AsyncScroll | MozBrowserEvent::Close | MozBrowserEvent::ContextMenu |
|
MozBrowserEvent::AsyncScroll | MozBrowserEvent::Close | MozBrowserEvent::ContextMenu |
|
||||||
MozBrowserEvent::Error | MozBrowserEvent::LoadEnd | MozBrowserEvent::LoadStart |
|
MozBrowserEvent::Error | MozBrowserEvent::LoadEnd | MozBrowserEvent::LoadStart |
|
||||||
MozBrowserEvent::OpenWindow | MozBrowserEvent::SecurityChange | MozBrowserEvent::OpenSearch |
|
MozBrowserEvent::OpenWindow | MozBrowserEvent::SecurityChange | MozBrowserEvent::OpenSearch |
|
||||||
MozBrowserEvent::ShowModalPrompt | MozBrowserEvent::UsernameAndPasswordRequired => {
|
MozBrowserEvent::UsernameAndPasswordRequired => {
|
||||||
rval.set(NullValue());
|
rval.set(NullValue());
|
||||||
}
|
}
|
||||||
MozBrowserEvent::LocationChange(ref string) | MozBrowserEvent::TitleChange(ref string) => {
|
MozBrowserEvent::LocationChange(ref string) | MozBrowserEvent::TitleChange(ref string) => {
|
||||||
|
@ -285,6 +286,14 @@ impl MozBrowserEventDetailBuilder for HTMLIFrameElement {
|
||||||
sizes: Some(DOMString::from(sizes)),
|
sizes: Some(DOMString::from(sizes)),
|
||||||
}.to_jsval(cx, rval);
|
}.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;
|
DOMString sizes;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
dictionary BrowserShowModalPromptEventDetail {
|
||||||
|
DOMString promptType;
|
||||||
|
DOMString title;
|
||||||
|
DOMString message;
|
||||||
|
DOMString returnValue;
|
||||||
|
// TODO(simartin) unblock() callback
|
||||||
|
};
|
||||||
|
|
||||||
BrowserElement implements BrowserElementCommon;
|
BrowserElement implements BrowserElementCommon;
|
||||||
BrowserElement implements BrowserElementPrivileged;
|
BrowserElement implements BrowserElementPrivileged;
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ use libc;
|
||||||
use msg::ParseErrorReporter;
|
use msg::ParseErrorReporter;
|
||||||
use msg::compositor_msg::{LayerId, ScriptToCompositorMsg};
|
use msg::compositor_msg::{LayerId, ScriptToCompositorMsg};
|
||||||
use msg::constellation_msg::{ConstellationChan, DocumentState, LoadData};
|
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 msg::webdriver_msg::{WebDriverJSError, WebDriverJSResult};
|
||||||
use net_traits::ResourceTask;
|
use net_traits::ResourceTask;
|
||||||
use net_traits::image_cache_task::{ImageCacheChan, ImageCacheTask};
|
use net_traits::image_cache_task::{ImageCacheChan, ImageCacheTask};
|
||||||
|
@ -394,7 +394,7 @@ impl WindowMethods for Window {
|
||||||
fn Alert(&self, s: DOMString) {
|
fn Alert(&self, s: DOMString) {
|
||||||
// Right now, just print to the console
|
// Right now, just print to the console
|
||||||
// Ensure that stderr doesn't trample through the alert() we use to
|
// 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 stderr = stderr();
|
||||||
let mut stderr = stderr.lock();
|
let mut stderr = stderr.lock();
|
||||||
let stdout = stdout();
|
let stdout = stdout();
|
||||||
|
@ -402,6 +402,11 @@ impl WindowMethods for Window {
|
||||||
writeln!(&mut stdout, "ALERT: {}", s).unwrap();
|
writeln!(&mut stdout, "ALERT: {}", s).unwrap();
|
||||||
stdout.flush().unwrap();
|
stdout.flush().unwrap();
|
||||||
stderr.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
|
// https://html.spec.whatwg.org/multipage/#dom-window-close
|
||||||
|
|
|
@ -5691,6 +5691,12 @@
|
||||||
"url": "/_mozilla/mozilla/mozbrowser/mozbrowsericonchange_event.html"
|
"url": "/_mozilla/mozilla/mozbrowser/mozbrowsericonchange_event.html"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"mozilla/mozbrowser/mozbrowsershowmodalprompt_event.html": [
|
||||||
|
{
|
||||||
|
"path": "mozilla/mozbrowser/mozbrowsershowmodalprompt_event.html",
|
||||||
|
"url": "/_mozilla/mozilla/mozbrowser/mozbrowsershowmodalprompt_event.html"
|
||||||
|
}
|
||||||
|
],
|
||||||
"mozilla/mozbrowser/reload.html": [
|
"mozilla/mozbrowser/reload.html": [
|
||||||
{
|
{
|
||||||
"path": "mozilla/mozbrowser/reload.html",
|
"path": "mozilla/mozbrowser/reload.html",
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
<!doctype html>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Dispatch mozbrowsershowmodalprompt event for alert (issue #8352)</title>
|
||||||
|
<script src="/resources/testharness.js"></script>
|
||||||
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
|
<body></body>
|
||||||
|
<script>
|
||||||
|
async_test(function(t) {
|
||||||
|
var iframe = document.createElement("iframe");
|
||||||
|
iframe.mozbrowser = "true";
|
||||||
|
iframe.src = "mozbrowsershowmodalprompt_event_iframe.html";
|
||||||
|
iframe.addEventListener("mozbrowsershowmodalprompt", t.step_func(e => {
|
||||||
|
assert_equals(e.detail.promptType, "alert");
|
||||||
|
assert_equals(e.detail.message, "my alert message");
|
||||||
|
t.done();
|
||||||
|
}));
|
||||||
|
document.body.appendChild(iframe);
|
||||||
|
});
|
||||||
|
</script>
|
|
@ -0,0 +1,6 @@
|
||||||
|
<html>
|
||||||
|
<body></body>
|
||||||
|
<script>
|
||||||
|
window.alert("my alert message");
|
||||||
|
</script>
|
||||||
|
</html>
|
Loading…
Add table
Add a link
Reference in a new issue