mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-30 07:31:47 +00:00
dom: DocumentHTML getters
This commit is contained in:
@@ -18,9 +18,35 @@ pub const HTMLDocument = struct {
|
|||||||
// JS funcs
|
// JS funcs
|
||||||
// --------
|
// --------
|
||||||
|
|
||||||
|
pub fn get_domain(self: *parser.DocumentHTML) ![]const u8 {
|
||||||
|
return try parser.documentHTMLGetDomain(self);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_domain(_: *parser.DocumentHTML, _: []const u8) ![]const u8 {
|
||||||
|
return parser.DOMError.NotSupported;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_referrer(self: *parser.DocumentHTML) ![]const u8 {
|
||||||
|
return try parser.documentHTMLGetReferrer(self);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_referrer(_: *parser.DocumentHTML, _: []const u8) ![]const u8 {
|
||||||
|
return parser.DOMError.NotSupported;
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_body(self: *parser.DocumentHTML) !?*parser.Body {
|
pub fn get_body(self: *parser.DocumentHTML) !?*parser.Body {
|
||||||
return try parser.documentHTMLBody(self);
|
return try parser.documentHTMLBody(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: not implemented by libdom
|
||||||
|
pub fn get_cookie(_: *parser.DocumentHTML) ![]const u8 {
|
||||||
|
return error.NotImplemented;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: not implemented by libdom
|
||||||
|
pub fn set_cookie(_: *parser.DocumentHTML, _: []const u8) ![]const u8 {
|
||||||
|
return parser.DOMError.NotSupported;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Tests
|
// Tests
|
||||||
@@ -37,4 +63,10 @@ pub fn testExecFn(
|
|||||||
.{ .src = "document.body.localName == 'body'", .ex = "true" },
|
.{ .src = "document.body.localName == 'body'", .ex = "true" },
|
||||||
};
|
};
|
||||||
try checkCases(js_env, &constructor);
|
try checkCases(js_env, &constructor);
|
||||||
|
|
||||||
|
var getters = [_]Case{
|
||||||
|
.{ .src = "document.domain", .ex = "" },
|
||||||
|
.{ .src = "document.referrer", .ex = "" },
|
||||||
|
};
|
||||||
|
try checkCases(js_env, &getters);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1450,3 +1450,19 @@ pub inline fn documentHTMLBody(doc_html: *DocumentHTML) !?*Body {
|
|||||||
if (body == null) return null;
|
if (body == null) return null;
|
||||||
return @as(*Body, @ptrCast(body.?));
|
return @as(*Body, @ptrCast(body.?));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn documentHTMLGetDomain(doc: *DocumentHTML) ![]const u8 {
|
||||||
|
var s: ?*String = undefined;
|
||||||
|
const err = documentHTMLVtable(doc).get_domain.?(doc, &s);
|
||||||
|
try DOMErr(err);
|
||||||
|
if (s == null) return "";
|
||||||
|
return strToData(s.?);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn documentHTMLGetReferrer(doc: *DocumentHTML) ![]const u8 {
|
||||||
|
var s: ?*String = undefined;
|
||||||
|
const err = documentHTMLVtable(doc).get_referrer.?(doc, &s);
|
||||||
|
try DOMErr(err);
|
||||||
|
if (s == null) return "";
|
||||||
|
return strToData(s.?);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user