aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/script/dom/node.rs7
-rw-r--r--components/script/dom/webidls/Node.webidl2
-rw-r--r--tests/wpt/metadata/MANIFEST.json6
-rw-r--r--tests/wpt/metadata/html/infrastructure/urls/terminology-0/document-base-url.html.ini2
-rw-r--r--tests/wpt/web-platform-tests/dom/nodes/Node-baseURI.html32
5 files changed, 42 insertions, 7 deletions
diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs
index 2d009dd4159..c5d435d5156 100644
--- a/components/script/dom/node.rs
+++ b/components/script/dom/node.rs
@@ -987,7 +987,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
@@ -1950,9 +1950,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/metadata/html/infrastructure/urls/terminology-0/document-base-url.html.ini b/tests/wpt/metadata/html/infrastructure/urls/terminology-0/document-base-url.html.ini
index 0709e4b7387..a9ce512b7d8 100644
--- a/tests/wpt/metadata/html/infrastructure/urls/terminology-0/document-base-url.html.ini
+++ b/tests/wpt/metadata/html/infrastructure/urls/terminology-0/document-base-url.html.ini
@@ -5,7 +5,7 @@
expected: FAIL
[The fallback base URL of a document containing no base element is the document's address.]
- expected: FAIL
+ expected: PASS
[The fallback base URL of a document whose address is about:blank is the document base URL of the creator document.]
expected: TIMEOUT
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..1672b6ecd22
--- /dev/null
+++ b/tests/wpt/web-platform-tests/dom/nodes/Node-baseURI.html
@@ -0,0 +1,32 @@
+<!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.body.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.body.appendChild(fragment);
+ assert_equals(element.baseURI, document.URL)
+}, "After inserting fragment into document, element baseURI should be document url")
+</script>