mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Auto merge of #20181 - fabricedesre:end-load-pageshow, r=jdm
Fire the pageshow event at the end of the page load <!-- Please describe your changes on the following line: --> This implements step 8 of https://html.spec.whatwg.org/multipage/parsing.html#the-end --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [X] These changes do not require tests because I could not find a wpt test for that, which is strange. I likely missed it :( <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/20181) <!-- Reviewable:end -->
This commit is contained in:
commit
94a6c2c429
4 changed files with 57 additions and 7 deletions
|
@ -47,6 +47,7 @@ none
|
||||||
number
|
number
|
||||||
onchange
|
onchange
|
||||||
open
|
open
|
||||||
|
pageshow
|
||||||
password
|
password
|
||||||
pause
|
pause
|
||||||
play
|
play
|
||||||
|
|
|
@ -364,6 +364,8 @@ pub struct Document {
|
||||||
canceller: FetchCanceller,
|
canceller: FetchCanceller,
|
||||||
/// https://html.spec.whatwg.org/multipage/#throw-on-dynamic-markup-insertion-counter
|
/// https://html.spec.whatwg.org/multipage/#throw-on-dynamic-markup-insertion-counter
|
||||||
throw_on_dynamic_markup_insertion_counter: Cell<u64>,
|
throw_on_dynamic_markup_insertion_counter: Cell<u64>,
|
||||||
|
/// https://html.spec.whatwg.org/multipage/#page-showing
|
||||||
|
page_showing: Cell<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(JSTraceable, MallocSizeOf)]
|
#[derive(JSTraceable, MallocSizeOf)]
|
||||||
|
@ -1634,7 +1636,37 @@ impl Document {
|
||||||
).unwrap();
|
).unwrap();
|
||||||
|
|
||||||
// Step 8.
|
// Step 8.
|
||||||
// TODO: pageshow event.
|
let document = Trusted::new(self);
|
||||||
|
if document.root().browsing_context().is_some() {
|
||||||
|
self.window.dom_manipulation_task_source().queue(
|
||||||
|
task!(fire_pageshow_event: move || {
|
||||||
|
let document = document.root();
|
||||||
|
let window = document.window();
|
||||||
|
if document.page_showing.get() || !window.is_alive() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
document.page_showing.set(true);
|
||||||
|
|
||||||
|
let event = PageTransitionEvent::new(
|
||||||
|
window,
|
||||||
|
atom!("pageshow"),
|
||||||
|
false, // bubbles
|
||||||
|
false, // cancelable
|
||||||
|
false, // persisted
|
||||||
|
);
|
||||||
|
let event = event.upcast::<Event>();
|
||||||
|
event.set_trusted(true);
|
||||||
|
|
||||||
|
// FIXME(nox): Why are errors silenced here?
|
||||||
|
let _ = window.upcast::<EventTarget>().dispatch_event_with_target(
|
||||||
|
document.upcast(),
|
||||||
|
&event,
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
self.window.upcast(),
|
||||||
|
).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
// Step 9.
|
// Step 9.
|
||||||
// TODO: pending application cache download process tasks.
|
// TODO: pending application cache download process tasks.
|
||||||
|
@ -2225,6 +2257,7 @@ impl Document {
|
||||||
tti_window: DomRefCell::new(InteractiveWindow::new()),
|
tti_window: DomRefCell::new(InteractiveWindow::new()),
|
||||||
canceller: canceller,
|
canceller: canceller,
|
||||||
throw_on_dynamic_markup_insertion_counter: Cell::new(0),
|
throw_on_dynamic_markup_insertion_counter: Cell::new(0),
|
||||||
|
page_showing: Cell::new(false),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -568154,7 +568154,7 @@
|
||||||
"support"
|
"support"
|
||||||
],
|
],
|
||||||
"html/syntax/parsing/the-end.html": [
|
"html/syntax/parsing/the-end.html": [
|
||||||
"78b17f053dd3e52b3bf68a5fafc4a4e070e65cfd",
|
"4b38fe0c7bcb088450cc13f13c805711caf91961",
|
||||||
"testharness"
|
"testharness"
|
||||||
],
|
],
|
||||||
"html/syntax/serializing-html-fragments/.gitkeep": [
|
"html/syntax/serializing-html-fragments/.gitkeep": [
|
||||||
|
|
|
@ -29,12 +29,28 @@ async_test(function() {
|
||||||
}, "load");
|
}, "load");
|
||||||
|
|
||||||
async_test(function() {
|
async_test(function() {
|
||||||
var seen = false;
|
window.addEventListener("pageshow", this.step_func_done(function(e) {
|
||||||
document.addEventListener("DOMContentLoaded", this.step_func(function() {
|
assert_equals(e.type, "pageshow");
|
||||||
seen = true;
|
assert_false(e.bubbles, "bubbles should be false");
|
||||||
|
assert_false(e.cancelable, "cancelable should be false");
|
||||||
|
assert_equals(e.target, document, "target should be document");
|
||||||
|
assert_true(e.isTrusted, "isTrusted should be true");
|
||||||
|
assert_class_string(e, "PageTransitionEvent");
|
||||||
}));
|
}));
|
||||||
window.addEventListener("load", this.step_func_done(function() {
|
}, "pageshow");
|
||||||
assert_true(seen, "DOMContentLoaded should be fired before load");
|
|
||||||
|
async_test(function() {
|
||||||
|
var seen_dcl = false;
|
||||||
|
var seen_load = false;
|
||||||
|
document.addEventListener("DOMContentLoaded", this.step_func(function() {
|
||||||
|
seen_dcl = true;
|
||||||
|
}));
|
||||||
|
window.addEventListener("load", this.step_func(function() {
|
||||||
|
seen_load = true;
|
||||||
|
assert_true(seen_dcl, "DOMContentLoaded should be fired before load");
|
||||||
|
}));
|
||||||
|
window.addEventListener("pageshow", this.step_func_done(function() {
|
||||||
|
assert_true(seen_load, "load should be fired before pageshow")
|
||||||
}));
|
}));
|
||||||
}, "order");
|
}, "order");
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue