mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
Auto merge of #9740 - paulrouget:mozbrowserconnected, r=jdm
Support Browser API event mozbrowserconnected Fixes https://github.com/servo/servo/issues/9382 This new event is not yet documented. If this lands, I will add documentation to MDN. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9740) <!-- Reviewable:end -->
This commit is contained in:
commit
42f1712846
5 changed files with 67 additions and 6 deletions
|
@ -584,9 +584,17 @@ impl Document {
|
||||||
// https://html.spec.whatwg.org/multipage/#current-document-readiness
|
// https://html.spec.whatwg.org/multipage/#current-document-readiness
|
||||||
pub fn set_ready_state(&self, state: DocumentReadyState) {
|
pub fn set_ready_state(&self, state: DocumentReadyState) {
|
||||||
match state {
|
match state {
|
||||||
DocumentReadyState::Loading => update_with_current_time(&self.dom_loading),
|
DocumentReadyState::Loading => {
|
||||||
|
// https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowserconnected
|
||||||
|
self.trigger_mozbrowser_event(MozBrowserEvent::Connected);
|
||||||
|
update_with_current_time(&self.dom_loading);
|
||||||
|
},
|
||||||
|
DocumentReadyState::Complete => {
|
||||||
|
// https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowserloadend
|
||||||
|
self.trigger_mozbrowser_event(MozBrowserEvent::LoadEnd);
|
||||||
|
update_with_current_time(&self.dom_complete);
|
||||||
|
},
|
||||||
DocumentReadyState::Interactive => update_with_current_time(&self.dom_interactive),
|
DocumentReadyState::Interactive => update_with_current_time(&self.dom_interactive),
|
||||||
DocumentReadyState::Complete => update_with_current_time(&self.dom_complete),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
self.ready_state.set(state);
|
self.ready_state.set(state);
|
||||||
|
@ -2587,9 +2595,6 @@ impl DocumentProgressHandler {
|
||||||
|
|
||||||
document.notify_constellation_load();
|
document.notify_constellation_load();
|
||||||
|
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowserloadend
|
|
||||||
document.trigger_mozbrowser_event(MozBrowserEvent::LoadEnd);
|
|
||||||
|
|
||||||
window.reflow(ReflowGoal::ForDisplay,
|
window.reflow(ReflowGoal::ForDisplay,
|
||||||
ReflowQueryType::NoQuery,
|
ReflowQueryType::NoQuery,
|
||||||
ReflowReason::DocumentLoaded);
|
ReflowReason::DocumentLoaded);
|
||||||
|
|
|
@ -303,7 +303,7 @@ impl MozBrowserEventDetailBuilder for HTMLIFrameElement {
|
||||||
match event {
|
match event {
|
||||||
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::OpenSearch |
|
MozBrowserEvent::Connected | MozBrowserEvent::OpenWindow | MozBrowserEvent::OpenSearch |
|
||||||
MozBrowserEvent::UsernameAndPasswordRequired => {
|
MozBrowserEvent::UsernameAndPasswordRequired => {
|
||||||
rval.set(NullValue());
|
rval.set(NullValue());
|
||||||
}
|
}
|
||||||
|
|
|
@ -415,6 +415,8 @@ pub enum MozBrowserEvent {
|
||||||
Error,
|
Error,
|
||||||
/// Sent when the favicon of a browser `<iframe>` changes.
|
/// Sent when the favicon of a browser `<iframe>` changes.
|
||||||
IconChange(String, String, String),
|
IconChange(String, String, String),
|
||||||
|
/// Sent when the browser `<iframe>` has reached the server.
|
||||||
|
Connected,
|
||||||
/// Sent when the browser `<iframe>` has finished loading all its assets.
|
/// Sent when the browser `<iframe>` has finished loading all its assets.
|
||||||
LoadEnd,
|
LoadEnd,
|
||||||
/// Sent when the browser `<iframe>` starts to load a new page.
|
/// Sent when the browser `<iframe>` starts to load a new page.
|
||||||
|
@ -441,6 +443,7 @@ impl MozBrowserEvent {
|
||||||
match *self {
|
match *self {
|
||||||
MozBrowserEvent::AsyncScroll => "mozbrowserasyncscroll",
|
MozBrowserEvent::AsyncScroll => "mozbrowserasyncscroll",
|
||||||
MozBrowserEvent::Close => "mozbrowserclose",
|
MozBrowserEvent::Close => "mozbrowserclose",
|
||||||
|
MozBrowserEvent::Connected => "mozbrowserconnected",
|
||||||
MozBrowserEvent::ContextMenu => "mozbrowsercontextmenu",
|
MozBrowserEvent::ContextMenu => "mozbrowsercontextmenu",
|
||||||
MozBrowserEvent::Error => "mozbrowsererror",
|
MozBrowserEvent::Error => "mozbrowsererror",
|
||||||
MozBrowserEvent::IconChange(_, _, _) => "mozbrowsericonchange",
|
MozBrowserEvent::IconChange(_, _, _) => "mozbrowsericonchange",
|
||||||
|
|
|
@ -5934,6 +5934,12 @@
|
||||||
"url": "/_mozilla/mozilla/mozbrowser/iframe_reload_twice.html"
|
"url": "/_mozilla/mozilla/mozbrowser/iframe_reload_twice.html"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"mozilla/mozbrowser/mozbrowser_loadevents.html": [
|
||||||
|
{
|
||||||
|
"path": "mozilla/mozbrowser/mozbrowser_loadevents.html",
|
||||||
|
"url": "/_mozilla/mozilla/mozbrowser/mozbrowser_loadevents.html"
|
||||||
|
}
|
||||||
|
],
|
||||||
"mozilla/mozbrowser/mozbrowsericonchange_event.html": [
|
"mozilla/mozbrowser/mozbrowsericonchange_event.html": [
|
||||||
{
|
{
|
||||||
"path": "mozilla/mozbrowser/mozbrowsericonchange_event.html",
|
"path": "mozilla/mozbrowser/mozbrowsericonchange_event.html",
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
<head>
|
||||||
|
<title>mozbrowserloadstart, mozbrowserconnected and mozbrowserloadend are dispatched</title>
|
||||||
|
<script src="/resources/testharness.js"></script>
|
||||||
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<script>
|
||||||
|
|
||||||
|
async_test(function(t) {
|
||||||
|
|
||||||
|
var has_reloaded = false;
|
||||||
|
var expectedEvents = [
|
||||||
|
"mozbrowserloadstart",
|
||||||
|
"mozbrowserconnected",
|
||||||
|
"mozbrowserloadend",
|
||||||
|
"mozbrowserloadstart",
|
||||||
|
"mozbrowserconnected",
|
||||||
|
"mozbrowserloadend",
|
||||||
|
];
|
||||||
|
|
||||||
|
var receivedEvents = [];
|
||||||
|
|
||||||
|
var iframe = document.createElement("iframe");
|
||||||
|
iframe.mozbrowser = "true";
|
||||||
|
iframe.src = "http://web-platform.test:8000";
|
||||||
|
|
||||||
|
for (var event_name of ["mozbrowserloadstart",
|
||||||
|
"mozbrowserconnected",
|
||||||
|
"mozbrowserloadend"]) {
|
||||||
|
iframe.addEventListener(event_name, t.step_func(e => {
|
||||||
|
receivedEvents.push(e.type);
|
||||||
|
if (receivedEvents.length == expectedEvents.length) {
|
||||||
|
assert_array_equals(receivedEvents, expectedEvents);
|
||||||
|
t.done();
|
||||||
|
} else {
|
||||||
|
if (e.type == "mozbrowserloadend") {
|
||||||
|
iframe.reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
document.body.appendChild(iframe);
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</body>
|
Loading…
Add table
Add a link
Reference in a new issue