document: re-dispatch tests between node document and html document

This commit is contained in:
Pierre Tachoire
2023-10-18 14:11:31 +02:00
parent b8efce8f34
commit 34d5f2800e
2 changed files with 0 additions and 33 deletions

View File

@@ -48,7 +48,6 @@ pub fn testExecFn(
.{ .src = "document.__proto__.__proto__.constructor.name", .ex = "Document" },
.{ .src = "document.__proto__.__proto__.__proto__.constructor.name", .ex = "Node" },
.{ .src = "document.__proto__.__proto__.__proto__.__proto__.constructor.name", .ex = "EventTarget" },
.{ .src = "document.body.localName == 'body'", .ex = "true" },
};
try checkCases(js_env, &constructor);

View File

@@ -34,39 +34,7 @@ pub fn testExecFn(
var constructor = [_]Case{
.{ .src = "document.__proto__.constructor.name", .ex = "HTMLDocument" },
.{ .src = "document.__proto__.__proto__.constructor.name", .ex = "Document" },
.{ .src = "document.__proto__.__proto__.__proto__.constructor.name", .ex = "Node" },
.{ .src = "document.__proto__.__proto__.__proto__.__proto__.constructor.name", .ex = "EventTarget" },
.{ .src = "document.body.localName == 'body'", .ex = "true" },
};
try checkCases(js_env, &constructor);
var getElementById = [_]Case{
.{ .src = "let getElementById = document.getElementById('content')", .ex = "undefined" },
.{ .src = "getElementById.constructor.name", .ex = "HTMLDivElement" },
.{ .src = "getElementById.localName", .ex = "div" },
};
try checkCases(js_env, &getElementById);
const tags = comptime parser.Tag.all();
const elements = comptime parser.Tag.allElements();
comptime var createElements: [(tags.len) * 3]Case = undefined;
inline for (tags, elements, 0..) |tag, element_name, i| {
// if (tag == .undef) {
// continue;
// }
const tag_name = @tagName(tag);
createElements[i * 3] = Case{
.src = "var " ++ tag_name ++ "Elem = document.createElement('" ++ tag_name ++ "')",
.ex = "undefined",
};
createElements[(i * 3) + 1] = Case{
.src = tag_name ++ "Elem.constructor.name",
.ex = "HTML" ++ element_name ++ "Element",
};
createElements[(i * 3) + 2] = Case{
.src = tag_name ++ "Elem.localName",
.ex = tag_name,
};
}
try checkCases(js_env, &createElements);
}