aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/window.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2018-07-21 14:39:25 -0400
committerGitHub <noreply@github.com>2018-07-21 14:39:25 -0400
commita97d8b99efaa16a325b3a7bf2baf80ed2da2590d (patch)
treeb7d0b77d76cf34f7709151385d0014a71e9e32d7 /components/script/dom/window.rs
parent37a73d3bc09a8a3f12e4e2d42850419208000ba8 (diff)
parent61442cce4b93ef6b88b4ce59bad2358e8ce8bf4e (diff)
downloadservo-a97d8b99efaa16a325b3a7bf2baf80ed2da2590d.tar.gz
servo-a97d8b99efaa16a325b3a7bf2baf80ed2da2590d.zip
Auto merge of #21048 - cbrewster:hash_change_history, r=asajeffrey
Track hash changes in session history <!-- Please describe your changes on the following line: --> Adds tracking of hash changes in the session history. --- <!-- 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 - [X] These changes fix #14970 fix #13437 (github issue number if applicable). <!-- Either: --> - [X] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- 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/21048) <!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/window.rs')
-rw-r--r--components/script/dom/window.rs25
1 files changed, 24 insertions, 1 deletions
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs
index ea3a92e0f37..a26570edb1c 100644
--- a/components/script/dom/window.rs
+++ b/components/script/dom/window.rs
@@ -33,7 +33,10 @@ use dom::cssstyledeclaration::{CSSModificationAccess, CSSStyleDeclaration, CSSSt
use dom::customelementregistry::CustomElementRegistry;
use dom::document::{AnimationFrameCallback, Document};
use dom::element::Element;
+use dom::event::Event;
+use dom::eventtarget::EventTarget;
use dom::globalscope::GlobalScope;
+use dom::hashchangeevent::HashChangeEvent;
use dom::history::History;
use dom::location::Location;
use dom::mediaquerylist::{MediaQueryList, WeakMediaQueryListVec};
@@ -1582,13 +1585,33 @@ impl Window {
referrer_policy: Option<ReferrerPolicy>) {
let doc = self.Document();
let referrer_policy = referrer_policy.or(doc.get_referrer_policy());
-
// https://html.spec.whatwg.org/multipage/#navigating-across-documents
if !force_reload && url.as_url()[..Position::AfterQuery] ==
doc.url().as_url()[..Position::AfterQuery] {
// Step 6
if let Some(fragment) = url.fragment() {
+ self.send_to_constellation(ScriptMsg::NavigatedToFragment(url.clone(), replace));
doc.check_and_scroll_fragment(fragment);
+ let this = Trusted::new(self);
+ let old_url = doc.url().into_string();
+ let new_url = url.clone().into_string();
+ let task = task!(hashchange_event: move || {
+ let this = this.root();
+ let event = HashChangeEvent::new(
+ &this,
+ atom!("hashchange"),
+ false,
+ false,
+ old_url,
+ new_url);
+ event.upcast::<Event>().fire(this.upcast::<EventTarget>());
+ });
+ // FIXME(nox): Why are errors silenced here?
+ let _ = self.script_chan.send(CommonScriptMsg::Task(
+ ScriptThreadEventCategory::DomEvent,
+ Box::new(self.task_canceller(TaskSourceName::DOMManipulation).wrap_task(task)),
+ self.pipeline_id()
+ ));
doc.set_url(url.clone());
return
}