mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Implement document.domain getter
This commit is contained in:
parent
e3eee5a41b
commit
0e0e051f3f
7 changed files with 50 additions and 10 deletions
|
@ -105,7 +105,7 @@ use string_cache::{Atom, QualName};
|
|||
use style::restyle_hints::ElementSnapshot;
|
||||
use style::stylesheets::Stylesheet;
|
||||
use time;
|
||||
use url::Url;
|
||||
use url::{Host, Url};
|
||||
use util::str::{DOMString, split_html_space_chars, str_join};
|
||||
|
||||
#[derive(JSTraceable, PartialEq, HeapSizeOf)]
|
||||
|
@ -1647,6 +1647,19 @@ impl DocumentMethods for Document {
|
|||
}
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#relaxing-the-same-origin-restriction
|
||||
fn Domain(&self) -> DOMString {
|
||||
// TODO: This should use the effective script origin when it exists
|
||||
let origin = self.window.get_url();
|
||||
|
||||
if let Some(&Host::Ipv6(ipv6)) = origin.host() {
|
||||
// Omit square brackets for IPv6 addresses.
|
||||
return DOMString::from(ipv6.serialize());
|
||||
}
|
||||
|
||||
DOMString::from(origin.serialize_host().unwrap_or_else(|| "".to_owned()))
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-document-documenturi
|
||||
fn DocumentURI(&self) -> DOMString {
|
||||
self.URL()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue