// 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(""); 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(''); } 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(""); var elmt = document.getElementById(id); return JSON.stringify([ elmt.protocol, elmt.hostname, elmt.port, elmt.pathname, elmt.search, elmt.hash ]); }