@@ -239,6 +239,8 @@ pub struct Document {
239239 origin : Origin ,
240240 /// https://w3c.github.io/webappsec-referrer-policy/#referrer-policy-states
241241 referrer_policy : Cell < Option < ReferrerPolicy > > ,
242+ /// https://html.spec.whatwg.org/multipage/#dom-document-referrer
243+ referrer : Option < String > ,
242244}
243245
244246#[ derive( JSTraceable , HeapSizeOf ) ]
@@ -1629,7 +1631,8 @@ impl Document {
16291631 content_type : Option < DOMString > ,
16301632 last_modified : Option < String > ,
16311633 source : DocumentSource ,
1632- doc_loader : DocumentLoader )
1634+ doc_loader : DocumentLoader ,
1635+ referrer : Option < String > )
16331636 -> Document {
16341637 let url = url. unwrap_or_else ( || Url :: parse ( "about:blank" ) . unwrap ( ) ) ;
16351638
@@ -1716,6 +1719,7 @@ impl Document {
17161719 origin : origin,
17171720 //TODO - setting this for now so no Referer header set
17181721 referrer_policy : Cell :: new ( Some ( ReferrerPolicy :: NoReferrer ) ) ,
1722+ referrer : referrer,
17191723 }
17201724 }
17211725
@@ -1732,7 +1736,8 @@ impl Document {
17321736 None ,
17331737 None ,
17341738 DocumentSource :: NotFromParser ,
1735- docloader) )
1739+ docloader,
1740+ None ) )
17361741 }
17371742
17381743 pub fn new ( window : & Window ,
@@ -1742,7 +1747,8 @@ impl Document {
17421747 content_type : Option < DOMString > ,
17431748 last_modified : Option < String > ,
17441749 source : DocumentSource ,
1745- doc_loader : DocumentLoader )
1750+ doc_loader : DocumentLoader ,
1751+ referrer : Option < String > )
17461752 -> Root < Document > {
17471753 let document = reflect_dom_object ( box Document :: new_inherited ( window,
17481754 browsing_context,
@@ -1751,7 +1757,8 @@ impl Document {
17511757 content_type,
17521758 last_modified,
17531759 source,
1754- doc_loader) ,
1760+ doc_loader,
1761+ referrer) ,
17551762 GlobalRef :: Window ( window) ,
17561763 DocumentBinding :: Wrap ) ;
17571764 {
@@ -1815,7 +1822,8 @@ impl Document {
18151822 None ,
18161823 None ,
18171824 DocumentSource :: NotFromParser ,
1818- DocumentLoader :: new ( & self . loader ( ) ) ) ;
1825+ DocumentLoader :: new ( & self . loader ( ) ) ,
1826+ None ) ;
18191827 new_doc. appropriate_template_contents_owner_document . set ( Some ( & new_doc) ) ;
18201828 new_doc
18211829 } )
@@ -1934,6 +1942,14 @@ impl DocumentMethods for Document {
19341942 }
19351943 }
19361944
1945+ // https://html.spec.whatwg.org/multipage/#dom-document-referrer
1946+ fn Referrer ( & self ) -> DOMString {
1947+ match self . referrer {
1948+ Some ( ref referrer) => DOMString :: from ( referrer. to_string ( ) ) ,
1949+ None => DOMString :: new ( )
1950+ }
1951+ }
1952+
19371953 // https://dom.spec.whatwg.org/#dom-document-documenturi
19381954 fn DocumentURI ( & self ) -> USVString {
19391955 self . URL ( )
0 commit comments