forked from cweb/url-testing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
url-HTTP.html
84 lines (78 loc) · 3.29 KB
/
url-HTTP.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<!doctype html>
<html>
<head>
<title>run url tests</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
<link rel="stylesheet" href="css/testharness.css">
<script src="js/testharness.js"></script>
<script src="js/testharnessreport.js"></script>
<script src="js/test-http.js"></script>
</head>
<body>
<h1>Goal</h1>
<p>Test for discrepancy between a URL's parsed components as they appear in the DOM properties versus an HTTP GET request.</p>
<h1>Description</h1>
<p>This page tests how a URL's properties compare in the DOM and an HTTP GET request, using the following method:</p>
<ul>
<li>Load test cases from <a herf="urls-local.json">urls-local.json</a></li>
<li>For each test case, create an iframe in the same origin as the parent document.</li>
<li>In the iframe, create an anchor element with the test case as href, e.g.:</li>
<pre><a href="http://urltest.lookout.net/foo?bar"></a></pre>
<li>In the iframe reate a script element with the test case as src, e.g.:</li>
<pre><script src="http://urltest.lookout.net/foo?bar"></script></pre>
<li>This host is setup with a wildcard DNS record, a mod_rewrite rule, and a CGI script so that any request that includes "urltest" in the hostname will return a javascript document with two variables: "hostname" and "pathname" with values taken from the HTTP GET request.</li>
<li>Compare the DOM properties of the anchor's href, with the two javascript variables returned from the HTTP GET request.</li>
</ul>
<div id="log"></div>
</body>
<script>
// Start your engines
init();
for (var i = 0; i < data.tests.group.length; i++) {
var group = data.tests.group[i];
for (var j = 0, len = group.test.length; j < len; j++) {
var testcase = group.test[j];
if (group.name == "host" ||
group.name == "idna2008" ||
group.name == "idna2003" ||
group.name == "ipv4" ||
group.name == "ipv6" ||
group.name == "mailto" ||
group.name == "path-url" ||
group.name == "path" ||
group.name == "port" ||
group.name == "query" ||
group.name == "scheme" ||
group.name == "standard-url" ||
group.name == "whitespace"
) {
test_simple(group.name + " - " + testcase.id + ": testing " + testcase.url,
testcase.url);
}
else if (group.name == "relative" ||
group.name == "trivial"
) {
test_simple(group.name + " - " + testcase.id + ": testing base " + testcase.base + " and relative " + testcase.rel,
testcase.base,
testcase.rel);
}
else if (group.name == "segments" ) {
test_components(group.name + " - " + testcase.id + ": testing base " + testcase.base + " and relative " + testcase.rel,
testcase.base,
testcase.rel);
}
else if (group.name == "miscellaneous" ||
group.name == "data-scheme"
) {
test_components(group.name + " - " + testcase.id + ": testing " + testcase.url,
testcase.url);
}
else if (group.name == "normalization" ||
group.name == "percent-encoding"
) {
// TODO Test these
}
}
}
</script>
</html>