aboutsummaryrefslogtreecommitdiffstats
path: root/components/script_traits/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script_traits/lib.rs')
-rw-r--r--components/script_traits/lib.rs59
1 files changed, 58 insertions, 1 deletions
diff --git a/components/script_traits/lib.rs b/components/script_traits/lib.rs
index 64e64e64ed9..d9fcba984ad 100644
--- a/components/script_traits/lib.rs
+++ b/components/script_traits/lib.rs
@@ -41,7 +41,7 @@ use ipc_channel::ipc::{IpcReceiver, IpcSender};
use libc::c_void;
use msg::constellation_msg::{ConstellationChan, Failure, PipelineId, WindowSizeData};
use msg::constellation_msg::{Key, KeyModifiers, KeyState, LoadData, MouseButton};
-use msg::constellation_msg::{MozBrowserEvent, PipelineNamespaceId, SubpageId};
+use msg::constellation_msg::{PipelineNamespaceId, SubpageId};
use msg::webdriver_msg::WebDriverScriptCommand;
use net_traits::ResourceThread;
use net_traits::image_cache_thread::ImageCacheThread;
@@ -371,3 +371,60 @@ pub struct IFrameLoadInfo {
/// Sandbox type of this iframe
pub sandbox: IFrameSandboxState,
}
+
+// https://developer.mozilla.org/en-US/docs/Web/API/Using_the_Browser_API#Events
+/// The events fired in a Browser API context (`<iframe mozbrowser>`)
+#[derive(Deserialize, Serialize)]
+pub enum MozBrowserEvent {
+ /// Sent when the scroll position within a browser `<iframe>` changes.
+ AsyncScroll,
+ /// Sent when window.close() is called within a browser `<iframe>`.
+ Close,
+ /// Sent when a browser `<iframe>` tries to open a context menu. This allows
+ /// handling `<menuitem>` element available within the browser `<iframe>`'s content.
+ ContextMenu,
+ /// Sent when an error occurred while trying to load content within a browser `<iframe>`.
+ Error,
+ /// Sent when the favicon of a browser `<iframe>` changes.
+ IconChange(String, String, String),
+ /// Sent when the browser `<iframe>` has finished loading all its assets.
+ LoadEnd,
+ /// Sent when the browser `<iframe>` starts to load a new page.
+ LoadStart,
+ /// Sent when a browser `<iframe>`'s location changes.
+ LocationChange(String),
+ /// Sent when window.open() is called within a browser `<iframe>`.
+ OpenWindow,
+ /// Sent when the SSL state changes within a browser `<iframe>`.
+ SecurityChange,
+ /// Sent when alert(), confirm(), or prompt() is called within a browser `<iframe>`.
+ ShowModalPrompt(String, String, String, String), // TODO(simartin): Handle unblock()
+ /// Sent when the document.title changes within a browser `<iframe>`.
+ TitleChange(String),
+ /// Sent when an HTTP authentification is requested.
+ UsernameAndPasswordRequired,
+ /// Sent when a link to a search engine is found.
+ OpenSearch,
+}
+
+impl MozBrowserEvent {
+ /// Get the name of the event as a `& str`
+ pub fn name(&self) -> &'static str {
+ match *self {
+ MozBrowserEvent::AsyncScroll => "mozbrowserasyncscroll",
+ MozBrowserEvent::Close => "mozbrowserclose",
+ MozBrowserEvent::ContextMenu => "mozbrowsercontextmenu",
+ MozBrowserEvent::Error => "mozbrowsererror",
+ MozBrowserEvent::IconChange(_, _, _) => "mozbrowsericonchange",
+ MozBrowserEvent::LoadEnd => "mozbrowserloadend",
+ MozBrowserEvent::LoadStart => "mozbrowserloadstart",
+ MozBrowserEvent::LocationChange(_) => "mozbrowserlocationchange",
+ MozBrowserEvent::OpenWindow => "mozbrowseropenwindow",
+ MozBrowserEvent::SecurityChange => "mozbrowsersecuritychange",
+ MozBrowserEvent::ShowModalPrompt(_, _, _, _) => "mozbrowsershowmodalprompt",
+ MozBrowserEvent::TitleChange(_) => "mozbrowsertitlechange",
+ MozBrowserEvent::UsernameAndPasswordRequired => "mozbrowserusernameandpasswordrequired",
+ MozBrowserEvent::OpenSearch => "mozbrowseropensearch"
+ }
+ }
+}