Testing HTML

Getting the Code

hg clone http://dvcs.w3.org/hg/html

Creating and Submitting a Test

cd html/tests/submission/Opera/
mkdir table
emacs table_api.html
hg commit table_api.html -m "tests for the table element api"
hg push

Simple test

<!DOCTYPE html>
<title>Testcase Title</title>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testharness.js"></script>
<script>test(function() {assert_equals(1+1,2)}, "Test addition")</script>

Test for the Table API

<!DOCTYPE HTML>
<html>
<head>
<title>Test Table API</title>
</head>
<h1>Test Table API</h1>
<div id="log"></div>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<table id="a">
<caption id="caption_1"></caption>
<caption id="caption_2"></caption>
</table>
<table id="b"></table>
<script>

test(function() {assert_equals(document.getElementById("a").caption,
document.getElementById("caption_1"))},
"Caption property must be the first caption child of the table");

test(function() {assert_equals(document.getElementById("b").caption, null)},
"Tables with no caption child must have null .caption");

</script>