summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/data/html/INDEX2
-rw-r--r--test/data/html/isindex.html8
-rw-r--r--test/data/html/misnested.html11
-rw-r--r--test/tree.c84
4 files changed, 86 insertions, 19 deletions
diff --git a/test/data/html/INDEX b/test/data/html/INDEX
index cd97b8e..25483db 100644
--- a/test/data/html/INDEX
+++ b/test/data/html/INDEX
@@ -6,3 +6,5 @@ section-tree-construction.html HTML5 tree construction algorithm
#web-apps.html HTML5 specification
initial-close-tag.html Page with initial </html>
#phonecalls.html HTML document that breaks libxml's HTML parser
+misnested.html Misnested tags
+isindex.html Test of <isindex> parsing
diff --git a/test/data/html/isindex.html b/test/data/html/isindex.html
new file mode 100644
index 0000000..f454069
--- /dev/null
+++ b/test/data/html/isindex.html
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<html>
+<body>
+<isindex action="foo" name="bar">
+<isindex action="foo" name="bar" prompt="baz">
+</body>
+</html>
+
diff --git a/test/data/html/misnested.html b/test/data/html/misnested.html
new file mode 100644
index 0000000..1116840
--- /dev/null
+++ b/test/data/html/misnested.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>Misnested tags</title>
+</head>
+<body>
+<p>Hello <b>this <i>is a test </b>of badly </i>nested tags</p>
+<p>Hello <b>this <i>is a <button>test </b>of badly </i>nested tags</p>
+<p>Hello <a>this is <p><a>test </p></p>
+</body>
+</html>
diff --git a/test/tree.c b/test/tree.c
index f4e6c3c..4370139 100644
--- a/test/tree.c
+++ b/test/tree.c
@@ -37,8 +37,6 @@ static int create_doctype(void *ctx, const hubbub_string *qname,
const hubbub_string *public_id, const hubbub_string *system_id,
void **result);
static int create_element(void *ctx, const hubbub_tag *tag, void **result);
-static int create_element_verbatim(void *ctx, const uint8_t *name, size_t len,
- void **result);
static int create_text(void *ctx, const hubbub_string *data, void **result);
static int ref_node(void *ctx, void *node);
static int unref_node(void *ctx, void *node);
@@ -47,13 +45,18 @@ static int insert_before(void *ctx, void *parent, void *child, void *ref_child,
void **result);
static int remove_child(void *ctx, void *parent, void *child, void **result);
static int clone_node(void *ctx, void *node, bool deep, void **result);
+static int reparent_children(void *ctx, void *node, void *new_parent);
+static int get_parent(void *ctx, void *node, bool element_only, void **result);
+static int has_children(void *ctx, void *node, bool *result);
+static int form_associate(void *ctx, void *form, void *node);
+static int add_attributes(void *ctx, void *node,
+ const hubbub_attribute *attributes, uint32_t n_attributes);
static int set_quirks_mode(void *ctx, hubbub_quirks_mode mode);
static hubbub_tree_handler tree_handler = {
create_comment,
create_doctype,
create_element,
- create_element_verbatim,
create_text,
ref_node,
unref_node,
@@ -61,6 +64,11 @@ static hubbub_tree_handler tree_handler = {
insert_before,
remove_child,
clone_node,
+ reparent_children,
+ get_parent,
+ has_children,
+ form_associate,
+ add_attributes,
set_quirks_mode,
NULL
};
@@ -251,22 +259,6 @@ int create_element(void *ctx, const hubbub_tag *tag, void **result)
return 0;
}
-int create_element_verbatim(void *ctx, const uint8_t *name, size_t len,
- void **result)
-{
- printf("Creating (%u) [element verbatim '%.*s']\n",
- ++node_counter, len, name);
-
- GROW_REF
- node_ref[node_counter] = 0;
-
- ref_node(ctx, (void *) node_counter);
-
- *result = (void *) node_counter;
-
- return 0;
-}
-
int create_text(void *ctx, const hubbub_string *data, void **result)
{
printf("Creating (%u) [text '%.*s']\n", ++node_counter,
@@ -349,6 +341,60 @@ int clone_node(void *ctx, void *node, bool deep, void **result)
return 0;
}
+int reparent_children(void *ctx, void *node, void *new_parent)
+{
+ UNUSED(ctx);
+
+ printf("Reparenting children of %u to %u\n",
+ (uintptr_t) node, (uintptr_t) new_parent);
+
+ return 0;
+}
+
+int get_parent(void *ctx, void *node, bool element_only, void **result)
+{
+ printf("Retrieving parent of %u (%s)\n", (uintptr_t) node,
+ element_only ? "element only" : "");
+
+ ref_node(ctx, (void *) 1);
+ *result = (void *) 1;
+
+ return 0;
+}
+
+int has_children(void *ctx, void *node, bool *result)
+{
+ UNUSED(ctx);
+
+ printf("Want children for %u\n", (uintptr_t) node);
+
+ *result = false;
+
+ return 0;
+}
+
+int form_associate(void *ctx, void *form, void *node)
+{
+ UNUSED(ctx);
+
+ printf("Associating %u with form %u\n",
+ (uintptr_t) node, (uintptr_t) form);
+
+ return 0;
+}
+
+int add_attributes(void *ctx, void *node,
+ const hubbub_attribute *attributes, uint32_t n_attributes)
+{
+ UNUSED(ctx);
+ UNUSED(attributes);
+ UNUSED(n_attributes);
+
+ printf("Adding attributes to %u\n", (uintptr_t) node);
+
+ return 0;
+}
+
int set_quirks_mode(void *ctx, hubbub_quirks_mode mode)
{
UNUSED(ctx);