mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Auto merge of #8655 - jdm:domain, r=jdm
Implement document.domain getter Rebased from #6840 + test fixes. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8655) <!-- Reviewable:end -->
This commit is contained in:
commit
0905088e83
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()
|
||||
|
|
|
@ -81,7 +81,7 @@ partial /*sealed*/ interface Document {
|
|||
// resource metadata management
|
||||
// [PutForwards=href, Unforgeable]
|
||||
readonly attribute Location/*?*/ location;
|
||||
// attribute DOMString domain;
|
||||
readonly attribute DOMString domain;
|
||||
// readonly attribute DOMString referrer;
|
||||
[Throws]
|
||||
attribute DOMString cookie;
|
||||
|
|
|
@ -29953,6 +29953,12 @@
|
|||
"deleted": [],
|
||||
"items": {
|
||||
"testharness": {
|
||||
"html/browsers/origin/relaxing-the-same-origin-restriction/document_domain.html": [
|
||||
{
|
||||
"path": "html/browsers/origin/relaxing-the-same-origin-restriction/document_domain.html",
|
||||
"url": "/html/browsers/origin/relaxing-the-same-origin-restriction/document_domain.html"
|
||||
}
|
||||
],
|
||||
"html/semantics/forms/form-submission-0/url-encoded.html": [
|
||||
{
|
||||
"path": "html/semantics/forms/form-submission-0/url-encoded.html",
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
[send-after-setting-document-domain.htm]
|
||||
type: testharness
|
||||
[loading documents from original origin after setting document.domain]
|
||||
expected: FAIL
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
[document_domain.html]
|
||||
type: testharness
|
||||
[new document]
|
||||
expected: FAIL
|
|
@ -9003,9 +9003,6 @@
|
|||
[Document interface: document.implementation.createDocument(null, "", null) must inherit property "enableStyleSheetsForSet" with the proper type (33)]
|
||||
expected: FAIL
|
||||
|
||||
[Document interface: document.implementation.createDocument(null, "", null) must inherit property "domain" with the proper type (35)]
|
||||
expected: FAIL
|
||||
|
||||
[Document interface: document.implementation.createDocument(null, "", null) must inherit property "referrer" with the proper type (36)]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
test(function() {
|
||||
assert_equals(typeof document.domain, "string", "document.domain is a string");
|
||||
assert_not_equals(document.domain, "", "document.domain is not empty");
|
||||
}, "sanity checks");
|
||||
|
||||
test(function() {
|
||||
assert_equals(document.domain, window.location.hostname, "equals location.hostname");
|
||||
}, "current document");
|
||||
|
||||
test(function() {
|
||||
var doc = new Document();
|
||||
assert_equals(doc.domain, "", "new document has empty domain");
|
||||
}, "new document");
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue