content/base/test/test_XHRDocURI.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/base/test/test_XHRDocURI.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,497 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=459470
     1.8 +-->
     1.9 +<head>
    1.10 +  <title>XMLHttpRequest return document URIs</title>
    1.11 +  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.12 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.13 +  <base href="http://example.org/">
    1.14 +</head>
    1.15 +<body>
    1.16 +<a target="_blank"
    1.17 +   href="https://bugzilla.mozilla.org/show_bug.cgi?id=459470">Mozilla Bug 459470</a><br />
    1.18 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=859095">Mozilla Bug 859095</a>
    1.19 +
    1.20 +<p id="display">
    1.21 +<iframe id=loader></iframe>
    1.22 +</p>
    1.23 +<div id="content" style="display: none">
    1.24 +
    1.25 +</div>
    1.26 +<pre id="test">
    1.27 +<script class="testbody" type="application/javascript;version=1.8">
    1.28 +
    1.29 +SimpleTest.waitForExplicitFinish();
    1.30 +
    1.31 +gen = runTest();
    1.32 +gen.next();
    1.33 +
    1.34 +function testXMLDocURI(aDoc, aExpects) {
    1.35 +  is(aDoc.documentURI, aExpects.documentURI, "wrong url");
    1.36 +  is(aDoc.baseURI, aExpects.baseURI, "wrong base");
    1.37 +  is(aDoc.documentElement.baseURI, aExpects.elementBaseURI,
    1.38 +     "wrong base (xml:base)");
    1.39 +}
    1.40 +
    1.41 +function testChromeXMLDocURI(aDoc, aExpects) {
    1.42 +  is(aDoc.documentURI, aExpects.documentURI, "wrong url");
    1.43 +  is(aDoc.documentURIObject.spec, aExpects.documentURI,
    1.44 +     "wrong url (.documentObjectURI)");
    1.45 +  is(aDoc.baseURI, aExpects.baseURI, "wrong base");
    1.46 +  is(aDoc.baseURIObject.spec, aExpects.baseURI,
    1.47 +     "wrong base (.baseURIObject)");
    1.48 +  is(aDoc.documentElement.baseURI, aExpects.elementBaseURI,
    1.49 +     "wrong base (xml:base)");
    1.50 +  is(aDoc.documentElement.baseURIObject.spec, aExpects.elementBaseURI,
    1.51 +     "wrong base (.baseURIObject, xml:base)");
    1.52 +}
    1.53 +
    1.54 +function testHTMLDocURI(aDoc, aExpects) {
    1.55 +  is(aDoc.documentURI, aExpects.documentURI, "wrong url");
    1.56 +  is(aDoc.baseURI, aExpects.baseURI, "wrong base");
    1.57 +
    1.58 +  var base = aDoc.createElement("base");
    1.59 +  var newBaseURI = "http://www.example.com/";
    1.60 +  base.href = newBaseURI;
    1.61 +  aDoc.head.appendChild(base);
    1.62 +  is(aDoc.baseURI, newBaseURI, "wrong base (after <base> changed)");
    1.63 +}
    1.64 +
    1.65 +function testChromeHTMLDocURI(aDoc, aNonChromeBaseURI, aExpects) {
    1.66 +  is(aDoc.documentURI, aExpects.documentURI, "wrong url");
    1.67 +  is(aDoc.documentURIObject.spec, aExpects.documentURI,
    1.68 +     "wrong url (.documentURIObject)");
    1.69 +  is(aDoc.baseURI, aExpects.baseURI, "wrong base");
    1.70 +  is(aDoc.baseURIObject.spec, aExpects.baseURI,
    1.71 +     "wrong url (.baseURIObject)");
    1.72 +
    1.73 +  aDoc.body.setAttributeNS("http://www.w3.org/XML/1998/namespace", "base",
    1.74 +                           aNonChromeBaseURI);
    1.75 +  is(aDoc.body.baseURI, aNonChromeBaseURI,
    1.76 +     "wrong base (doc base and xml:base are same)");
    1.77 +  is(aDoc.body.baseURIObject.spec, aNonChromeBaseURI,
    1.78 +     "wrong base (.baseURIObject, doc base and xml:base are same)")
    1.79 +  var attr = aDoc.getElementById("data").getAttributeNode("id");
    1.80 +  is(attr.baseURI, aNonChromeBaseURI,
    1.81 +     "wrong attr base (doc base and xml:base are same)")
    1.82 +  is(attr.baseURIObject.spec, aNonChromeBaseURI,
    1.83 +     "wrong attr base (.baseURIObject, doc base and xml:base are same)")
    1.84 +
    1.85 +  var base = aDoc.createElement("base");
    1.86 +  var newBaseURI = "http://www.example.com/";
    1.87 +  base.href = newBaseURI;
    1.88 +  aDoc.head.appendChild(base);
    1.89 +  is(aDoc.baseURI, newBaseURI, "wrong base (after <base> changed)");
    1.90 +  is(aDoc.baseURIObject.spec, newBaseURI,
    1.91 +     "wrong base (.baseURIObject, after <base> changed)");
    1.92 +}
    1.93 +
    1.94 +function testCloneDocURI(aDoc) {
    1.95 +  var clone = aDoc.cloneNode(true);
    1.96 +  is(clone.documentURI, aDoc.documentURI, "wrong url (clone)");
    1.97 +  is(clone.baseURI, aDoc.baseURI, "wrong base (clone)");
    1.98 +}
    1.99 +
   1.100 +function runTest() {
   1.101 +  is(document.baseURI, "http://example.org/", "wrong doc baseURI");
   1.102 +
   1.103 +  // use content XHR and access URI properties from content privileged script
   1.104 +  xhr = new XMLHttpRequest;
   1.105 +  xhr.open("GET", "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.xml");
   1.106 +  xhr.onreadystatechange = function(e) {
   1.107 +    if (!xhr.responseXML) {
   1.108 +      return;
   1.109 +    }
   1.110 +    var expects = {
   1.111 +      documentURI: "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.xml",
   1.112 +      baseURI: "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.xml",
   1.113 +      elementBaseURI: "http://www.example.com/"
   1.114 +    };
   1.115 +    testXMLDocURI(xhr.responseXML, expects);
   1.116 +    if (xhr.readyState == 4) {
   1.117 +      gen.next();
   1.118 +    }
   1.119 +  };
   1.120 +  xhr.send();
   1.121 +  yield undefined;
   1.122 +
   1.123 +  xhr = new XMLHttpRequest;
   1.124 +  xhr.open("GET", "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.html");
   1.125 +  xhr.responseType = "document";
   1.126 +  xhr.onreadystatechange = function(e) {
   1.127 +    if (!xhr.response) {
   1.128 +      return;
   1.129 +    }
   1.130 +    var expects = {
   1.131 +      documentURI: "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.html",
   1.132 +      baseURI: "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.html"
   1.133 +    };
   1.134 +    testHTMLDocURI(xhr.response, expects);
   1.135 +    if (xhr.readyState == 4) {
   1.136 +      gen.next();
   1.137 +    }
   1.138 +  };
   1.139 +  xhr.send();
   1.140 +  yield undefined;
   1.141 +
   1.142 +  xhr = new XMLHttpRequest;
   1.143 +  xhr.open("GET", "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.text");
   1.144 +  xhr.onreadystatechange = function(e) {
   1.145 +    is(xhr.responseXML, null, "should not have document");
   1.146 +    if (xhr.readyState == 4) {
   1.147 +      gen.next();
   1.148 +    }
   1.149 +  };
   1.150 +  xhr.send();
   1.151 +  yield undefined;
   1.152 +
   1.153 +  xhr = new XMLHttpRequest;
   1.154 +  xhr.open("GET", "http://example.com/tests/content/base/test/file_XHRDocURI.xml");
   1.155 +  xhr.onreadystatechange = function(e) {
   1.156 +    if (!xhr.responseXML) {
   1.157 +      return;
   1.158 +    }
   1.159 +    var expects = {
   1.160 +      documentURI: "http://example.com/tests/content/base/test/file_XHRDocURI.xml",
   1.161 +      baseURI: "http://example.com/tests/content/base/test/file_XHRDocURI.xml",
   1.162 +      elementBaseURI: "http://www.example.com/"
   1.163 +    };
   1.164 +    testXMLDocURI(xhr.responseXML, expects);
   1.165 +    if (xhr.readyState == 4) {
   1.166 +      gen.next();
   1.167 +    }
   1.168 +  };
   1.169 +  xhr.send();
   1.170 +  yield undefined;
   1.171 +
   1.172 +  xhr = new XMLHttpRequest;
   1.173 +  xhr.open("GET", "http://example.com/tests/content/base/test/file_XHRDocURI.html");
   1.174 +  xhr.responseType = "document";
   1.175 +  xhr.onreadystatechange = function(e) {
   1.176 +    if (!xhr.response) {
   1.177 +      return;
   1.178 +    }
   1.179 +    var expects = {
   1.180 +      documentURI: "http://example.com/tests/content/base/test/file_XHRDocURI.html",
   1.181 +      baseURI: "http://example.com/tests/content/base/test/file_XHRDocURI.html"
   1.182 +    };
   1.183 +    testHTMLDocURI(xhr.response, expects);
   1.184 +    if (xhr.readyState == 4) {
   1.185 +      gen.next();
   1.186 +    }
   1.187 +  };
   1.188 +  xhr.send();
   1.189 +  yield undefined;
   1.190 +
   1.191 +  xhr = new XMLHttpRequest;
   1.192 +  xhr.open("GET", "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.sjs?url=http://example.com/tests/content/base/test/file_XHRDocURI.xml");
   1.193 +  xhr.onreadystatechange = function(e) {
   1.194 +    if (!xhr.responseXML) {
   1.195 +      return;
   1.196 +    }
   1.197 +    var expects = {
   1.198 +      documentURI: "http://example.com/tests/content/base/test/file_XHRDocURI.xml",
   1.199 +      baseURI: "http://example.com/tests/content/base/test/file_XHRDocURI.xml",
   1.200 +      elementBaseURI: "http://www.example.com/"
   1.201 +    };
   1.202 +    testXMLDocURI(xhr.responseXML, expects);
   1.203 +    if (xhr.readyState == 4) {
   1.204 +      gen.next();
   1.205 +    }
   1.206 +  };
   1.207 +  xhr.send();
   1.208 +  yield undefined;
   1.209 +
   1.210 +  xhr = new XMLHttpRequest;
   1.211 +  xhr.open("GET", "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.sjs?url=http://example.com/tests/content/base/test/file_XHRDocURI.html");
   1.212 +  xhr.responseType = "document";
   1.213 +  xhr.onreadystatechange = function(e) {
   1.214 +    if (!xhr.response) {
   1.215 +      return;
   1.216 +    }
   1.217 +    var expects = {
   1.218 +      documentURI: "http://example.com/tests/content/base/test/file_XHRDocURI.html",
   1.219 +      baseURI: "http://example.com/tests/content/base/test/file_XHRDocURI.html"
   1.220 +    };
   1.221 +    testHTMLDocURI(xhr.response, expects);
   1.222 +    if (xhr.readyState == 4) {
   1.223 +      gen.next();
   1.224 +    }
   1.225 +  };
   1.226 +  xhr.send();
   1.227 +  yield undefined;
   1.228 +
   1.229 +  xhr = new XMLHttpRequest;
   1.230 +  xhr.open("GET", "http://example.com/tests/content/base/test/file_XHRDocURI.text");
   1.231 +  xhr.onreadystatechange = function(e) {
   1.232 +    is(xhr.responseXML, null, "should not have document");
   1.233 +    if (xhr.readyState == 4) {
   1.234 +      gen.next();
   1.235 +    }
   1.236 +  };
   1.237 +  xhr.send();
   1.238 +  yield undefined;
   1.239 +
   1.240 +
   1.241 +  // use content XHR and access URI properties from chrome privileged script
   1.242 +
   1.243 +  xhr = new XMLHttpRequest;
   1.244 +  xhr.open("GET", "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.xml");
   1.245 +  xhr.onreadystatechange = function(e) {
   1.246 +    if (!xhr.responseXML) {
   1.247 +      return;
   1.248 +    }
   1.249 +    var expects = {
   1.250 +      documentURI: "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.xml",
   1.251 +      baseURI: "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.xml",
   1.252 +      elementBaseURI: "http://www.example.com/"
   1.253 +    };
   1.254 +    var xml = SpecialPowers.wrap(xhr.responseXML);
   1.255 +    testChromeXMLDocURI(xml, expects);
   1.256 +    testCloneDocURI(xml);
   1.257 +    if (xhr.readyState == 4) {
   1.258 +      gen.next();
   1.259 +    }
   1.260 +  };
   1.261 +  xhr.send();
   1.262 +  yield undefined;
   1.263 +
   1.264 +  xhr = new XMLHttpRequest;
   1.265 +  xhr.open("GET", "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.html");
   1.266 +  xhr.responseType = "document";
   1.267 +  xhr.onreadystatechange = function(e) {
   1.268 +    if (!xhr.response) {
   1.269 +      return;
   1.270 +    }
   1.271 +    var expects = {
   1.272 +      documentURI: "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.html",
   1.273 +      baseURI: "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.html"
   1.274 +    };
   1.275 +    var doc = SpecialPowers.wrap(xhr.response);
   1.276 +    testChromeHTMLDocURI(doc, "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.html", expects);
   1.277 +    testCloneDocURI(doc);
   1.278 +    if (xhr.readyState == 4) {
   1.279 +      gen.next();
   1.280 +    }
   1.281 +  };
   1.282 +  xhr.send();
   1.283 +  yield undefined;
   1.284 +
   1.285 +  xhr = new XMLHttpRequest;
   1.286 +  xhr.open("GET", "http://example.com/tests/content/base/test/file_XHRDocURI.xml");
   1.287 +  xhr.onreadystatechange = function(e) {
   1.288 +    if (!xhr.responseXML) {
   1.289 +      return;
   1.290 +    }
   1.291 +    var expects = {
   1.292 +      documentURI: document.documentURI,
   1.293 +      baseURI: document.baseURI,
   1.294 +      elementBaseURI: "http://www.example.com/"
   1.295 +    };
   1.296 +    var xml = SpecialPowers.wrap(xhr.responseXML);
   1.297 +    testChromeXMLDocURI(xml, expects);
   1.298 +    testCloneDocURI(xml);
   1.299 +    if (xhr.readyState == 4) {
   1.300 +      gen.next();
   1.301 +    }
   1.302 +  };
   1.303 +  xhr.send();
   1.304 +  yield undefined;
   1.305 +
   1.306 +  xhr = new XMLHttpRequest;
   1.307 +  xhr.open("GET", "http://example.com/tests/content/base/test/file_XHRDocURI.html");
   1.308 +  xhr.responseType = "document";
   1.309 +  xhr.onreadystatechange = function(e) {
   1.310 +    if (!xhr.response) {
   1.311 +      return;
   1.312 +    }
   1.313 +    var expects = {
   1.314 +      documentURI: document.documentURI,
   1.315 +      baseURI: document.baseURI
   1.316 +    };
   1.317 +    var doc = SpecialPowers.wrap(xhr.response);
   1.318 +    testChromeHTMLDocURI(doc, "http://example.com/tests/content/base/test/file_XHRDocURI.html", expects);
   1.319 +    testCloneDocURI(doc);
   1.320 +    if (xhr.readyState == 4) {
   1.321 +      gen.next();
   1.322 +    }
   1.323 +  };
   1.324 +  xhr.send();
   1.325 +  yield undefined;
   1.326 +
   1.327 +  xhr = new XMLHttpRequest;
   1.328 +  xhr.open("GET", "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.sjs?url=http://example.com/tests/content/base/test/file_XHRDocURI.xml");
   1.329 +  xhr.onreadystatechange = function(e) {
   1.330 +    if (!xhr.responseXML) {
   1.331 +      return;
   1.332 +    }
   1.333 +    var expects = {
   1.334 +      documentURI: document.documentURI,
   1.335 +      baseURI: document.baseURI,
   1.336 +      elementBaseURI: "http://www.example.com/"
   1.337 +    };
   1.338 +    var xml = SpecialPowers.wrap(xhr.responseXML);
   1.339 +    testChromeXMLDocURI(xml, expects);
   1.340 +    testCloneDocURI(xml);
   1.341 +    if (xhr.readyState == 4) {
   1.342 +      gen.next();
   1.343 +    }
   1.344 +  };
   1.345 +  xhr.send();
   1.346 +  yield undefined;
   1.347 +
   1.348 +  xhr = new XMLHttpRequest;
   1.349 +  xhr.open("GET", "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.sjs?url=http://example.com/tests/content/base/test/file_XHRDocURI.html");
   1.350 +  xhr.responseType = "document";
   1.351 +  xhr.onreadystatechange = function(e) {
   1.352 +    if (!xhr.response) {
   1.353 +      return;
   1.354 +    }
   1.355 +    var expects = {
   1.356 +      documentURI: document.documentURI,
   1.357 +      baseURI: document.baseURI
   1.358 +    };
   1.359 +    var doc = SpecialPowers.wrap(xhr.response);
   1.360 +    testChromeHTMLDocURI(doc, "http://example.com/tests/content/base/test/file_XHRDocURI.html", expects);
   1.361 +    testCloneDocURI(doc);
   1.362 +    if (xhr.readyState == 4) {
   1.363 +      gen.next();
   1.364 +    }
   1.365 +  };
   1.366 +  xhr.send();
   1.367 +  yield undefined;
   1.368 +
   1.369 +
   1.370 +  // use chrome XHR and access URI properties from chrome privileged script
   1.371 +  SpecialPowers.addPermission("systemXHR", true, document);
   1.372 +  xhr = new XMLHttpRequest({mozAnon: false, mozSystem: true});
   1.373 +  xhr.open("GET", "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.xml");
   1.374 +  xhr.onreadystatechange = function(e) {
   1.375 +    if (!xhr.responseXML) {
   1.376 +      return;
   1.377 +    }
   1.378 +    var expects = {
   1.379 +      documentURI: "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.xml",
   1.380 +      baseURI: "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.xml",
   1.381 +      elementBaseURI: "http://www.example.com/"
   1.382 +    };
   1.383 +    var xml = SpecialPowers.wrap(xhr.responseXML);
   1.384 +    testChromeXMLDocURI(xml, expects);
   1.385 +    if (xhr.readyState == 4) {
   1.386 +      gen.next();
   1.387 +    }
   1.388 +  };
   1.389 +  xhr.send();
   1.390 +  yield undefined;
   1.391 +
   1.392 +  xhr = new XMLHttpRequest({mozAnon: false, mozSystem: true});
   1.393 +  xhr.open("GET", "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.html");
   1.394 +  xhr.responseType = "document";
   1.395 +  xhr.onreadystatechange = function(e) {
   1.396 +    if (!xhr.response) {
   1.397 +      return;
   1.398 +    }
   1.399 +    var expects = {
   1.400 +      documentURI: "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.html",
   1.401 +      baseURI: "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.html"
   1.402 +    };
   1.403 +    var doc = SpecialPowers.wrap(xhr.response);
   1.404 +    testChromeHTMLDocURI(doc, "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.html", expects);
   1.405 +    if (xhr.readyState == 4) {
   1.406 +      gen.next();
   1.407 +    }
   1.408 +  };
   1.409 +  xhr.send();
   1.410 +  yield undefined;
   1.411 +
   1.412 +  xhr = new XMLHttpRequest({mozAnon: false, mozSystem: true});
   1.413 +  xhr.open("GET", "http://example.com/tests/content/base/test/file_XHRDocURI.xml");
   1.414 +  xhr.onreadystatechange = function(e) {
   1.415 +    if (!xhr.responseXML) {
   1.416 +      return;
   1.417 +    }
   1.418 +    var expects = {
   1.419 +      documentURI: "http://example.com/tests/content/base/test/file_XHRDocURI.xml",
   1.420 +      baseURI: "http://example.com/tests/content/base/test/file_XHRDocURI.xml",
   1.421 +      elementBaseURI: "http://www.example.com/"
   1.422 +    };
   1.423 +    var xml = SpecialPowers.wrap(xhr.responseXML);
   1.424 +    testChromeXMLDocURI(xml, expects);
   1.425 +    if (xhr.readyState == 4) {
   1.426 +      gen.next();
   1.427 +    }
   1.428 +  };
   1.429 +  xhr.send();
   1.430 +  yield undefined;
   1.431 +
   1.432 +  xhr = new XMLHttpRequest({mozAnon: false, mozSystem: true});
   1.433 +  xhr.open("GET", "http://example.com/tests/content/base/test/file_XHRDocURI.html");
   1.434 +  xhr.responseType = "document";
   1.435 +  xhr.onreadystatechange = function(e) {
   1.436 +    if (!xhr.response) {
   1.437 +      return;
   1.438 +    }
   1.439 +    var expects = {
   1.440 +      documentURI: "http://example.com/tests/content/base/test/file_XHRDocURI.html",
   1.441 +      baseURI: "http://example.com/tests/content/base/test/file_XHRDocURI.html"
   1.442 +    };
   1.443 +    var doc = SpecialPowers.wrap(xhr.response);
   1.444 +    testChromeHTMLDocURI(doc, "http://example.com/tests/content/base/test/file_XHRDocURI.html", expects);
   1.445 +    if (xhr.readyState == 4) {
   1.446 +      gen.next();
   1.447 +    }
   1.448 +  };
   1.449 +  xhr.send();
   1.450 +  yield undefined;
   1.451 +
   1.452 +  xhr = new XMLHttpRequest({mozAnon: false, mozSystem: true});
   1.453 +  xhr.open("GET", "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.sjs?url=http://example.com/tests/content/base/test/file_XHRDocURI.xml");
   1.454 +  xhr.onreadystatechange = function(e) {
   1.455 +    if (!xhr.responseXML) {
   1.456 +      return;
   1.457 +    }
   1.458 +    var expects = {
   1.459 +      documentURI: "http://example.com/tests/content/base/test/file_XHRDocURI.xml",
   1.460 +      baseURI: "http://example.com/tests/content/base/test/file_XHRDocURI.xml",
   1.461 +      elementBaseURI: "http://www.example.com/"
   1.462 +    };
   1.463 +    var xml = SpecialPowers.wrap(xhr.responseXML);
   1.464 +    testChromeXMLDocURI(xml, expects);
   1.465 +    if (xhr.readyState == 4) {
   1.466 +      gen.next();
   1.467 +    }
   1.468 +  };
   1.469 +  xhr.send();
   1.470 +  yield undefined;
   1.471 +
   1.472 +  xhr = new XMLHttpRequest({mozAnon: false, mozSystem: true});
   1.473 +  xhr.open("GET", "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.sjs?url=http://example.com/tests/content/base/test/file_XHRDocURI.html");
   1.474 +  xhr.responseType = "document";
   1.475 +  xhr.onreadystatechange = function(e) {
   1.476 +    if (!xhr.response) {
   1.477 +      return;
   1.478 +    }
   1.479 +    var expects = {
   1.480 +      documentURI: "http://example.com/tests/content/base/test/file_XHRDocURI.html",
   1.481 +      baseURI: "http://example.com/tests/content/base/test/file_XHRDocURI.html"
   1.482 +    };
   1.483 +    var doc = SpecialPowers.wrap(xhr.response);
   1.484 +    testChromeHTMLDocURI(doc, "http://example.com/tests/content/base/test/file_XHRDocURI.html", expects);
   1.485 +    if (xhr.readyState == 4) {
   1.486 +      gen.next();
   1.487 +    }
   1.488 +  };
   1.489 +  xhr.send();
   1.490 +  yield undefined;
   1.491 +
   1.492 +  SimpleTest.finish();
   1.493 +  SpecialPowers.removePermission("systemXHR", document);
   1.494 +  yield undefined;
   1.495 +}
   1.496 +
   1.497 +</script>
   1.498 +</pre>
   1.499 +</body>
   1.500 +</html>

mercurial