diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2016-07-14 11:55:44 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-14 11:55:44 -0700 |
commit | 4b78b9adab916cc4fdde6248e785030b79f406da (patch) | |
tree | 93cba375688da2cb779ed1aabc04c7abdd55b0d7 /components/script/dom/document.rs | |
parent | 48a912f57ec51e55e7905983b2bf368a07a9902f (diff) | |
parent | d6c1f7b5e3909d9b11544dae4b4c7d0793fef5f7 (diff) | |
download | servo-4b78b9adab916cc4fdde6248e785030b79f406da.tar.gz servo-4b78b9adab916cc4fdde6248e785030b79f406da.zip |
Auto merge of #12416 - canaltinova:referrer, r=jdm
Implement Document.referrer
<!-- Please describe your changes on the following line: -->
---
<!-- 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 #12389 (github issue number if applicable).
<!-- Either: -->
- [X] There are tests for these changes OR
- [ ] These changes do not require tests because _____
<!-- 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/12416)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/document.rs')
-rw-r--r-- | components/script/dom/document.rs | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 8630d64eb7a..44a8e2231ea 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -239,6 +239,8 @@ pub struct Document { origin: Origin, /// https://w3c.github.io/webappsec-referrer-policy/#referrer-policy-states referrer_policy: Cell<Option<ReferrerPolicy>>, + /// https://html.spec.whatwg.org/multipage/#dom-document-referrer + referrer: Option<String>, } #[derive(JSTraceable, HeapSizeOf)] @@ -1630,7 +1632,8 @@ impl Document { content_type: Option<DOMString>, last_modified: Option<String>, source: DocumentSource, - doc_loader: DocumentLoader) + doc_loader: DocumentLoader, + referrer: Option<String>) -> Document { let url = url.unwrap_or_else(|| Url::parse("about:blank").unwrap()); @@ -1717,6 +1720,7 @@ impl Document { origin: origin, //TODO - setting this for now so no Referer header set referrer_policy: Cell::new(Some(ReferrerPolicy::NoReferrer)), + referrer: referrer, } } @@ -1733,7 +1737,8 @@ impl Document { None, None, DocumentSource::NotFromParser, - docloader)) + docloader, + None)) } pub fn new(window: &Window, @@ -1743,7 +1748,8 @@ impl Document { content_type: Option<DOMString>, last_modified: Option<String>, source: DocumentSource, - doc_loader: DocumentLoader) + doc_loader: DocumentLoader, + referrer: Option<String>) -> Root<Document> { let document = reflect_dom_object(box Document::new_inherited(window, browsing_context, @@ -1752,7 +1758,8 @@ impl Document { content_type, last_modified, source, - doc_loader), + doc_loader, + referrer), GlobalRef::Window(window), DocumentBinding::Wrap); { @@ -1816,7 +1823,8 @@ impl Document { None, None, DocumentSource::NotFromParser, - DocumentLoader::new(&self.loader())); + DocumentLoader::new(&self.loader()), + None); new_doc.appropriate_template_contents_owner_document.set(Some(&new_doc)); new_doc }) @@ -1935,6 +1943,14 @@ impl DocumentMethods for Document { } } + // https://html.spec.whatwg.org/multipage/#dom-document-referrer + fn Referrer(&self) -> DOMString { + match self.referrer { + Some(ref referrer) => DOMString::from(referrer.to_string()), + None => DOMString::new() + } + } + // https://dom.spec.whatwg.org/#dom-document-documenturi fn DocumentURI(&self) -> USVString { self.URL() |