blob: 631bdeca9c56775f5cf8a78577e11fadab75357c (
plain)
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
|
// Start the bidding at 42 for no particular reason.
var lastID = 42;
function canonicalize(url)
{
// It would be more elegant to use the DOM here, but we use document.write()
// so the tests run correctly in Firefox.
var id = ++lastID;
document.write("<a id='" + id + "' href='" + url + "'></a>");
return document.getElementById(id).href;
}
function setBaseURL(url)
{
// It would be more elegant to use the DOM here, but we chose document.write()
// so the tests ran correctly in Firefox at the time we originally wrote them.
// Remove any existing base elements.
var existingBase = document.getElementsByTagName('base');
while (existingBase.length) {
var element = existingBase[0];
element.parentNode.removeChild(element);
}
// Add a new base element.
document.write('<base href="' + url + '">');
}
function segments(url)
{
// It would be more elegant to use the DOM here, but we use document.write()
// so the tests run correctly in Firefox.
var id = ++lastID;
document.write("<a id='" + id + "' href='" + url + "'></a>");
var elmt = document.getElementById(id);
return JSON.stringify([
elmt.protocol,
elmt.hostname,
elmt.port,
elmt.pathname,
elmt.search,
elmt.hash
]);
}
|