diff options
author | Kevin Ball <kmball11@gmail.com> | 2015-07-05 15:29:04 -0700 |
---|---|---|
committer | Kevin Ball <kmball11@gmail.com> | 2015-07-05 15:29:04 -0700 |
commit | dbbab3b113e24e2e3be4b8556218e44ca5a1db35 (patch) | |
tree | 08b27d27f4f7b32261e0143bf2bc56885eb4dc4e | |
parent | 0fb6604cb37da0ca0f4852328def21100a38fd63 (diff) | |
download | servo-dbbab3b113e24e2e3be4b8556218e44ca5a1db35.tar.gz servo-dbbab3b113e24e2e3be4b8556218e44ca5a1db35.zip |
Implement Node.baseURI
-rw-r--r-- | components/script/dom/node.rs | 7 | ||||
-rw-r--r-- | components/script/dom/webidls/Node.webidl | 2 | ||||
-rw-r--r-- | tests/wpt/metadata/MANIFEST.json | 6 | ||||
-rw-r--r-- | tests/wpt/web-platform-tests/dom/nodes/Node-baseURI.html | 29 |
4 files changed, 38 insertions, 6 deletions
diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index b69dd3fad46..b892a60daf3 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -993,7 +993,7 @@ impl<'a> NodeHelpers for &'a Node { fn summarize(self) -> NodeInfo { NodeInfo { uniqueId: self.get_unique_id(), - baseURI: self.GetBaseURI().unwrap_or("".to_owned()), + baseURI: self.BaseURI(), parent: self.GetParentNode().map(|node| node.r().get_unique_id()).unwrap_or("".to_owned()), nodeType: self.NodeType(), namespaceURI: "".to_owned(), //FIXME @@ -1956,9 +1956,8 @@ impl<'a> NodeMethods for &'a Node { } // https://dom.spec.whatwg.org/#dom-node-baseuri - fn GetBaseURI(self) -> Option<DOMString> { - // FIXME (#1824) implement. - None + fn BaseURI(self) -> DOMString { + self.owner_doc().URL() } // https://dom.spec.whatwg.org/#dom-node-ownerdocument diff --git a/components/script/dom/webidls/Node.webidl b/components/script/dom/webidls/Node.webidl index 2bc3624157a..70561bb1b72 100644 --- a/components/script/dom/webidls/Node.webidl +++ b/components/script/dom/webidls/Node.webidl @@ -26,7 +26,7 @@ interface Node : EventTarget { readonly attribute DOMString nodeName; [Pure] - readonly attribute DOMString? baseURI; + readonly attribute DOMString baseURI; [Pure] readonly attribute Document? ownerDocument; diff --git a/tests/wpt/metadata/MANIFEST.json b/tests/wpt/metadata/MANIFEST.json index ca40eed366e..9cc668a4f88 100644 --- a/tests/wpt/metadata/MANIFEST.json +++ b/tests/wpt/metadata/MANIFEST.json @@ -13118,6 +13118,10 @@ "url": "/dom/nodes/Node-appendChild.html" }, { + "path": "dom/nodes/Node-baseURI.html", + "url": "/dom/nodes/Node-baseURI.html" + }, + { "path": "dom/nodes/Node-childNodes.html", "url": "/dom/nodes/Node-childNodes.html" }, @@ -31931,4 +31935,4 @@ "rev": "87398b8448f699e3e324148795891658f2fa16dd", "url_base": "/", "version": 2 -}
\ No newline at end of file +} diff --git a/tests/wpt/web-platform-tests/dom/nodes/Node-baseURI.html b/tests/wpt/web-platform-tests/dom/nodes/Node-baseURI.html new file mode 100644 index 00000000000..76a9023d5b8 --- /dev/null +++ b/tests/wpt/web-platform-tests/dom/nodes/Node-baseURI.html @@ -0,0 +1,29 @@ +<!DOCTYPE html> +<title>Node.baseURI</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +test(function() { + var element =document.createElement("div"); + document.getElementById("log").appendChild(element); + assert_equals(element.baseURI, document.URL); +}, "For elements belonging to document, baseURI should be document url") +test(function() { + var element =document.createElement("div"); + assert_equals(element.baseURI, document.URL); +}, "For elements unassigned to document, baseURI should be document url") +test(function() { + var fragment = document.createDocumentFragment(); + var element =document.createElement("div"); + fragment.appendChild(element); + assert_equals(element.baseURI, document.URL) +}, "For elements belonging to document fragments, baseURI should be document url") +test(function() { + var fragment = document.createDocumentFragment(); + var element =document.createElement("div"); + fragment.appendChild(element); + document.getElementById("log").appendChild(fragment); + assert_equals(element.baseURI, document.URL) +}, "After inserting fragment into document, element baseURI should be document url") +</script> |