diff --git a/src/dom/document.zig b/src/dom/document.zig index 8119f357..d4cfbb21 100644 --- a/src/dom/document.zig +++ b/src/dom/document.zig @@ -34,6 +34,15 @@ pub const Document = struct { return Element.toInterface(e); } + pub fn get_documentURI(self: *parser.Document) []const u8 { + return parser.documentGetDocumentURI(self); + } + + // TODO should be get_URL but in this case, document.URL is indefined. + pub fn get_url(self: *parser.Document) []const u8 { + return get_documentURI(self); + } + // TODO implement contentType pub fn get_contentType(self: *parser.Document) []const u8 { _ = self; @@ -168,6 +177,13 @@ pub fn testExecFn( }; try checkCases(js_env, &getContentType); + var getDocumentURI = [_]Case{ + .{ .src = "document.documentURI", .ex = "about:blank" }, + // TODO should be document.URL + .{ .src = "document.url", .ex = "about:blank" }, + }; + try checkCases(js_env, &getDocumentURI); + const tags = comptime parser.Tag.all(); comptime var createElements: [(tags.len) * 2]Case = undefined; inline for (tags, 0..) |tag, i| { diff --git a/src/netsurf.zig b/src/netsurf.zig index 66571071..368e01f1 100644 --- a/src/netsurf.zig +++ b/src/netsurf.zig @@ -794,6 +794,12 @@ pub inline fn documentGetDocumentElement(doc: *Document) *Element { return elem.?; } +pub inline fn documentGetDocumentURI(doc: *Document) []const u8 { + var s: ?*String = undefined; + _ = documentVtable(doc).dom_document_get_uri.?(doc, &s); + return stringToData(s.?); +} + pub inline fn documentCreateElement(doc: *Document, tag_name: []const u8) *Element { var elem: ?*Element = undefined; _ = documentVtable(doc).dom_document_create_element.?(doc, stringFromData(tag_name), &elem);